Разработка сайтов

Меняем склад для товаров в отгрузке Битрикс


// меняем склад для товаров в отгрузке.
                $shipmentCollection = $order->getShipmentCollection();
               foreach ($shipmentCollection as $shipment)
               {
                   $shipmentItemCollection = $shipment->getShipmentItemCollection();
                   foreach($shipmentItemCollection as $item)
                   {

                       $storeCollection = $item->getShipmentItemStoreCollection();
                       if ($storeCollection->isEmpty())
                       {
                           $store = $storeCollection->createItem($item->getBasketItem());
                           $store->setFields([
                               'QUANTITY' => $item->getField('QUANTITY'),
                               'STORE_ID' => 3
                           ]);
                       }
                       else
                       {
                           foreach ($storeCollection as $store)
                           {
                               $store->setField('STORE_ID', 3);
                           }
                       }
                   }
                   $shipment->save();
               }
Подписка на блог Подпишись на новые материалы от US STUDIO и вы не пропустите интересные статьи от нашей компании