|
11 | 11 | use Magento\Catalog\Model\Product\Type;
|
12 | 12 | use Magento\Catalog\Model\ProductIdLocatorInterface;
|
13 | 13 | use Magento\Customer\Api\GroupRepositoryInterface;
|
| 14 | +use Magento\Directory\Model\Currency; |
14 | 15 | use Magento\Framework\Api\FilterBuilder;
|
15 | 16 | use Magento\Framework\Api\SearchCriteriaBuilder;
|
16 | 17 | use Magento\Framework\Exception\LocalizedException;
|
@@ -426,7 +427,7 @@ private function checkUnique(
|
426 | 427 | foreach ($prices[$tierPrice->getSku()] as $price) {
|
427 | 428 | if ($price !== $tierPrice) {
|
428 | 429 | $checkWebsiteValue = $isExistingPrice ? $this->compareWebsiteValue($price, $tierPrice)
|
429 |
| - : ($price->getWebsiteId() == $tierPrice->getWebsiteId()); |
| 430 | + : $this->compareWebsiteValueNewPrice($price, $tierPrice); |
430 | 431 | if (strtolower($price->getCustomerGroup()) === strtolower($tierPrice->getCustomerGroup())
|
431 | 432 | && $price->getQuantity() == $tierPrice->getQuantity()
|
432 | 433 | && $checkWebsiteValue
|
@@ -547,6 +548,29 @@ private function compareWebsiteValue(TierPriceInterface $price, TierPriceInterfa
|
547 | 548 | && $price->getWebsiteId() != $tierPrice->getWebsiteId();
|
548 | 549 | }
|
549 | 550 |
|
| 551 | + /** |
| 552 | + * Compare Website Values between for new price records |
| 553 | + * |
| 554 | + * @param TierPriceInterface $price |
| 555 | + * @param TierPriceInterface $tierPrice |
| 556 | + * @return bool |
| 557 | + */ |
| 558 | + private function compareWebsiteValueNewPrice(TierPriceInterface $price, TierPriceInterface $tierPrice): bool |
| 559 | + { |
| 560 | + if ($price->getWebsiteId() != $this->allWebsitesValue || |
| 561 | + $tierPrice->getWebsiteId() != $this->allWebsitesValue |
| 562 | + ) { |
| 563 | + return $price->getWebsiteId() == $tierPrice->getWebsiteId(); |
| 564 | + } |
| 565 | + |
| 566 | + $baseCurrency = $this->scopeConfig->getValue(Currency::XML_PATH_CURRENCY_BASE, 'default'); |
| 567 | + $websiteId = max($price->getWebsiteId(), $tierPrice->getWebsiteId()); |
| 568 | + $website = $this->websiteRepository->getById($websiteId); |
| 569 | + $websiteCurrency = $website->getBaseCurrencyCode(); |
| 570 | + |
| 571 | + return $price->getWebsiteId() == $tierPrice->getWebsiteId() && $baseCurrency == $websiteCurrency; |
| 572 | + } |
| 573 | + |
550 | 574 | /**
|
551 | 575 | * @inheritDoc
|
552 | 576 | */
|
|
0 commit comments