Is it possible to add custom values to select options e.g. in configurable products?

I need to add the sku of the option to the option, so that it will become

<option id="354" price="10" sku="my_sku">Option name</option>

I figured out that the Block Class of the Select is Mage_Catalog_Block_Product_View_Options_Type_Select, so I overrided the class but I don't know which code I have to edit.

I found the definition of addOption in Mage_Catalog_Model_Product_Option but there is no big logic.

Edit: This is not the right definition. The right definition is in the Block class Mage_Core_Block_Html_Select

 * Add an option to HTML select
 * @param string $value  HTML value
 * @param string $label  HTML label
 * @param array  $params HTML attributes
 * @return Mage_Core_Block_Html_Select
public function addOption($value, $label, $params=array())
    $this->_options[] = array('value' => $value, 'label' => $label, 'params' => $params);
    return $this;

Cache is deactivated.

1 Answer 1


I figured it out. The definition of addOption is in Mage_Core_Block_Html_Select, there are 3 parameters.

 * @param string $value  HTML value
 * @param string $label  HTML label
 * @param array  $params HTML attributes

You can pass new attributes by passing them as array via the 3rd parameter $params.

    $_value->getTitle() . ' ' . $priceStr,
        'price' => $this->helper('core')->currencyByStore($_value->getPrice(true), $store, false)
        , 'sku' => $_value->getSku()

Your Answer

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

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