コード例 #1
0
 /**
  * Asserts product
  *
  * @param Product|null $product
  * @param array        $data
  */
 protected function assertProductApiResult(Product $product = null, array $data = [])
 {
     $this->assertArrayHasKey('id', $data);
     $this->assertEquals($product->getId(), $data['id']);
     $this->assertArrayHasKey('name', $data);
     $this->assertEquals($product->getName(), $data['name']);
     $this->assertArrayHasKey('sku', $data);
     $this->assertEquals($product->getSku(), $data['sku']);
     $this->assertArrayHasKey('price', $data);
     $this->assertEquals($product->getPrice(), $data['price']);
     $this->assertArrayHasKey('createdAt', $data);
     $this->assertArrayHasKey('updatedAt', $data);
     $this->assertArrayHasKey('status', $data);
     $this->assertArrayHasKey('organization', $data);
     $this->assertArrayHasKey('prices', $data);
     $this->assertArrayHasKey('channels', $data);
     $this->assertArrayHasKey('inventory', $data);
 }
コード例 #2
0
ファイル: LoadProductData.php プロジェクト: umpirsky/marello
 /**
  * create new products and inventory items
  * @param array $data
  * @return Product $product
  */
 private function createProduct(array $data)
 {
     $product = new Product();
     $product->setSku($data['sku']);
     $product->setPrice($data['price']);
     $product->setName($data['name']);
     $inventoryItem = new InventoryItem();
     $inventoryItem->setProduct($product);
     $inventoryItem->setWarehouse($this->defaultWarehouse);
     $inventoryItem->setQuantity($data['stock_level']);
     $product->getInventoryItems()->add($inventoryItem);
     $status = $this->getReference('product_status_' . $data['status']);
     $product->setStatus($status);
     $channels = explode(';', $data['channel']);
     foreach ($channels as $channelId) {
         $channel = $this->getReference('marello_sales_channel_' . (int) $channelId);
         $product->addChannel($channel);
     }
     $this->manager->persist($product);
     return $product;
 }
コード例 #3
0
ファイル: OrderItem.php プロジェクト: umpirsky/marello
 /**
  * @ORM\PrePersist
  */
 public function prePersist()
 {
     $this->productName = $this->product->getName();
     $this->productSku = $this->product->getSku();
 }
コード例 #4
0
 /**
  * @Config\Route("/widget/info/{id}", name="marello_inventory_widget_info", requirements={"id"="\d+"})
  * @Config\Template
  *
  * @param Product $product
  * @return array
  */
 public function infoAction(Product $product)
 {
     $item = $product->getInventoryItems()->first();
     return ['item' => $item];
 }
コード例 #5
0
 /**
  * Remove prices from the collection on product
  * @param Product $product
  */
 protected function clearPricingCollection($product)
 {
     if (count($product->getPrices()) > 0) {
         foreach ($product->getPrices() as $_price) {
             $product->removePrice($_price);
         }
     }
 }