0

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?

2
  • Are you adding custom comment box to each product in Cart?
    – Yeshu
    May 5, 2016 at 14:36
  • Yes. In the quote every item has a field for comment May 5, 2016 at 14:46

2 Answers 2

0

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();
           }
    }

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.