Reputation: 41
In my site i have setted a filter for ordering my products by attribute, but the order is alphabetical and i would like the order is by position attribute setted in backend.
example attribute color:
Valuename | Position
green | 1
blue | 2
red | 3
The actual result in frontend is product blue then green then red, i would like the result is green then blue then red
what classes i can modify for resolving this problem?
thanks in advance
Upvotes: 3
Views: 5328
Reputation: 1372
I am thinking that you create the custom option for a product and then set the short_order of the value. If this is right then use this code.
Go to the App/code/core/Mage/Catalog/Model/Product/Option.php
There is a function getProductOptionCollection Line no:- 373 . just comment out the code of ->setOrder('title', 'asc'); and add the " ; " just after the ->setOrder('sort_order', 'asc')
public function getProductOptionCollection(Mage_Catalog_Model_Product $product)
{
$collection = $this->getCollection()
->addFieldToFilter('product_id', $product->getId())
->addTitleToResult($product->getStoreId())
->addPriceToResult($product->getStoreId())
->setOrder('sort_order', 'asc');
//->setOrder('title', 'asc');
if ($this->getAddRequiredFilter()) {
$collection->addRequiredFilter($this->getAddRequiredFilterValue());
}
$collection->addValuesToResult($product->getStoreId());
return $collection;
}
Upvotes: 4