Issue:
Fatal error: Call to undefined method Mage_Catalog_Model_Resource_Category_Flat_Collection::groupByAttribute() in app/code/local/Sm/BasicProducts/Block/List.php
(The same: sm tablisting, sm slider, sm slideshow)
Solution:
Open app/code/local/Sm/BasicProducts/Block/List.php file, find this fundtion:
private function _addCategoryFilter(& $collection, $category_ids){ $category_collection = Mage::getModel('catalog/category')->getCollection(); $category_collection->addAttributeToSelect('*'); $category_collection->addIsActiveFilter(); if (count($category_ids)>0){ $category_collection->addIdFilter($category_ids); } $category_collection->groupByAttribute('entity_id'); $category_products = array(); foreach ($category_collection as $category){ $cid = $category->getId(); if (!array_key_exists( $cid, $category_products)){ $category_products[$cid] = $category->getProductCollection()->getAllIds(); //Mage::log("ID: " . $cid ); //Mage::log("collection->count(): " . count($category_products[$cid]) ); } } $product_ids = array(); if (count($category_products)){ foreach ($category_products as $cp) { $product_ids = array_merge($product_ids, $cp); } } //Mage::log("merged_count: " . count($product_ids)); $collection->addIdFilter($product_ids); }
and change to:
private function _addCategoryFilter(& $collection, $category_ids){ $category_collection = Mage::getModel('catalog/category')->getCollection(); $category_collection->addAttributeToSelect('*'); $category_collection->addIsActiveFilter(); $product_ids = array(); if (count($category_ids)>0){ $category_collection->addIdFilter($category_ids); } if (!Mage::helper('catalog/category_flat')->isEnabled()) { $category_collection->groupByAttribute('entity_id'); } $category_products = array(); foreach ($category_collection as $category){ $cid = $category->getId(); if (!array_key_exists( $cid, $category_products)){ $category_products[$cid] = $category->getProductCollection()->getAllIds(); //Mage::log("ID: " . $cid ); //Mage::log("collection->count(): " . count($category_products[$cid]) ); } } }
Thanks!