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:
1
|
$category_collection->addPathFilter($regexp);
|
=> change to:
1
2
3
4
5
|
if (Mage::helper('catalog/category_flat')->isEnabled()) {
$category_collection->addPathsFilter();
}else{
$category_collection->addPathFilter($regexp);
}
|
- and find:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
|
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:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
|
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:
1
2
3
|
<?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:
1
2
3
4
5
6
7
|
<?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!