clerkio / clerk-magento

Other
8 stars 20 forks source link

Please add category Title Chooser in config #76

Open seansan opened 5 years ago

seansan commented 5 years ago

Please add category Title Chooser in config

Some websites use two attributs for categories

  1. for the TITLE in the menu navigation
  2. for the NAME H1 on the page (page title)

The TITLE can be quite short something like "White"; suppose in a menu like "Shirts->White"; however the page title on the page is "White Shirts" taken from another attribute

Default should stay default 'name' but one should be able to change it in the backend

Quick and SImple win ; also goes for M2

seansan commented 5 years ago

Can be updated in public function categoryAction()


// 1. GET SETTING FROM BACKEND HERE

        // SNH CUSTOM 4-2-2019 CHANGED DB FETCH and added ->addAttributeToSelect('page_title')
        $categories = Mage::getModel('catalog/category')
            ->getCollection()
            ->addIsActiveFilter()
            ->addAttributeToSelect('name')
            ->addAttributeToSelect('page_title')                                    // 2. ADD FETCH DATA HERE
            ->addAttributeToFilter('path', ['like' => "1/{$rootCategoryId}/%"])
            ->setOrder('entity_id', Varien_Db_Select::SQL_ASC)
            ->setPageSize($limit)
            ->setCurPage($page);

        $items = [];

        foreach ($categories as $category) {
            //Get children categories
            $children = $category->getResource()->getChildren($category, false);

            // SNH CUSTOM 4-2-2019 CHANGED CATEGORIES FETCH FROM: $category->getName() to $category->getPageTitle(),
            $data = [
                'id' => (int) $category->getId(),
                'name' => $category->getPageTitle(),                                // 3. SUBMIT DATA HERE .... CAN ALSO BE EXTRA FIELD OF CLERK SUPPORTS IT
                'url' => $category->getUrl(),
                'subcategories' => array_map('intval', $children),
            ];