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!