Skip to content

Commit

Permalink
Mage_Catalog_Model_Product_Attribute_Backend_Groupprice_Abstract: avo…
Browse files Browse the repository at this point in the history
…id loading all websites when using only the current one (#2351)
  • Loading branch information
fballiano committed Aug 2, 2022
1 parent a252af8 commit 4721a48
Showing 1 changed file with 12 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -55,14 +55,23 @@ abstract protected function _getDuplicateErrorMessage();
/**
* Retrieve websites currency rates and base currency codes
*
* @param int|null $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')
Expand Down Expand Up @@ -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) {
Expand Down

0 comments on commit 4721a48

Please sign in to comment.