5

Hello Good Day to All

I have Attribute "Malakas","Mahina","Payat"

On a Product Page it will Show

Malakas
--Choose an Option--
Mahina
--Choose an Option--
Payat
--Choose an Option--

Is this a way to change the Postiton of Super Attribute so the Attribute "Payat" will be first ??

Payat
--Choose an Option--
Malakas
--Choose an Option--
Mahina
--Choose an Option--

I already try the Position and still not working on product view Page only the Left side bar is working for Postion

the Option Drag and Drop while Create product can be use but is there a way to make it default attribute

or is there a ways to change the code on the configurable Product Option so to use Attribute Position ?

Thank

3
  • you can check here magento.stackexchange.com/questions/45396/… this might help you
    – fmsthird
    Apr 16, 2019 at 1:15
  • which specific magento 1.9 version you are using?
    – fmsthird
    Apr 16, 2019 at 1:20
  • @magefm I'm using the latest one 1.9.4.0 it seems the link that you give for me is for the sorting of Attribute( the choose option )
    – roy phil
    Apr 16, 2019 at 1:21

2 Answers 2

3

I check the magento collection.php thank you @magefms

    /**
     * Set order collection by Position
     *
     * @param string $dir
     * @return Mage_Catalog_Model_Resource_Product_Type_Configurable_Attribute_Collection
     */
    public function orderByPosition($dir = self::SORT_ORDER_ASC)
    {
        $this->setOrder('position ',  $dir);
        return $this;
    }

Lucky for me my Attribute created at the same time so i achieve what i want Ijust change

  public function orderByPosition($dir = self::SORT_ORDER_DESC)

thanks

0
2

Try this fix:
Copy the file

app/code/core/Mage/Catalog/Model/Resource/Product/Type/Configurable/Attribute/Collection.php

to local folder

app/code/local/Mage/Catalog/Model/Resource/Product/Type/Configurable/Attribute/Collection.php  

Please add the following code in line 305

$sortOrder = 1;
foreach ($this->_items as $item) {
$productAttribute = $item->getProductAttribute();
if (!($productAttribute instanceof Mage_Eav_Model_Entity_Attribute_Abstract)) {
Continue;
}
$options = $productAttribute->getFrontend()->getSelectOptions();
foreach ($options as $option) {
if (!$option['value']) continue;
                    if (isset($values[$item->getId() . ':' . $option['value']])) {
                            $values[$item->getId() . ':' . $option['value']]['order'] = $sortOrder++;
                    }
            }
}
usort($values, function($a, $b) {
return $a['order'] - $b['order'];
});  

The code given should be placed above the code of Magento shown below:

foreach ($values as $data) {

$this->getItemById($data[‘product_super_attribute_id’])->addPrice($data);

}  

After the above changes, clear the cache and check if it works.

3
  • Hi magefms thank you for your help still the same the position of super attribute "Malakas","Mahina","Payat" still same is there a way the magento use position so if i save Payat - Position 1 and Malakas as postion 2 and Mahina for position 3 so i will show like this
    – roy phil
    Apr 16, 2019 at 1:45
  • you can set it in Catalog > Attributes > Manage Attributes >
    – fmsthird
    Apr 16, 2019 at 1:48
  • hi magefms thank you for your answer but i believe the position is only work at the left side filter not on the Product view page
    – roy phil
    Apr 16, 2019 at 1:50

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

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