0

I got a question where I want to sort the product listings in category pages sorted by manufacturer by default then I would like it to be alphabetically by name.

Example:

Products list (Sorted by Manufacturer) - this is working

Product G     Product Z     Product A   Product R   Product Ab

Where it should be:

Products list (Sorted by Manufacturer) - this is working

Product A     Product Ab     Product G   Product R   Product Z

Same issue but it's not working for me: https://stackoverflow.com/questions/4167173/magento-sort-by-position-and-name

Regards

2 Answers 2

1

When you go to Category page in Magento administration (Catalog/Manage Categories), you’ll see “Display Settings” tab. From there you can modify “Available Product Listing Sort By” and “Default Product Listing Sort By” values.

Let’s modify “Default Product Listing Sort By”. If you deselect “Use Config Settings” and if you select “Manufacturer” for “Default Product Listing Sort By”, on frontend for specified category you’ll see that all items are now sorted by Name ascending (growing upward).

You can select multiple attributes for this sorting. (Manufacturer and Name)

1
  • 1
    Thanks @Irfan but you cant select multiple attributes in "Default Product Listing Sort By" here so if I choose Manufacturer on the frontend the products were not in ascending order or alphabetically order.
    – nhinzky
    Dec 6, 2016 at 9:53
1

Now I got it working and here is how did I manage to fixed it.

I edited list.phtml and replace the line of code that stores the product collection which is:

$_productCollection=$this->getLoadedProductCollection();

And replace it with this line:

<?php

  $cat_id = Mage::registry('current_category')->getId();
  $category = Mage::getModel('catalog/category')->load($cat_id);
  $_productCollection = $category->getProductCollection()
    ->addAttributeToSelect('*')
    ->addStoreFilter(Mage::app()->getStore()->getId())
    ->addAttributeToSort('manufacturer', 'ASC')
    ->addAttributeToSort('name', 'ASC');

?>

Cheers!

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.