I have setup a custom option for my product in Magento as dropdown i.e.
Size : Small, Medium, Large
On product page I show additional information for each op
Just to add a small fix to Vinai's great solution. The solution breaks the logic of getting a quote item by product.
The function getItemByProduct in Mage_Sales_Model_Quote_Item calls the function representProduct which compares between the quote and product options. If both objects have identical list of options it returns the quote object otherwise false.
Because both objects have different options now that we added our custom option the function will return false.
One way to solve this issue is to rewrite Mage_Sales_Model_Quote_Item class and add your custom option code to the local variable $_notRepresentOptions in the constructor.
class Custom_Options_Model_Sales_Quote_Item extends Mage_Sales_Model_Quote_Item {
/**
* Initialize resource model
*
*/
protected function _construct()
{
$this->_notRepresentOptions = array_merge($this->_notRepresentOptions, array('additional_options'));
parent::_construct();
}
}