Esempio n. 1
0
 /**
  * @param ListProduct $listProduct
  * @param ListProduct $product
  */
 public function assignProductData(ListProduct $listProduct, ListProduct $product)
 {
     $product->setShippingFree($listProduct->isShippingFree());
     $product->setMainVariantId($listProduct->getMainVariantId());
     $product->setAllowsNotification($listProduct->allowsNotification());
     $product->setHighlight($listProduct->highlight());
     $product->setUnit($listProduct->getUnit());
     $product->setTax($listProduct->getTax());
     $product->setPrices($listProduct->getPrices());
     $product->setManufacturer($listProduct->getManufacturer());
     $product->setCover($listProduct->getCover());
     $product->setCheapestPrice($listProduct->getCheapestPrice());
     $product->setName($listProduct->getName());
     $product->setAdditional($listProduct->getAdditional());
     $product->setCloseouts($listProduct->isCloseouts());
     $product->setEan($listProduct->getEan());
     $product->setHeight($listProduct->getHeight());
     $product->setKeywords($listProduct->getKeywords());
     $product->setLength($listProduct->getLength());
     $product->setLongDescription($listProduct->getLongDescription());
     $product->setMinStock($listProduct->getMinStock());
     $product->setReleaseDate($listProduct->getReleaseDate());
     $product->setShippingTime($listProduct->getShippingTime());
     $product->setShortDescription($listProduct->getShortDescription());
     $product->setStock($listProduct->getStock());
     $product->setWeight($listProduct->getWeight());
     $product->setWidth($listProduct->getWidth());
     $product->setPriceGroup($listProduct->getPriceGroup());
     $product->setCreatedAt($listProduct->getCreatedAt());
     $product->setPriceRules($listProduct->getPriceRules());
     $product->setCheapestPriceRule($listProduct->getCheapestPriceRule());
     $product->setManufacturerNumber($listProduct->getManufacturerNumber());
     $product->setMetaTitle($listProduct->getMetaTitle());
     $product->setTemplate($listProduct->getTemplate());
     $product->setHasConfigurator($listProduct->hasConfigurator());
     $product->setSales($listProduct->getSales());
     $product->setHasEsd($listProduct->hasEsd());
     $product->setEsd($listProduct->getEsd());
     $product->setIsPriceGroupActive($listProduct->isPriceGroupActive());
     $product->setBlockedCustomerGroupIds($listProduct->getBlockedCustomerGroupIds());
     $product->setVoteAverage($listProduct->getVoteAverage());
     $product->setHasAvailableVariant($listProduct->hasAvailableVariant());
     $product->setCheapestUnitPrice($listProduct->getCheapestUnitPrice());
     $product->setFallbackPriceCount($listProduct->getFallbackPriceCount());
     $product->setCustomerPriceCount($listProduct->getCustomerPriceCount());
     foreach ($listProduct->getAttributes() as $name => $attribute) {
         $product->addAttribute($name, $attribute);
     }
     foreach ($listProduct->getStates() as $state) {
         $product->addState($state);
     }
 }
 /**
  * Internal function which converts only the data of a list product.
  * Associated data won't converted.
  *
  * @param StoreFrontBundle\Struct\ListProduct $product
  * @return array
  */
 private function getListProductData(StoreFrontBundle\Struct\ListProduct $product)
 {
     $createDate = null;
     if ($product->getCreatedAt()) {
         $createDate = $product->getCreatedAt()->format('Y-m-d');
     }
     $data = array('articleID' => $product->getId(), 'articleDetailsID' => $product->getVariantId(), 'ordernumber' => $product->getNumber(), 'highlight' => $product->highlight(), 'description' => $product->getShortDescription(), 'description_long' => $product->getLongDescription(), 'esd' => $product->hasEsd(), 'articleName' => $product->getName(), 'taxID' => $product->getTax()->getId(), 'tax' => $product->getTax()->getTax(), 'instock' => $product->getStock(), 'isAvailable' => $product->isAvailable(), 'weight' => $product->getWeight(), 'shippingtime' => $product->getShippingTime(), 'pricegroupActive' => false, 'pricegroupID' => null, 'length' => $product->getLength(), 'height' => $product->getHeight(), 'width' => $product->getWidth(), 'laststock' => $product->isCloseouts(), 'additionaltext' => $product->getAdditional(), 'datum' => $createDate, 'sales' => $product->getSales(), 'filtergroupID' => null, 'priceStartingFrom' => null, 'pseudopricePercent' => null, 'sVariantArticle' => null, 'sConfigurator' => $product->hasConfigurator(), 'metaTitle' => $product->getMetaTitle(), 'shippingfree' => $product->isShippingFree(), 'suppliernumber' => $product->getManufacturerNumber(), 'notification' => $product->allowsNotification(), 'ean' => $product->getEan(), 'keywords' => $product->getKeywords(), 'sReleasedate' => $this->dateToString($product->getReleaseDate()), 'template' => $product->getTemplate());
     if ($product->hasAttribute('core')) {
         $attributes = $product->getAttribute('core')->toArray();
         unset($attributes['id'], $attributes['articleID'], $attributes['articledetailsID']);
         $data = array_merge($data, $attributes);
     }
     $data['attributes'] = $product->getAttributes();
     if ($product->getManufacturer()) {
         $manufacturer = array('supplierName' => $product->getManufacturer()->getName(), 'supplierImg' => $product->getManufacturer()->getCoverFile(), 'supplierID' => $product->getManufacturer()->getId(), 'supplierDescription' => $product->getManufacturer()->getDescription());
         if (!empty($manufacturer['supplierImg'])) {
             $manufacturer['supplierImg'] = $this->mediaService->getUrl($manufacturer['supplierImg']);
         }
         $data = array_merge($data, $manufacturer);
         $data['supplier_attributes'] = $product->getManufacturer()->getAttributes();
     }
     if ($product->hasAttribute('marketing')) {
         /**@var $marketing StoreFrontBundle\Struct\Product\MarketingAttribute */
         $marketing = $product->getAttribute('marketing');
         $data['newArticle'] = $marketing->isNew();
         $data['sUpcoming'] = $marketing->comingSoon();
         $data['topseller'] = $marketing->isTopSeller();
     }
     $today = new \DateTime();
     if ($product->getReleaseDate() && $product->getReleaseDate() > $today) {
         $data['sReleasedate'] = $product->getReleaseDate()->format('Y-m-d');
     }
     return $data;
 }