Reputation: 25968
I am unable to sort product by price in product list page.
Sort by name works fine there.
Any idea guys?
I googled and tried some solution but they didn't solve my problem.
I tried: System->Cache Management->Layered Navigation Indices->Refresh now
Also tried this link: http://www.miromedia.co.uk/blog/300/fixing-the-magento-price-sort-issue.htm
Magento version: 1.3.2.4
Upvotes: 2
Views: 9167
Reputation: 199
There seems to be some kind of bug in this version of Magento, the product catalog index price not updating on product save. So what you can do is by pass the price condition like described below.
Update addAttributeToSort
function of Mage_Catalog_Model_Resource_Eav_Mysql4_Product_Collection
class.
Comment out the following code:-
// if ($attribute == 'price' && $storeId != 0) {
// $websiteId = Mage::app()->getStore()->getWebsiteId();
// $customerGroup = Mage::getSingleton('customer/session')->getCustomerGroupId();
//
// if ($this->isEnabledFlat()) {
// $priceColumn = 'e.display_price_group_' . $customerGroup;
// $this->getSelect()->order("{$priceColumn} {$dir}");
// }
// else {
// $priceAttributeId = $this->getAttribute('price')->getId();
//
// $entityCondition = '_price_order_table.entity_id = e.entity_id';
// $storeCondition = $this->getConnection()->quoteInto(
// '_price_order_table.website_id = ?',
// $websiteId
// );
// $groupCondition = $this->getConnection()->quoteInto(
// '_price_order_table.customer_group_id = ?',
// $customerGroup
// );
// $attributeCondition = $this->getConnection()->quoteInto(
// '_price_order_table.attribute_id = ?',
// $priceAttributeId
// );
//
// $this->getSelect()->joinLeft(
// array('_price_order_table'=>$this->getTable('catalogindex/price')),
// "{$entityCondition} AND {$storeCondition} AND {$groupCondition} AND {$attributeCondition}",
// array()
// );
// $this->getSelect()->order('_price_order_table.value ' . $dir);
//
// /**
// * Distinct we are using for remove duplicates of products which have
// * several rows in price index (like grouped products)
// */
// $this->getSelect()->distinct(true);
// }
//
// return $this;
// }
You can do this in Magento standard way other than commenting out the core code. Hope this helps.
Upvotes: 3
Reputation: 59
You need to configure the price attribute correctly in Magento admin.
Go to attribute management, find the price attribute and ensure that you tick the box on "sortable in frontend"
that should resolve this for you.
Upvotes: 1