示例#1
0
 private function getConfiguratorProduct($number, ShopContextInterface $context)
 {
     $product = $this->helper->getSimpleProduct($number, array_shift($context->getTaxRules()), $context->getCurrentCustomerGroup());
     $configurator = $this->helper->getConfigurator($context->getCurrentCustomerGroup(), $number, array('farbe' => array('rot', 'blau', 'grün', 'schwarz', 'weiß')));
     $product = array_merge($product, $configurator);
     $product['categories'] = [['id' => $context->getShop()->getCategory()->getId()]];
     foreach ($product['variants'] as $index => &$variant) {
         $offset = ($index + 1) * -10;
         $variant['prices'] = $this->helper->getGraduatedPrices($context->getCurrentCustomerGroup()->getKey(), $offset);
     }
     return $product;
 }
示例#2
0
 /**
  * @param Struct\Category[] $categories
  * @param Struct\ShopContextInterface $context
  * @return Struct\Category[] $categories Indexed by the category id
  */
 private function filterValidCategories($categories, Struct\ShopContextInterface $context)
 {
     $customerGroup = $context->getCurrentCustomerGroup();
     return array_filter($categories, function (Struct\Category $category) use($customerGroup) {
         return !in_array($customerGroup->getId(), $category->getBlockedCustomerGroupIds());
     });
 }
 /**
  * @param int[] $categoryIds
  * @param ShopContextInterface $context
  * @return Criteria
  */
 public function createBaseCriteria($categoryIds, ShopContextInterface $context)
 {
     $criteria = new Criteria();
     $criteria->addBaseCondition(new CategoryCondition($categoryIds));
     if ($this->config->get('hideNoInstock')) {
         $criteria->addBaseCondition(new IsAvailableCondition());
     }
     $criteria->addBaseCondition(new CustomerGroupCondition([$context->getCurrentCustomerGroup()->getId()]));
     return $criteria;
 }
示例#4
0
 /**
  * @inheritdoc
  */
 public function getSelection(Struct\ShopContextInterface $context)
 {
     $fallback = $context->getFallbackCustomerGroup();
     $current = $context->getCurrentCustomerGroup();
     $currency = $context->getCurrency();
     $priceField = 'defaultPrice.price';
     if ($fallback->getId() != $current->getId()) {
         $priceField = 'IFNULL(customerPrice.price, defaultPrice.price)';
     }
     $discount = $current->useDiscount() ? $current->getPercentageDiscount() : 0;
     $considerMinPurchase = $this->config->get('calculateCheapestPriceWithMinPurchase');
     //rounded to filter this value correctly
     // => 2,99999999 displayed as 3,- € but won't be displayed with a filter on price >= 3,- €
     return 'ROUND(' . $priceField . ($considerMinPurchase ? ' * availableVariant.minpurchase' : '') . ' * ((100 - IFNULL(priceGroup.discount, 0)) / 100)' . ($current->displayGrossPrices() ? " * ((tax.tax + 100) / 100)" : '') . ($discount ? " * " . (100 - (double) $discount) / 100 : '') . ($currency->getFactor() ? " * " . $currency->getFactor() : '') . ', 2)';
 }
示例#5
0
 /**
  * @inheritdoc
  */
 public function getList($products, Struct\ShopContextInterface $context)
 {
     $group = $context->getCurrentCustomerGroup();
     $rules = $this->cheapestPriceGateway->getList($products, $context, $group);
     $prices = $this->buildPrices($products, $rules, $group);
     //check if one of the products have no assigned price within the prices variable.
     $fallbackProducts = array_filter($products, function (Struct\BaseProduct $product) use($prices) {
         return !array_key_exists($product->getNumber(), $prices);
     });
     if (empty($fallbackProducts)) {
         return $prices;
     }
     //if some product has no price, we have to load the fallback customer group prices for the fallbackProducts.
     $fallbackPrices = $this->cheapestPriceGateway->getList($fallbackProducts, $context, $context->getFallbackCustomerGroup());
     $fallbackPrices = $this->buildPrices($fallbackProducts, $fallbackPrices, $context->getFallbackCustomerGroup());
     $prices = $prices + $fallbackPrices;
     return $prices;
 }
示例#6
0
 /**
  * @param ShopContextInterface $context
  * @return string
  */
 public function getPriceField(ShopContextInterface $context)
 {
     $key = $context->getCurrentCustomerGroup()->getKey();
     $currency = $context->getCurrency()->getId();
     return 'calculatedPrices.' . $key . '_' . $currency . '.calculatedPrice';
 }
 /**
  * @param Criteria $criteria
  * @param ShopContextInterface $context
  */
 private function addCustomerGroupCondition(Criteria $criteria, ShopContextInterface $context)
 {
     $condition = new CustomerGroupCondition([$context->getCurrentCustomerGroup()->getId()]);
     $criteria->addBaseCondition($condition);
 }
 /**
  * @param Struct\ListProduct $product
  * @param Struct\ShopContextInterface $context
  * @param $limit
  * @return Search
  */
 protected function getSearch($product, Struct\ShopContextInterface $context, $limit)
 {
     $search = new Search();
     $search->setSize($limit);
     $search->addQuery($this->getSimilarQuery($product));
     $search->addFilter($this->getProductNumberFilter($product));
     $search->addFilter($this->getCategoryFilter($context->getShop()->getCategory()));
     $search->addFilter($this->getCustomerGroupFilter($context->getCurrentCustomerGroup()));
     return $search;
 }
