示例#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);
     }
 }
 /**
  * Returns the highest price group discount for the provided product.
  *
  * The price groups are stored in the provided context object.
  * If the product has no configured price group or the price group has no discount defined for the
  * current customer group, the function returns null.
  *
  * @param Struct\ListProduct $product
  * @param Struct\ProductContextInterface $context
  * @param $quantity
  * @return null|Struct\Product\PriceDiscount
  */
 private function getHighestQuantityDiscount(Struct\ListProduct $product, Struct\ProductContextInterface $context, $quantity)
 {
     $priceGroups = $context->getPriceGroups();
     if (empty($priceGroups)) {
         return null;
     }
     $id = $product->getPriceGroup()->getId();
     if (!isset($priceGroups[$id])) {
         return null;
     }
     $priceGroup = $priceGroups[$id];
     /**@var $highest Struct\Product\PriceDiscount*/
     $highest = null;
     foreach ($priceGroup->getDiscounts() as $discount) {
         if ($discount->getQuantity() > $quantity) {
             continue;
         }
         if (!$highest) {
             $highest = $discount;
             continue;
         }
         if ($highest->getPercent() < $discount->getPercent()) {
             $highest = $discount;
         }
     }
     return $highest;
 }
示例#3
0
 /**
  * @param Struct\ListProduct $product
  * @param array $data
  */
 private function assignPriceGroupData(Struct\ListProduct $product, array $data)
 {
     if (!empty($data['__priceGroup_id'])) {
         $product->setPriceGroup(new Struct\Product\PriceGroup());
         $product->getPriceGroup()->setId((int) $data['__priceGroup_id']);
         $product->getPriceGroup()->setName($data['__priceGroup_description']);
     }
 }