When you have a large scale Magento store with thousands of products in every top-level category, dozens or even hundreds of offered filters for a single attribute in your layered navigation, certain necessities become mandatory – like selective attribute sorting.
Even though Magento does offer sorting functionality for attribute values, in these situations that just might not be enough as you can not sort selectively for a specific category.
For instance, let’s say a customer is in a “First Category” and there he sees a brands attribute in layered navigation, filterable by these values:
- A & A Specialties (1)
- Abella (2)
- Abex Friction Products (1)
- Absco Ltd (1)
- AC-Delco (166)
- Accel (1)
- Acco Ind (1)
Then customer goes to a “Second Category” and again there is this brands attribute with exactly the same options offered to filter by.
Now, why wouldn’t you offer your customers filterable options in the order you find the most suitable, maybe boost sales by emphasizing a certain brand, or just sorted to be a bit more relevant to current category?
Here’s how you can do it with the least coding required.
First download the Inchoo_SAS extension and copy it’s content to your Magento’s root folder. This extension will handle all the back-end logic for you.
(Remember to log out and then log back into admin after extension is installed.)
Now, for the fun part.
Let’s go to Magento admin -> CMS -> Static Blocks
In order to manipulate the attribute values for a particular category follow these steps:
1. Create a static block:
Static block name example: First Category – Layer Brands
Static block identifier example: first_category_layer_brands
2. Place the attribute values in the Content area separated by new line [enter]:
It must be plain text and no html tags, so hide the WYSIWYG Content Editor.
3. In admin go to the relevant category – in our example it’s First Category
a) click on the “Custom Design” tab
b) Enter the following custom layout update:
<!-- --> <block type="cms/block" name="layer_brands"> <action method="setBlockId"> <block_id>first_category_layer_brands</block_id> </action> </block> <!-- -->
Place this code outside / after any <reference name=”something”></reference> node.
The name=”layer_brands” serves as an example, you’ll use layer_actual_attribute_code
instead, like layer_manufacturer. The only thing that always stays the same is the layer_ prefix.
Inside <block_id></block_id> you’ll enter the identifier of the relevant static block (see No. 1)
4. Click on “Save Category”
5. Go to Cache management and hit the “Flush Magento Cash” in order to see the changes.
And that’s it
Whenever you need to alter the order of attribute values for a certain category, just go to the relevant static block and reorder values the way you like it.
Another big gain you get with this extension is that if you sort products by Position in this particular category, you’ll notice that Magento will sort products the way attribute values are sorted as well.
Finally, if you don’t like the required prefix layer, you may change it if you go to
Magento admin -> System -> Configuration -> Inchoo Extensions -> Layer Navigation – sorting
I hope this will prove to be helpful to you.