3

I have changed the default sort by to reference one of our attributes so the best sellers get listed first, It works perfectly via this code

public function setListOrders()
{
    $category = Mage::getSingleton('catalog/layer')
        ->getCurrentCategory();
    /* @var $category Mage_Catalog_Model_Category */
    $availableOrders = $category->getAvailableSortByOptions();
    unset($availableOrders['position']);
    $availableOrders = array_merge(array(
        'best_sellers' => $this->__('Best Seller'),
        'relevance' => $this->__('Relevance')
    ), $availableOrders);

    $this->getListBlock()
        ->setAvailableOrders($availableOrders)
        ->setDefaultDirection('desc')
        ->setSortBy('best_sellers');

    return $this;
}

As you can see i have set the direction to descending, However when ever i change the sort by attribute (ie name, relevance or price) it changes the order to ascending, how can i change it so it always stays on descending unless the customer changes it?

Cheers

1

You need to override Mage_Catalog_Block_Product_List_Toolbar and change variable $_direction value to desc

  • I have already done that but it still changes when i change what i sort it by – Adam Allen Dec 11 '14 at 13:24

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.