From 6731ddb4105bec9263a62a81c5fa5bba9a2ea271 Mon Sep 17 00:00:00 2001 From: Richard Brown Date: Tue, 26 Mar 2019 22:36:30 +0000 Subject: [PATCH] Fix pricing when using with&without tax with customer groups When using prices with and without taxes, there are multiple entries in the $fields array. When looping through the groups $product->getPriceModel()->getFinalPrice() is called for each group. This sets the data['final_price'] on the product model each time it is called. This means that on the second loop of the field array, when the call to set $special_price uses $product->getFinalPrice() it is getting value set for the final group in the previous iteration. This patch changes the assignment of special_price to recalculate the final_price everytime, it also moves it out of the currency loop because the result doesn't depend on the currency. (cherry picked from commit 77dad50c58c81b6e95772230bad89e05b60c9b2e) --- .../Algoliasearch/Helper/Entity/Producthelper.php | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/app/code/community/Algolia/Algoliasearch/Helper/Entity/Producthelper.php b/app/code/community/Algolia/Algoliasearch/Helper/Entity/Producthelper.php index 222755e3..44de8b86 100644 --- a/app/code/community/Algolia/Algoliasearch/Helper/Entity/Producthelper.php +++ b/app/code/community/Algolia/Algoliasearch/Helper/Entity/Producthelper.php @@ -528,21 +528,21 @@ protected function handlePrice(Mage_Catalog_Model_Product &$product, $sub_produc foreach ($fields as $field => $with_tax) { $customData[$field] = array(); + $field_price = (double) $taxHelper->getPrice($product, $product->getPrice(), $with_tax, null, null, null, $product->getStore(), null); + $field_special_price = (double) $taxHelper->getPrice($product, $product->getPriceModel()->getFinalPrice(1, $product), $with_tax, null, null, null, $product->getStore(), null); foreach ($currencies as $currency_code) { $customData[$field][$currency_code] = array(); - $price = (double) $taxHelper->getPrice($product, $product->getPrice(), $with_tax, null, null, null, $product->getStore(), null); - $price = $directoryHelper->currencyConvert($price, $baseCurrencyCode, $currency_code); + $price = $directoryHelper->currencyConvert($field_price, $baseCurrencyCode, $currency_code); $price += $weeeTaxAmount; + $special_price = $directoryHelper->currencyConvert($field_special_price, $baseCurrencyCode, $currency_code); + $special_price += $weeeTaxAmount; + $customData[$field][$currency_code]['default'] = $price; $customData[$field][$currency_code]['default_formated'] = $this->formatPrice($price, false, $currency_code); - $special_price = (double) $taxHelper->getPrice($product, $product->getFinalPrice(), $with_tax, null, null, null, $product->getStore(), null); - $special_price = $directoryHelper->currencyConvert($special_price, $baseCurrencyCode, $currency_code); - $special_price += $weeeTaxAmount; - if ($customer_groups_enabled) { // If fetch special price for groups