1

I am trying to change my order item custom options after order placed but it overwrite exitsting data and set only value that i did set previously. https://www.screencast.com/t/Y99dQ1D4 My code.

foreach ($orderIds as $key => $value) {
       $orderModel = Mage::getModel('sales/order')->load($value);
       $orderItem = $orderModel->getAllItems();
       foreach ($orderItem as $item) {
        if($item->getId()==17447){
           $option = $item->getProductOptions();
          $info = $intoByRequest['info_buyRequest']['additional_options']['item_shippinggroup'];
          $info = 'group1';
          $item->setProductOptions(serialize($info))
       }
    }

can anyone please guide me how i would change one array element and save the item.

2
  • Did you check with save in your code like $item->setProductOptions(serialize($info))->save(); Jan 31, 2017 at 12:55
  • yes dear i did but it save only set value :(
    – MageLerner
    Jan 31, 2017 at 13:05

1 Answer 1

2

Try below code:

foreach ($orderIds as $key => $value) {
   $orderModel = Mage::getModel('sales/order')->load($value);
   $orderItem = $orderModel->getAllItems();
   foreach ($orderItem as $item) {
        if($item->getId()==17447){
          $option = $item->getProductOptions();
          $option['info_buyRequest']['additional_options']['item_shippinggroup'] = 'group1';
          $item->setProductOptions($option)->save();
        }
    }
}
5

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.