I load quote by quote id and adding items to quote_item
table.
I need to know how to add product options i.e. info_buyrequest
options to quote item from controller only. I tried below code.
$quote = Mage::getModel('sales/quote')->load('1125');
$quote = $quote->setUpdatedAt(now());
$product = Mage::getModel('catalog/product')->load($product_id);
$quoteItem = Mage::getModel('sales/quote_item')->setProduct($product)->setQty(1);
$quote->addItem($quoteItem);
$additionalOptions = array(
'label' => 'shop_data',
'value' => 1
);
/* Here the modification is needed */
foreach($quote->getAllVisibleItems() as $row){
if($row->getProductId() == 95 ){
$row->getProduct()->addCustomOption('info_buyRequest', serialize($additionalOptions));
}
}
try{
$quote->save();
}catch(Exception $e){
echo $e->getMessage();
}
Best Answer
please try belo