Reputation: 13
I am wondering how to change the sort order of sub categories listed on the left sidebar of the page of a parent category (eg: the 'Brands' page has left menu items listing the subcategory names in order of ID and not alphabetically by name). I've tried tinkering with the leftnav.phtml file, but cannot seem to figure out how to pull the names into the array to sort them.
Upvotes: 0
Views: 947
Reputation: 1963
This post is old but answers never. hope it will help someone
Override the below file
app/code/core/Mage/Catalog/Model/Layer/Filter/Abstract.php
at
app/code/local/Mage/Catalog/Model/Layer/Filter/Abstract.php
replace
return $this->_items;
with
asort($this->_items);
return $this->_items;
That's it you will get all left navigation items by alphabet order.
Upvotes: 0
Reputation: 39
This is what I use to alphabetize all parent and child categories...hope it helps
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:=@i+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:=@j+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;
Upvotes: 1