示例#9
0
 /**
  * @param ShopContextInterface $shopContext
  * @param Tax[]                $taxRules
  * @param PriceGroup[]         $priceGroups
  * @return ProductContext
  */
 public static function createFromContexts(ShopContextInterface $shopContext, $taxRules, $priceGroups)
 {
     return new self($shopContext->getBaseUrl(), $shopContext->getShop(), $shopContext->getCurrency(), $shopContext->getCurrentCustomerGroup(), $shopContext->getFallbackCustomerGroup(), $taxRules, $priceGroups);
 }
示例#10
0
 /**
  * @param Struct\ShopContextInterface $context
  * @param Struct\Country\Area|null $area
  * @param Struct\Country|null $country
  * @param Struct\Country\State|null $state
  * @return Struct\Tax[]
  */
 protected function createTaxRulesStruct(Struct\ShopContextInterface $context, Struct\Country\Area $area = null, Struct\Country $country = null, Struct\Country\State $state = null)
 {
     $rules = $this->taxGateway->getRules($context->getCurrentCustomerGroup(), $area, $country, $state);
     return $rules;
 }
示例#11
0
 /**
  * @param array $numbers
  * @param Struct\ShopContextInterface $context
  * @return \Doctrine\DBAL\Query\QueryBuilder
  */
 protected function getQuery(array $numbers, Struct\ShopContextInterface $context)
 {
     $esdQuery = $this->getEsdQuery();
     $customerGroupQuery = $this->getCustomerGroupQuery();
     $availableVariantQuery = $this->getHasAvailableVariantQuery();
     $fallbackPriceQuery = $this->getPriceCountQuery(':fallback');
     $query = $this->connection->createQueryBuilder();
     $query->select($this->fieldHelper->getArticleFields())->addSelect($this->fieldHelper->getTopSellerFields())->addSelect($this->fieldHelper->getVariantFields())->addSelect($this->fieldHelper->getUnitFields())->addSelect($this->fieldHelper->getTaxFields())->addSelect($this->fieldHelper->getPriceGroupFields())->addSelect($this->fieldHelper->getManufacturerFields())->addSelect($this->fieldHelper->getEsdFields())->addSelect('(' . $esdQuery->getSQL() . ') as __product_has_esd')->addSelect('(' . $customerGroupQuery->getSQL() . ') as __product_blocked_customer_groups')->addSelect('(' . $availableVariantQuery->getSQL() . ') as __product_has_available_variants')->addSelect('(' . $fallbackPriceQuery->getSQL() . ') as __product_fallback_price_count');
     $query->setParameter(':fallback', $context->getFallbackCustomerGroup()->getKey());
     if ($context->getCurrentCustomerGroup()->getId() !== $context->getFallbackCustomerGroup()->getId()) {
         $customerPriceQuery = $this->getPriceCountQuery(':current');
         $query->addSelect('(' . $customerPriceQuery->getSQL() . ') as __product_custom_price_count');
         $query->setParameter(':current', $context->getCurrentCustomerGroup()->getKey());
     }
     $query->from('s_articles_details', 'variant')->innerJoin('variant', 's_articles', 'product', 'product.id = variant.articleID')->innerJoin('product', 's_core_tax', 'tax', 'tax.id = product.taxID')->leftJoin('variant', 's_core_units', 'unit', 'unit.id = variant.unitID')->leftJoin('product', 's_articles_supplier', 'manufacturer', 'manufacturer.id = product.supplierID')->leftJoin('product', 's_core_pricegroups', 'priceGroup', 'priceGroup.id = product.pricegroupID')->leftJoin('variant', 's_articles_attributes', 'productAttribute', 'productAttribute.articledetailsID = variant.id')->leftJoin('product', 's_articles_supplier_attributes', 'manufacturerAttribute', 'manufacturerAttribute.supplierID = product.supplierID')->leftJoin('product', 's_articles_top_seller_ro', 'topSeller', 'topSeller.article_id = product.id')->leftJoin('variant', 's_articles_esd', 'esd', 'esd.articledetailsID = variant.id')->leftJoin('esd', 's_articles_esd_attributes', 'esdAttribute', 'esdAttribute.esdID = esd.id')->where('variant.ordernumber IN (:numbers)')->andWhere('variant.active = 1')->andWhere('product.active = 1')->setParameter(':numbers', $numbers, Connection::PARAM_STR_ARRAY);
     $this->fieldHelper->addProductTranslation($query, $context);
     $this->fieldHelper->addVariantTranslation($query, $context);
     $this->fieldHelper->addManufacturerTranslation($query, $context);
     $this->fieldHelper->addUnitTranslation($query, $context);
     return $query;
 }