3
votes

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

1
Please do not cross-post on different Stack Exchange sites. And if you do, at least have the decency to not copy the 0 votes thing on the question at magento.SEWooble
sorry I did not know they were two connected sitesStefano

1 Answers

4
votes

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;
}