From 009e55fea39712711cb763c32cb46476b9d67aa0 Mon Sep 17 00:00:00 2001 From: AISSAOUI Date: Fri, 20 Sep 2024 17:05:34 +0200 Subject: [PATCH] Including FPT on indexed product final price! --- .../Product/PriceManager/ProductWithChildren.php | 4 ++-- .../Product/PriceManager/ProductWithoutChildren.php | 11 +++++++++-- 2 files changed, 11 insertions(+), 4 deletions(-) diff --git a/Helper/Entity/Product/PriceManager/ProductWithChildren.php b/Helper/Entity/Product/PriceManager/ProductWithChildren.php index 719d8e1da..9f2461dcf 100755 --- a/Helper/Entity/Product/PriceManager/ProductWithChildren.php +++ b/Helper/Entity/Product/PriceManager/ProductWithChildren.php @@ -55,8 +55,8 @@ protected function getMinMaxPrices(Product $product, $withTax, $subProducts, $cu } else { $minPrice = $specialPrice[0]; } - $price = $minPrice ?? $this->getTaxPrice($product, $subProduct->getFinalPrice(), $withTax); - $basePrice = $this->getTaxPrice($product, $subProduct->getPrice(), $withTax); + $price = $minPrice ?? $this->getTaxPrice($product, $subProduct->getFinalPrice(), $withTax) + $this->weeeTax->getWeeeAmount($subProduct); + $basePrice = $this->getTaxPrice($product, $subProduct->getPrice(), $withTax) + $this->weeeTax->getWeeeAmount($subProduct); $min = min($min, $price); $original = min($original, $basePrice); $max = max($max, $price); diff --git a/Helper/Entity/Product/PriceManager/ProductWithoutChildren.php b/Helper/Entity/Product/PriceManager/ProductWithoutChildren.php index b05c178e3..90ef22467 100755 --- a/Helper/Entity/Product/PriceManager/ProductWithoutChildren.php +++ b/Helper/Entity/Product/PriceManager/ProductWithoutChildren.php @@ -15,6 +15,7 @@ use Magento\Customer\Api\GroupExcludedWebsiteRepositoryInterface; use Magento\Framework\Pricing\PriceCurrencyInterface; use Magento\Tax\Helper\Data as TaxHelper; +use Magento\Weee\Model\Tax as WeeeTax; use Magento\Tax\Model\Config as TaxConfig; use Magento\Catalog\Api\ScopedProductTierPriceManagementInterface; @@ -40,6 +41,10 @@ abstract class ProductWithoutChildren * @var TaxHelper */ protected $taxHelper; + /** + * @var WeeeTax + */ + protected $weeeTax; /** * @var Rule */ @@ -89,6 +94,7 @@ public function __construct( PriceCurrencyInterface $priceCurrency, CatalogHelper $catalogHelper, TaxHelper $taxHelper, + WeeeTax $weeeTax, Rule $rule, ProductFactory $productloader, ScopedProductTierPriceManagementInterface $productTierPrice, @@ -100,6 +106,7 @@ public function __construct( $this->priceCurrency = $priceCurrency; $this->catalogHelper = $catalogHelper; $this->taxHelper = $taxHelper; + $this->weeeTax = $weeeTax; $this->rule = $rule; $this->productloader = $productloader; $this->productTierPrice = $productTierPrice; @@ -143,7 +150,7 @@ public function addPriceData($customData, Product $product, $subProducts): array $product->setPriceCalculation(true); foreach ($currencies as $currencyCode) { $this->customData[$field][$currencyCode] = []; - $price = $product->getPrice(); + $price = $product->getPrice() + $this->weeeTax->getWeeeAmount($product); if ($currencyCode !== $this->baseCurrencyCode) { $price = $this->convertPrice($price, $currencyCode); } @@ -254,7 +261,7 @@ protected function getSpecialPrice(Product $product, $currencyCode, $withTax, $s $specialPrices[$groupId] = []; $specialPrices[$groupId][] = $this->getRulePrice($groupId, $product, $subProducts); // The price with applied catalog rules - $specialPrices[$groupId][] = $product->getFinalPrice(); // The product's special price + $specialPrices[$groupId][] = $product->getFinalPrice() + $this->weeeTax->getWeeeAmount($product); // The product's special price $specialPrices[$groupId] = array_filter($specialPrices[$groupId], function ($price) { return $price > 0; });