diff --git a/vendor/magento/module-catalog/Model/Product/Price/Validation/TierPriceValidator.php b/vendor/magento/module-catalog/Model/Product/Price/Validation/TierPriceValidator.php index 4eff31e8a4428..6d1acb613ea4e 100644 --- a/vendor/magento/module-catalog/Model/Product/Price/Validation/TierPriceValidator.php +++ b/vendor/magento/module-catalog/Model/Product/Price/Validation/TierPriceValidator.php @@ -20,6 +20,7 @@ use Magento\Catalog\Helper\Data; use Magento\Store\Model\ScopeInterface; use Magento\Framework\Exception\NoSuchEntityException; +use Magento\Store\Model\StoreManagerInterface; /** * Validate Tier Price and check duplication @@ -88,6 +89,11 @@ class TierPriceValidator implements ResetAfterRequestInterface */ private $scopeConfig; + /** + * @var StoreManagerInterface + */ + private StoreManagerInterface $storeManager; + /** * TierPriceValidator constructor. * @@ -99,6 +105,7 @@ class TierPriceValidator implements ResetAfterRequestInterface * @param array $allowedProductTypes [optional] * @param ResourceConnection|null $resourceConnection * @param ScopeConfigInterface|null $scopeConfig + * @param StoreManagerInterface|null $storeManager * @SuppressWarnings(PHPMD.ExcessiveParameterList) */ public function __construct( @@ -109,7 +116,8 @@ public function __construct( ProductRepositoryInterface $productRepository, array $allowedProductTypes = [], ?ResourceConnection $resourceConnection = null, - ?ScopeConfigInterface $scopeConfig = null + ?ScopeConfigInterface $scopeConfig = null, + ?StoreManagerInterface $storeManager = null ) { $this->productIdLocator = $productIdLocator; $this->websiteRepository = $websiteRepository; @@ -119,6 +127,7 @@ public function __construct( $this->allowedProductTypes = $allowedProductTypes; $this->resourceConnection = $resourceConnection ?: ObjectManager::getInstance()->get(ResourceConnection::class); $this->scopeConfig = $scopeConfig ?: ObjectManager::getInstance()->get(ScopeConfigInterface::class); + $this->storeManager = $storeManager ?: ObjectManager::getInstance()->get(StoreManagerInterface::class); } /** @@ -354,12 +363,12 @@ private function checkWebsite(TierPriceInterface $price, $key, Result $validatio { try { $this->websiteRepository->getById($price->getWebsiteId()); - $isWebsiteScope = $this->scopeConfig - ->isSetFlag( - Data::XML_PATH_PRICE_SCOPE, - ScopeInterface::SCOPE_STORE, - ScopeConfigInterface::SCOPE_TYPE_DEFAULT - ); + $defaultStoreView = $this->storeManager->getDefaultStoreView(); + $isWebsiteScope = $this->scopeConfig->isSetFlag( + Data::XML_PATH_PRICE_SCOPE, + ScopeInterface::SCOPE_STORE, + $defaultStoreView->getCode() + ); if (!$isWebsiteScope && (int) $this->allWebsitesValue !== $price->getWebsiteId()) { throw NoSuchEntityException::singleField('website_id', $price->getWebsiteId()); }