2013-12-12 68 views
0

我在想如何更改父類別頁面左側欄中列出的子類別的排序順序(例如:「品牌」頁面左側菜單項列出子類別名稱按ID順序排列,不按名稱按字母順序排列)。我試着修改leftnav.phtml文件,但似乎無法弄清楚如何將名稱拉入數組進行排序。Magento 1.7左側導航類別按字母順序排列順序

回答

1

這是我使用的按字母順序排列的所有父母和孩子類別...希望它有助於

SET @i=0; 
SET @j=0; 
DROP TABLE IF EXISTS AAA_NEW_POSITION; 
CREATE TABLE AAA_NEW_POSITION     
SELECT 
e.entity_id AS 'entity_id', 
vn.value AS 'name', 
e.position AS 'old_position', @i:[email protected]+1 AS 'new_position' 
FROM 
catalog_category_entity e 
LEFT JOIN catalog_category_entity_varchar vn 
ON e.entity_id = vn.entity_id AND 
vn.attribute_id = (SELECT attribute_id FROM 
eav_attribute WHERE entity_type_id = (SELECT entity_type_id FROM catalog_category_entity LIMIT 1) AND attribute_code='name') 
ORDER BY vn.value ASC; 

ALTER TABLE AAA_NEW_POSITION ORDER BY NAME; 
UPDATE AAA_NEW_POSITION SET new_position= @j:[email protected]+1 ORDER BY NAME; 

UPDATE catalog_category_entity e 
LEFT JOIN AAA_NEW_POSITION np 
ON e.entity_id = np.entity_id 
SET e.position = np.new_position; 

DROP TABLE IF EXISTS AAA_NEW_POSITION; 
0

這個職位是舊的,但答案永遠。希望這會幫助別人

覆蓋下面的文件

app/code/core/Mage/Catalog/Model/Layer/Filter/Abstract.php 

app/code/local/Mage/Catalog/Model/Layer/Filter/Abstract.php 

更換

return $this->_items; 

asort($this->_items); 
return $this->_items; 

就是這樣,您將按字母順序獲取所有左側導航項目。