예제 #1
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)';
 }
예제 #2
0
 /**
  * @param ShopContextInterface $context
  * @return string
  */
 public function getPriceField(ShopContextInterface $context)
 {
     $key = $context->getCurrentCustomerGroup()->getKey();
     $currency = $context->getCurrency()->getId();
     return 'calculatedPrices.' . $key . '_' . $currency . '.calculatedPrice';
 }
예제 #3
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);
 }