Adding Values For Multiselect Attributes in Magento

Add this to your XML;

<global>
 <sales>
            <quote>
                <item>
                    <product_attributes>
                        <location />
                    </product_attributes>
                </item>
            </quote>
        </sales>
	</global>
  • This makes the product attributes accessible to the Mage_Sales_Model_Quote_Config class’ getProductAttributes() method. This reads in the sales/quote/item/product_attributes node.

  • This is called by the _assignProducts method of the “`Mage_Sales_Model_Resource_Quote_Item_Collection’s _assignProducts() method, where it adds all of the attributes to the product collection of the quote item collection.

Copy the attributes to the quote item

Unlike copying from quote items to order items, there isn’t an XML method to do this – it has to be accomplished through an observer. Add the following to the config (with the observer / method substituted):

<frontend>
    <events>
         <sales_quote_item_set_product>
             <observers>
                 <observer_name>
                        <class>model/observer</class>
                        <method>addAttributesToQuoteItem</method>
                 </observer_name>
             </observers>
         </sales_quote_item_set_product>
    </events>
</frontend>

Then create the following method for the observer above:

    public function addAttributesToQuoteItem($observer){
        $quoteItem = $observer->getQuoteItem();
        $product = $observer->getProduct();
        $quoteItem->setLocation($product->getLocation());
    }