/** * @param string $locale * @param array $filter * * @return array */ public function findAllByLocale($locale, $filter = []) { if (empty($filter)) { $items = $this->itemRepository->findAllByLocale($locale); } else { $items = $this->itemRepository->findByLocaleAndFilter($locale, $filter); } array_walk($items, function (&$item) use($locale) { $item = $this->itemFactory->createApiEntity($item, $locale); }); return $items; }
/** * Creates new item for test purpose. * * @return ItemInterface */ public function createNewTestItem() { $item = $this->itemFactory->createEntity(); $item->setName('Product1'); $item->setNumber('123'); $item->setQuantity(2); $item->setQuantityUnit('Pcs'); $item->setUseProductsPrice(true); $item->setTax(20); $item->setPrice($this->productPrice->getPrice()); $item->setDiscount(10); $item->setDescription('This is a description'); $item->setWeight(15.8); $item->setWidth(5); $item->setHeight(6); $item->setLength(7); $item->setCreated(new DateTime()); $item->setChanged(new DateTime()); $item->setProduct($this->product); $item->setSupplier($this->account); $item->setSupplierName($this->account->getName()); return $item; }
/** * @VirtualProperty * @SerializedName("items") * @Groups({"Default","cart"}) * * @return \Doctrine\Common\Collections\Collection */ public function getItems() { if (!$this->itemsChanged && $this->cacheItems && count($this->cacheItems) === count($this->entity->getItems())) { return $this->cacheItems; } else { $this->itemsChanged = false; $this->cacheItems = array(); foreach ($this->entity->getItems() as $item) { $this->cacheItems[] = $this->itemFactory->createApiEntity($item, $this->locale, $this->getCurrencyCode()); } } return $this->cacheItems; }