18

This seemed simple but is proving otherwise -- I just want to list all products in my store from high -> low

To do so, I went to:

Configuration -> Catalog -> Product Listing Sort by -> (I Selected) "Price"

Now this sorts every product from low to high for all products - but there doesn't seem to be a way to chose ascending vs descending order.

Is there something in the admin area I'm overlooking or do I have to modify a file to do this?

  • If I understood your explanation correctly, you should just click the price column again to sort the products high to low. – Mr_Green Nov 3 '13 at 4:47
  • You can improve your products sorting by using this script fmeaddons.com/magento/… – user9468 Jul 10 '14 at 6:53
42

You cannot change the default order direction for product lists from configuration.

You can however change the direction from layout XML.

Here are a few examples that you can put in your layout XML file, e.g. local.xml:

<?xml version="1.0"?>
<layout version="0.1.0">
    <!-- Change default direction for simple searches -->
    <catalogsearch_result_index>
        <reference name="search_result_list">
            <action method="setDefaultDirection"><dir>desc</dir></action>
        </reference>
    </catalogsearch_result_index>

    <!-- Change default direction for advanced searches -->
    <catalogsearch_advanced_result>
        <reference name="search_result_list">
            <action method="setDefaultDirection"><dir>desc</dir></action>
        </reference>
    </catalogsearch_advanced_result>

    <!-- Change default direction for a category without layered navigation -->
    <catalog_category_default>
        <reference name="product_list">
            <action method="setDefaultDirection"><dir>desc</dir></action>
        </reference>
    </catalog_category_default>

    <!-- Change default direction for a category with layered navigation -->
    <catalog_category_layered>
        <reference name="product_list">
            <action method="setDefaultDirection"><dir>desc</dir></action>
        </reference>
    </catalog_category_layered>

    <!-- Change default direction for category with ID 3 -->
    <CATEGORY_3>
        <reference name="product_list">
            <action method="setDefaultDirection"><dir>desc</dir></action>                                   
        </reference>
    </CATEGORY_3>
</layout>

Furthermore you can add layout XML as a Custom Design of your category in the backend. This setting will overwrite what you set in the XML file:

Set the default order direction by using Custom Design XML

6

Question is tagged CE 1.7.0.2 but this solution is useful for those on 1.9.1.1 so I'm adding it here.

We had an opposite problem where we needed to show the cheapest products first when sorted by Price. For the OP's first concern, this doesn't apply because in Magento CE 1.9 it already defaults to descending so this is actually not needed. The second concern, for a way to choose ascending vs descending, it can be done through an XML file or the Custom Layout Update. The latter is the preferred solution in most cases and most people would avoid the hassle of FTP'ing to upload an XML file to update settings.

Here's how it looks like in Catalog > Manage Categories > Category > Custom Design > Custom Layout Update:

Shows cheapest products first, NOT most expensive Here's the code:

<reference name="product_list_toolbar">
    <action method="setDefaultDirection"><string>asc</string></action>
    <action method="setDefaultOrder"><string>price</string></action>
</reference>

To choose ascending vs descending, just change asc to desc.

As an option, you can also change price to the sorting that you need. You can remove it so that it will default to asc on any Product Listing Sort by option that is set up as default.

3

The solutions above did not seem to make a difference with CE 1.8, so I had to solve this issue by overriding catalog model functionality in code/local/.../Catalog/Model/Category.php

/**
 * Override category products collection
 * to sort by price descending
 *
 * @return Varien_Data_Collection_Db
 */
public function getProductCollection()
{  
    $collection = parent::getProductCollection()->setOrder('price', 'DESC');
    return $collection;
}

Hope this helps. :-)

  • Hi, Can we change the current sort order via toolbar.phtml file ?? – Jordy S Chemparathy Mar 29 '16 at 11:42
  • In my case one category shows new products first; – Jordy S Chemparathy Mar 29 '16 at 11:43
3

The following xml worked for me in CE 1.8:

<layout>
    <catalog_category_default>
      <reference name="product_list_toolbar">
          <action method="setDefaultDirection"><string>asc</string></action>
          <action method="setDefaultOrder"><string>price</string></action>
      </reference>
    </catalog_category_default>

    <catalog_category_layered>
      <reference name="product_list_toolbar">
        <action method="setDefaultDirection"><string>asc</string></action>
        <action method="setDefaultOrder"><string>price</string></action>
      </reference>
    </catalog_category_layered>

    <catalogsearch_result_index>
      <reference name="search_result_list">
        <action method="setDefaultDirection"><string>asc</string></action>
        <action method="setDefaultOrder"><string>price</string></action>
      </reference>
    </catalogsearch_result_index>
    <catalogsearch_advanced_result>
      <reference name="search_result_list">
        <action method="setDefaultDirection"><string>asc</string></action>
        <action method="setDefaultOrder"><string>price</string></action>
      </reference>
    </catalogsearch_advanced_result>
</layout>

Thought I'd post since both above solutions didn't work for me in Magento 1.8 (Community).

'setDefaultOrder' can take any attribute code I think, and isn't required if you just want to use the default from admin.

Hope it's useful to someone.

1

Go to /app/code/core/Mage/Catalog/Model/ path and add the below code in Product.php

public function getRelatedProductCollection()
    {
$collection = $this->getLinkInstance()->useRelatedLinks()
        ->getProductCollection()
        ->setIsStrongMode();
    $collection->setProduct($this);
    $collection->setOrder('price', 'DESC');
    return $collection;
    }

You can also use this for weight. Just write 'weight' in place of 'price'. For ascending just write 'ASC' in place of 'DESC' .

  • never change core files. – func0der Feb 14 '18 at 22:01

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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