2

I have enabled RSS in System > Configuration > RSS Feeds > Catalog > Top Level Category-->Enabled.

However it lists static pages as well as product categories when I go to www.mysite.com/rss

Is there way I can unlist category from RSS feeds list somehow?

1 Answer 1

1

Welcome to Magento.SE!

The easiest approach here is to filter it to include only the categories you want. So create a new Magento plugin and rewrite the class Mage_Rss_Block_List in the file /app/code/core/Mage/Rss/Block/List.php.

Override the CategoriesRssFeed method with the following:

public function CategoriesRssFeed()
{
    $path = self::XML_PATH_RSS_METHODS.'/catalog/category';
    if((bool)Mage::getStoreConfig($path)){
        $category = Mage::getModel('catalog/category');

        /* @var $collection Mage_Catalog_Model_Resource_Eav_Mysql4_Category_Collection */
        $treeModel = $category->getTreeModel()->loadNode(Mage::app()->getStore()->getRootCategoryId());
        $nodes = $treeModel->loadChildren()->getChildren();

        $nodeIds = array();
        foreach ($nodes as $node) {
            $nodeIds[] = $node->getId();
        }

        //filter the ids I don't want (e.g. category with id 23):
        $nodeIds = array_diff($nodeIds,array(23));

        $collection = $category->getCollection()
            ->addAttributeToSelect('url_key')
            ->addAttributeToSelect('name')
            ->addAttributeToSelect('is_anchor')
            ->addAttributeToFilter('is_active',1)
            ->addIdFilter($nodeIds)
            ->addAttributeToSort('name')
            ->load();

        foreach ($collection as $category) {
            $this->addRssFeed('rss/catalog/category', $category->getName(),array('cid'=>$category->getId()));
        }
    }
}

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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