1

I have a page that is setup to display all product categories. How do I sort these alphabetically?

This is what the block looks like

{{block type="core/template" template="catalog/category/cat-thumbnails.phtml"}} {{block type="core/template" template="catalog/category/sidebar-fix.phtml"}}

I just want to alphabetize it.

  • How are you pulling the collection in your template .phtml files? – Goku Sep 7 '16 at 23:30
  • @Goku I am unsure I have been working on Magento for 2 days. Where would I look for this? – Tyler Jensen Sep 8 '16 at 0:10
1

For that you need to create on block file in your custom module,for example here I create one block file and in that file, you set custom category collection.

class Namespace_Module_Model_Getcategory extends Mage_Core_Model_Abstract
{
    public function getCategory($page,$limit)
    {
        $categories = Mage::getModel('catalog/category')
        ->getCollection()
        ->addAttributeToSelect('*')
        ->addAttributeToFilter('is_active', array('in' => array(1)))
        ->addAttributeToFilter('parent_id', array('neq' => array(1)))
        ->addIsActiveFilter()
        ->addAttributeToSort('name','ASC');


    return $categories;

}

}

now call phtml with this block name like,

{{block type="module/blockname" template="catalog/category/cat-thumbnails.phtml"}}

and get the custom collection in your phtml.

  • I am brand new to Magento. Do you know of a tutorial that takes a step back for this? How do I create a block file in the custom module? – Tyler Jensen Sep 8 '16 at 19:56
  • Hi, Please refer this link for how to create custom module of Block then after simple call this block. magento.stackexchange.com/questions/56396/… – Dhrumin Sep 12 '16 at 8:46

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.