문제

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?

다른 팁

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();
           }
    }
라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 magento.stackexchange
scroll top