From 79906f4d2cc424716529d1df20f40aae5df645d6 Mon Sep 17 00:00:00 2001 From: Maxime Leclercq Date: Thu, 8 Sep 2022 13:54:48 +0200 Subject: [PATCH 1/2] fix: get the weee tax amount for all types include it --- .../Algolia/Algoliasearch/Helper/Entity/Producthelper.php | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/app/code/community/Algolia/Algoliasearch/Helper/Entity/Producthelper.php b/app/code/community/Algolia/Algoliasearch/Helper/Entity/Producthelper.php index 02b0c260..ae718710 100644 --- a/app/code/community/Algolia/Algoliasearch/Helper/Entity/Producthelper.php +++ b/app/code/community/Algolia/Algoliasearch/Helper/Entity/Producthelper.php @@ -505,8 +505,11 @@ protected function handlePrice(Mage_Catalog_Model_Product &$product, $sub_produc $directoryCurrency = Mage::getModel('directory/currency'); $currencies = $directoryCurrency->getConfigAllowCurrencies(); - if (Mage::helper('core')->isModuleEnabled('Mage_Weee') && - Mage::helper('weee')->getPriceDisplayType($product->getStore()) == 0) { + // Get the weee tax amount if the weee module is enabled and for all types that include it + if ( + Mage::helper('core')->isModuleEnabled('Mage_Weee') && + Mage::helper('weee')->typeOfDisplay($product, [0, 1, 4]) + ) { $weeeTaxAmount = Mage::helper('weee')->getAmountForDisplay($product); } else { $weeeTaxAmount = 0; From 2ef008e6f7d7d4689e3437b859e4a51e19914bf3 Mon Sep 17 00:00:00 2001 From: Maxime Leclercq Date: Mon, 20 Mar 2023 11:19:00 +0100 Subject: [PATCH 2/2] fix: get the weee tax amount including taxes --- .../Helper/Entity/Producthelper.php | 29 ++++++++++++------- 1 file changed, 18 insertions(+), 11 deletions(-) diff --git a/app/code/community/Algolia/Algoliasearch/Helper/Entity/Producthelper.php b/app/code/community/Algolia/Algoliasearch/Helper/Entity/Producthelper.php index ae718710..5ec1598c 100644 --- a/app/code/community/Algolia/Algoliasearch/Helper/Entity/Producthelper.php +++ b/app/code/community/Algolia/Algoliasearch/Helper/Entity/Producthelper.php @@ -505,16 +505,6 @@ protected function handlePrice(Mage_Catalog_Model_Product &$product, $sub_produc $directoryCurrency = Mage::getModel('directory/currency'); $currencies = $directoryCurrency->getConfigAllowCurrencies(); - // Get the weee tax amount if the weee module is enabled and for all types that include it - if ( - Mage::helper('core')->isModuleEnabled('Mage_Weee') && - Mage::helper('weee')->typeOfDisplay($product, [0, 1, 4]) - ) { - $weeeTaxAmount = Mage::helper('weee')->getAmountForDisplay($product); - } else { - $weeeTaxAmount = 0; - } - $baseCurrencyCode = $store->getBaseCurrencyCode(); $groups = array(); @@ -536,6 +526,8 @@ protected function handlePrice(Mage_Catalog_Model_Product &$product, $sub_produc $customData[$field][$currency_code] = array(); $price = (double) $taxHelper->getPrice($product, $product->getPrice(), $with_tax, null, null, null, $product->getStore(), null); + + $weeeTaxAmount = $this->getWeeeAmount($product, $with_tax); $price = $directoryHelper->currencyConvert($price, $baseCurrencyCode, $currency_code); $price += $weeeTaxAmount; @@ -1115,7 +1107,7 @@ private function getCompositeTypes() return $this->compositeTypes; } - + public function getAllProductIds($storeId) { $products = Mage::getModel('catalog/product')->getCollection(); @@ -1316,4 +1308,19 @@ private function clearFacetsQueryRules($index) } } } + + private function getWeeeAmount($product, $withTax) + { + // Get the weee tax amount if the weee module is enabled and for all types that include it + if ( + !Mage::helper('core')->isModuleEnabled('Mage_Weee') || + !Mage::helper('weee')->typeOfDisplay($product, [0, 1, 4]) + ) { + return 0; + } + + return $withTax + ? Mage::helper('weee')->getAmountForDisplayInclTaxes($product) + : Mage::helper('weee')->getAmountForDisplay($product); + } }