如果你真的想使用設計的根 - >服裝 - >商店由*你可以做到這一點與單控和修改
config.xml中 - 這顯然是一個沉重簡化文件,你需要提供助手重寫爲文件。
<?xml version="1.0"?>
<config>
<helpers>
<catalog>
<rewrite>
<category>Namespace_Module_Helper_Catalog_Category</category>
</rewrite>
</catalog>
</helpers>
</config>
Category.php 這是假設你要使用的第一個孩子類別網站根目錄類別。在你的情況下,這將是「服裝」。此修改考慮到使用平面或非平面類別表。還有其他的選擇ID的選項,其中一個是以類別列表作爲源的系統配置,從而允許您直接選擇導航根類別。
這個文件的癥結在於讓Parent ID成爲你想要導航的「根類別」。同樣,對於您的情況,家長ID將被設置爲「服裝」類別的ID。
class Namespace_Module_Helper_Catalog_Category extends Mage_Catalog_Helper_Category {
public function getStoreCategories($sorted=false, $asCollection=false, $toLoad=true)
{
$parent = Mage::app()->getStore()->getRootCategoryId();
$cacheKey = sprintf('%d-%d-%d-%d', $parent, $sorted, $asCollection, $toLoad);
if (isset($this->_storeCategories[$cacheKey])) {
return $this->_storeCategories[$cacheKey];
}
/**
* Check if parent node of the store still exists
*/
$category = Mage::getModel('catalog/category');
/* @var $category Mage_Catalog_Model_Category */
if (!$category->checkId($parent)) {
if ($asCollection) {
return new Varien_Data_Collection();
}
return array();
}
/* Change ian on 1/4/13 at 11:16 AM - Description: Here we capture the id of first child for use as the 'root' */
$category->load($parent);
/** @var $collection Mage_Catalog_Model_Resource_Category_Collection */
$collection = $category->getChildrenCategories();
if (is_array($collection)) {
$category = array_shift($collection); //get the first category in the array. Unknown key.
$parent = $category->getId();
} else {
$parent = $collection->getFirstItem()->getId();
}
$recursionLevel = max(0, (int) Mage::app()->getStore()->getConfig('catalog/navigation/max_depth'));
$storeCategories = $category->getCategories($parent, $recursionLevel, $sorted, $asCollection, $toLoad);
$this->_storeCategories[$cacheKey] = $storeCategories;
return $storeCategories;
}
}
來源
2013-01-04 18:30:48
Ian
是APPARELS在該級別唯一的類別? – Ian