From 70f6ea575347951abe78932b4ce3c7948e25434f Mon Sep 17 00:00:00 2001 From: Fabrizio Balliano Date: Mon, 1 Aug 2022 16:18:20 +0100 Subject: [PATCH 1/2] Getting currency rates for single website --- .../Attribute/Backend/Groupprice/Abstract.php | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/app/code/core/Mage/Catalog/Model/Product/Attribute/Backend/Groupprice/Abstract.php b/app/code/core/Mage/Catalog/Model/Product/Attribute/Backend/Groupprice/Abstract.php index b0e15b97587..c4868fa61e9 100644 --- a/app/code/core/Mage/Catalog/Model/Product/Attribute/Backend/Groupprice/Abstract.php +++ b/app/code/core/Mage/Catalog/Model/Product/Attribute/Backend/Groupprice/Abstract.php @@ -55,14 +55,23 @@ abstract protected function _getDuplicateErrorMessage(); /** * Retrieve websites currency rates and base currency codes * + * @param int $websiteId * @return array */ - protected function _getWebsiteCurrencyRates() + protected function _getWebsiteCurrencyRates($websiteId = null) { if (is_null($this->_rates)) { $this->_rates = array(); $baseCurrency = Mage::app()->getBaseCurrencyCode(); - foreach (Mage::app()->getWebsites() as $website) { + + if (is_numeric($websiteId)) { + $website = Mage::app()->getWebsite($websiteId); + $websites = [$website]; + } else { + $websites = Mage::app()->getWebsites(); + } + + foreach ($websites as $website) { /* @var Mage_Core_Model_Website $website */ if ($website->getBaseCurrencyCode() != $baseCurrency) { $rate = Mage::getModel('directory/currency') @@ -189,7 +198,7 @@ public function validate($object) */ public function preparePriceData(array $priceData, $productTypeId, $websiteId) { - $rates = $this->_getWebsiteCurrencyRates(); + $rates = $this->_getWebsiteCurrencyRates($websiteId); $data = array(); $price = Mage::getSingleton('catalog/product_type')->priceFactory($productTypeId); foreach ($priceData as $v) { From defd83b6423e233237336be1ac1fedf3aa800ec7 Mon Sep 17 00:00:00 2001 From: Fabrizio Balliano Date: Mon, 1 Aug 2022 16:35:23 +0100 Subject: [PATCH 2/2] docblock fix --- .../Model/Product/Attribute/Backend/Groupprice/Abstract.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/code/core/Mage/Catalog/Model/Product/Attribute/Backend/Groupprice/Abstract.php b/app/code/core/Mage/Catalog/Model/Product/Attribute/Backend/Groupprice/Abstract.php index c4868fa61e9..ac70e2a5541 100644 --- a/app/code/core/Mage/Catalog/Model/Product/Attribute/Backend/Groupprice/Abstract.php +++ b/app/code/core/Mage/Catalog/Model/Product/Attribute/Backend/Groupprice/Abstract.php @@ -55,7 +55,7 @@ abstract protected function _getDuplicateErrorMessage(); /** * Retrieve websites currency rates and base currency codes * - * @param int $websiteId + * @param int|null $websiteId * @return array */ protected function _getWebsiteCurrencyRates($websiteId = null)