Filtering a Category by Page Layout in Magento

Share

Recently I needed to output categories on the homepage in magento, all these categories had a custom page layout so I thought I may as well filter by that rather than creating a custom category attribute. Here is I how I did that.

public function getCategories() {
$categories = Mage::getModel('catalog/category')->getCollection()
->addAttributeToSelect('*')
->addAttributeToFilter('is_active',array('eq'=>true))
->addAttributeToFilter('page_layout', 'custom_layout')
->load();
return $categories;
}

Comments are closed.