开发者

How do I detect if a category has Include in Navigation Menu set to NO?

How do I detect if a category has Include in Navigation 开发者_JAVA百科Menu set to NO?


include_in_menu is an attribute so you can use,

if (!$category->getIncludeInMenu()) ...


This worked for me

 $category->load();
//$category->getIncludeInMenu() returns 1 if set to yes, returns 0 if set to no
if(!$category->getIncludeInMenu())
...


Instead of loading entire object (performance issue) there is a better way of checking if category has include_in_menu attribute:

    $Category = Mage::getModel('catalog/category')
                        ->getCollection()
                        ->addFieldToFilter('parent_id', $rootCategory)
                        ->addAttributeToFilter('is_active', 1)
                        ->addAttributeToSelect(array('id', 'name', 'url','include_in_menu'))
                        ->setOrder('position','ASC');

This way you will load only attributes which are required to build navigation.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