Got Magento Error – Call To Undefined Method Mage_Catalog_Model_Resource_Category_Flat_Collection::getAllIdsSql()

I got following error in error.log. How to fix it? Call to undefined method Mage_Catalog_Model_Resource_Category_Flat_Collection::getAllIdsSql() in app/code/core/Mage/Catalog/Model/Resource/Category/Tree.php

It is a Magento bug.

When flat tables was disabled, Mage::getModel(‘catalog/category’)->getCollection() will return a Mage_Catalog_Model_Resource_Category_Collection object, which extends from Mage_Eav_Model_Entity_Collection_Abstract which has the getAllIdsSql() method.

However, if flat tables are enabled the collection will be a Mage_Catalog_Model_Resource_Category_Flat_Collection which does not inherit the getAllIdsSql() method, resulting in the error you’re seeing.

To fix this issue, just find out the following file

app/code/core/Mage/Catalog/Model/Resource/Category/Tree.php

and find the line

    protected function _getInactiveItemIds($collection, $storeId){
        $filter = $collection->getAllIdsSql();

          .....
     

change to

    protected function _getInactiveItemIds($collection, $storeId){
        //$filter = $collection->getAllIdsSql();
        $filter = $collection->getAllIds();


    .....
0 0 votes
Article Rating
Subscribe
Notify of
guest
0 Comments
Inline Feedbacks
View all comments