Ejemplo n.º 1
0
 /**
  * @param ShoppingList $shoppingList
  */
 protected function saveToStorage(ShoppingList $shoppingList)
 {
     /** @var ProductDataStorage $storage */
     $storage = $this->get('orob2b_product.service.product_data_storage');
     $data = [ProductDataStorage::ENTITY_DATA_KEY => ['accountUser' => $shoppingList->getAccountUser()->getId(), 'account' => $shoppingList->getAccount()->getId()]];
     foreach ($shoppingList->getLineItems() as $lineItem) {
         $data[ProductDataStorage::ENTITY_ITEMS_DATA_KEY][] = [ProductDataStorage::PRODUCT_SKU_KEY => $lineItem->getProduct()->getSku(), ProductDataStorage::PRODUCT_QUANTITY_KEY => $lineItem->getQuantity(), 'comment' => $lineItem->getNotes(), 'productUnit' => $lineItem->getUnit()->getCode(), 'productUnitCode' => $lineItem->getUnit()->getCode()];
     }
     $storage->set($data);
 }