|
6 | 6 | namespace Magento\Catalog\Model\ResourceModel\Product;
|
7 | 7 |
|
8 | 8 | use Magento\Catalog\Api\Data\ProductInterface;
|
| 9 | +use Magento\Store\Model\ScopeInterface; |
9 | 10 |
|
10 | 11 | /**
|
11 | 12 | * Catalog product custom option resource model
|
@@ -154,24 +155,26 @@ protected function _saveValuePrices(\Magento\Framework\Model\AbstractModel $obje
|
154 | 155 |
|
155 | 156 | $scope = (int)$this->_config->getValue(
|
156 | 157 | \Magento\Store\Model\Store::XML_PATH_PRICE_SCOPE,
|
157 |
| - \Magento\Store\Model\ScopeInterface::SCOPE_STORE |
| 158 | + ScopeInterface::SCOPE_STORE |
158 | 159 | );
|
159 | 160 |
|
160 | 161 | if ($object->getStoreId() != '0' && $scope == \Magento\Store\Model\Store::PRICE_SCOPE_WEBSITE) {
|
161 |
| - $baseCurrency = $this->_config->getValue( |
| 162 | + $website = $this->_storeManager->getStore($object->getStoreId())->getWebsite(); |
| 163 | + |
| 164 | + $websiteBaseCurrency = $this->_config->getValue( |
162 | 165 | \Magento\Directory\Model\Currency::XML_PATH_CURRENCY_BASE,
|
163 |
| - 'default' |
| 166 | + ScopeInterface::SCOPE_WEBSITE, |
| 167 | + $website |
164 | 168 | );
|
165 | 169 |
|
166 |
| - $storeIds = $this->_storeManager->getStore($object->getStoreId())->getWebsite()->getStoreIds(); |
| 170 | + $storeIds = $website->getStoreIds(); |
167 | 171 | if (is_array($storeIds)) {
|
168 | 172 | foreach ($storeIds as $storeId) {
|
169 | 173 | if ($object->getPriceType() == 'fixed') {
|
170 | 174 | $storeCurrency = $this->_storeManager->getStore($storeId)->getBaseCurrencyCode();
|
171 |
| - $rate = $this->_currencyFactory->create()->load($baseCurrency)->getRate($storeCurrency); |
172 |
| - if (!$rate) { |
173 |
| - $rate = 1; |
174 |
| - } |
| 175 | + $rate = $this->_currencyFactory->create()->load($websiteBaseCurrency) |
| 176 | + ->getRate($storeCurrency); |
| 177 | + $rate ?: $rate = 1; |
175 | 178 | $newPrice = $object->getPrice() * $rate;
|
176 | 179 | } else {
|
177 | 180 | $newPrice = $object->getPrice();
|
@@ -582,6 +585,8 @@ public function getPriceTypes()
|
582 | 585 | }
|
583 | 586 |
|
584 | 587 | /**
|
| 588 | + * Returns metadata poll. |
| 589 | + * |
585 | 590 | * @return \Magento\Framework\EntityManager\MetadataPool
|
586 | 591 | */
|
587 | 592 | private function getMetadataPool()
|
|
0 commit comments