diff --git a/Helper/Entity/Product/PriceManager/ProductWithChildren.php b/Helper/Entity/Product/PriceManager/ProductWithChildren.php index 2c1f52ac1..e8c884661 100755 --- a/Helper/Entity/Product/PriceManager/ProductWithChildren.php +++ b/Helper/Entity/Product/PriceManager/ProductWithChildren.php @@ -52,7 +52,7 @@ protected function getMinMaxPrices(Product $product, $withTax, $subProducts, $cu /** @var Product $subProduct */ foreach ($subProducts as $subProduct) { $specialPrice = $this->getSpecialPrice($subProduct, $currencyCode, $withTax, $subProducts); - $tierPrice = $this->getTierPrice($subProduct, $currencyCode, $withTax); + $tierPrice = $this->getTierPrice($subProduct, $currencyCode, $withTax, $subProducts); if (!empty($tierPrice[0]) && $specialPrice[0] > $tierPrice[0]){ $minPrice = $tierPrice[0]; } else { @@ -231,7 +231,7 @@ protected function getGroupPriceList($product, $subproducts, $min, $currencyCode $subProduct->setData('customer_group_id', $groupId); $subProduct->setData('website_id', $subProduct->getStore()->getWebsiteId()); $specialPrice = $this->getSpecialPrice($subProduct, $currencyCode, $withTax, []); - $tierPrice = $this->getTierPrice($subProduct, $currencyCode, $withTax); + $tierPrice = $this->getTierPrice($subProduct, $currencyCode, $withTax, []); $price = $this->getTaxPrice($product, $subProduct->getPriceModel()->getFinalPrice(1, $subProduct), $withTax); if (!empty($tierPrice[$groupId]) && $specialPrice[$groupId] > $tierPrice[$groupId]) { diff --git a/Helper/Entity/Product/PriceManager/ProductWithoutChildren.php b/Helper/Entity/Product/PriceManager/ProductWithoutChildren.php index 5868da92c..ec322f1e4 100755 --- a/Helper/Entity/Product/PriceManager/ProductWithoutChildren.php +++ b/Helper/Entity/Product/PriceManager/ProductWithoutChildren.php @@ -2,6 +2,7 @@ namespace Algolia\AlgoliaSearch\Helper\Entity\Product\PriceManager; +use Algolia\AlgoliaSearch\Exception\DiagnosticsException; use Algolia\AlgoliaSearch\Helper\ConfigHelper; use Algolia\AlgoliaSearch\Logger\DiagnosticsLogger; use DateTime; @@ -153,7 +154,7 @@ public function addPriceData($customData, Product $product, $subProducts): array $this->customData[$field][$currencyCode]['default'] = $this->priceCurrency->round($price); $this->customData[$field][$currencyCode]['default_formated'] = $this->formatPrice($price, $currencyCode); $specialPrice = $this->getSpecialPrice($product, $currencyCode, $withTax, $subProducts); - $tierPrice = $this->getTierPrice($product, $currencyCode, $withTax); + $tierPrice = $this->getTierPrice($product, $currencyCode, $withTax, $subProducts); if ($this->areCustomersGroupsEnabled) { $this->addCustomerGroupsPrices($product, $currencyCode, $withTax, $field); } @@ -266,7 +267,7 @@ protected function getSpecialPrice(Product $product, $currencyCode, $withTax, $s $specialPrice[$groupId] = min($specialPrices[$groupId]); } if ($specialPrice[$groupId]) { - if ($currencyCode !== $this->baseCurrencyCode) { + if ($currencyCode !== $this->baseCurrencyCode && (!$subProducts || count($subProducts) === 0)) { $specialPrice[$groupId] = $this->priceCurrency->round($this->convertPrice($specialPrice[$groupId], $currencyCode)); } @@ -279,10 +280,12 @@ protected function getSpecialPrice(Product $product, $currencyCode, $withTax, $s /** * @param Product $product * @param $currencyCode - * @param $withTax + * @param $withTaxm + * @param int|array $subProducts * @return array + * @throws DiagnosticsException */ - protected function getTierPrice(Product $product, $currencyCode, $withTax) + protected function getTierPrice(Product $product, $currencyCode, $withTax, $subProducts = []) { $this->logger->startProfiling(__METHOD__); $tierPrice = []; @@ -326,11 +329,11 @@ protected function getTierPrice(Product $product, $currencyCode, $withTax) min($currentTierPrice, $tierPrices[$groupId]); } - if ($currencyCode !== $this->baseCurrencyCode) { + if ($currencyCode !== $this->baseCurrencyCode && (!$subProducts || count($subProducts) === 0)) { $currentTierPrice = $this->priceCurrency->round($this->convertPrice($currentTierPrice, $currencyCode)); } - $tierPrice[$groupId] = $this->getTaxPrice($product, $currentTierPrice, $withTax); + $tierPrice[$groupId] = $this->getTaxPrice($product, $currentTierPrice, $withTax, $subProducts); } $this->logger->stopProfiling(__METHOD__);