我有一些調用主類別的子類別的代碼,我需要能夠更改網站前端的子類別的排序順序。更改magento中子類別的排序順序
我已經嘗試添加屬性來排序標記,但這不是做任何事情。任何人都可以幫助我指出正確的方向來實現這一目標。許多感謝:
->addAttributeToSort(’position’, ‘asc’)
這是沒有任何影響的順序。我使用的代碼如下:
<?php
//get the current category
$_cat = new Mage_Catalog_Block_Navigation();
$currentCat = $_cat->getCurrentCategory();
//get the children of the current category
$subCats = Mage::getModel('catalog/category')->load($currentCat->getId())->getChildren();
//get sub category ids
$subCatIds = explode(',',$subCats);
?>
<?php if (count($subCatIds) > 1): ?>
<?php foreach($subCatIds as $subCatId): ?>
<?php $subCat = Mage::getModel('catalog/category')->load($subCatId); ?>
<?php if($subCat->getIsActive()): ?>
謝謝你,但我在哪裏添加這個代碼來調用它?很多感謝 – 2012-03-19 06:59:04
好,取決於你想要的地方:) – Sergey 2012-03-19 08:20:14
它可以被添加到我已經張貼在上面的代碼或我需要看看重寫它,以使這種合適? – 2012-03-19 11:14:17