How to save value of the new column in the “sales_flat_quote_item”?
-
29-09-2020 - |
문제
I created in the installer a new column in "sales_flat_quote_item" named "comment". I set the value and it works but I can't save it in DB.
My piece of code:
$quote_item = Mage::getModel("sales/quote_item")->load(47);
$quote_item->setComment('test'); //field is set correctly.
$quote_item->save(); //but save don't work and my change gone.
Any idea how to save this value?
해결책
I guess this post will help you to solve your issue.
http://magentocoder.jigneshpatel.co.in/magento-add-comment-box-to-each-product-in-cart/
OR
다른 팁
Ok from the link above I made it this way:
$write = Mage::getSingleton('core/resource')->getConnection('core_write');
$query = "UPDATE sales_flat_quote_item SET comment = '" . itemNewValue['comment'] . "' where item_id = ". $itemNewValue['cartItemId'];
$write->query($query);
today i found another solution. I think it's better beacuse we can avoid directly sql statement.
$items = $quote->getAllItems();
foreach ($items as $item) {
if ($item['item_id'] === $itemNewValue['cartItemId']) {
$item->setComment($itemNewValue['comment']);
$item->save();
}
}
제휴하지 않습니다 magento.stackexchange