Skip to content

Commit 4721a48

Browse files
authored
Mage_Catalog_Model_Product_Attribute_Backend_Groupprice_Abstract: avoid loading all websites when using only the current one (#2351)
1 parent a252af8 commit 4721a48

File tree

1 file changed

+12
-3
lines changed
  • app/code/core/Mage/Catalog/Model/Product/Attribute/Backend/Groupprice

1 file changed

+12
-3
lines changed

app/code/core/Mage/Catalog/Model/Product/Attribute/Backend/Groupprice/Abstract.php

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -55,14 +55,23 @@ abstract protected function _getDuplicateErrorMessage();
5555
/**
5656
* Retrieve websites currency rates and base currency codes
5757
*
58+
* @param int|null $websiteId
5859
* @return array
5960
*/
60-
protected function _getWebsiteCurrencyRates()
61+
protected function _getWebsiteCurrencyRates($websiteId = null)
6162
{
6263
if (is_null($this->_rates)) {
6364
$this->_rates = array();
6465
$baseCurrency = Mage::app()->getBaseCurrencyCode();
65-
foreach (Mage::app()->getWebsites() as $website) {
66+
67+
if (is_numeric($websiteId)) {
68+
$website = Mage::app()->getWebsite($websiteId);
69+
$websites = [$website];
70+
} else {
71+
$websites = Mage::app()->getWebsites();
72+
}
73+
74+
foreach ($websites as $website) {
6675
/* @var Mage_Core_Model_Website $website */
6776
if ($website->getBaseCurrencyCode() != $baseCurrency) {
6877
$rate = Mage::getModel('directory/currency')
@@ -189,7 +198,7 @@ public function validate($object)
189198
*/
190199
public function preparePriceData(array $priceData, $productTypeId, $websiteId)
191200
{
192-
$rates = $this->_getWebsiteCurrencyRates();
201+
$rates = $this->_getWebsiteCurrencyRates($websiteId);
193202
$data = array();
194203
$price = Mage::getSingleton('catalog/product_type')->priceFactory($productTypeId);
195204
foreach ($priceData as $v) {

0 commit comments

Comments
 (0)