Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Mage_Catalog_Model_Product_Attribute_Backend_Groupprice_Abstract: avoid loading all websites when using only the current one #2351

Merged
merged 2 commits into from
Aug 2, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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