From a7d8704946dafd93f34557269a78878ed1353cf0 Mon Sep 17 00:00:00 2001 From: Mediacamp Date: Mon, 18 Oct 2021 04:00:20 +0200 Subject: [PATCH 1/2] JWK-79 Check product price for store view with different base currency --- Model/ProductService.php | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/Model/ProductService.php b/Model/ProductService.php index 4eee983..e4c3b50 100755 --- a/Model/ProductService.php +++ b/Model/ProductService.php @@ -304,6 +304,14 @@ public function getAllForDelete() public function prepareProductData($product, $isNew = true, array $imagesData = [], array $mediaContentData = []) { $rule = $this->ruleFactory->create(); + + if ($this->helper->isDifferentCurrency($this->helper->getStore()->getBaseCurrencyCode())) { + $baseProduct = $this->productRepository->getById($product->getId()); + + if ($baseProduct->getPrice() == $product->getPrice()) { + throw new \Magento\Framework\Exception\NoSuchEntityException(__('Product price is not set in the WTC store view')); + } + } $mainPrice = $this->helper->convertPrice($product->getPrice()); $mainSpecialPrice = null; From e624bfb3a5d5ba5215feaefa523a4abb86f17d7e Mon Sep 17 00:00:00 2001 From: Mediacamp Date: Mon, 1 Nov 2021 17:40:09 +0100 Subject: [PATCH 2/2] JWK-79 Check product price for store view with different base currency --- Model/ProductService.php | 23 +++++++++++++++++------ 1 file changed, 17 insertions(+), 6 deletions(-) diff --git a/Model/ProductService.php b/Model/ProductService.php index e4c3b50..530c494 100755 --- a/Model/ProductService.php +++ b/Model/ProductService.php @@ -56,6 +56,11 @@ class ProductService * @var \Magento\ConfigurableProduct\Model\Product\Type\Configurable */ protected $configurable; + + /** + * @var \Magento\Catalog\Model\Attribute\ScopeOverriddenValue + */ + protected $scopeOverriddenValue; /** * ProductService constructor. @@ -68,6 +73,7 @@ class ProductService * @param \Walkthechat\Walkthechat\Api\QueueRepositoryInterface $queueRepository * @param \Magento\CatalogRule\Model\RuleFactory $ruleFactory * @param \Magento\ConfigurableProduct\Model\Product\Type\Configurable $configurable + * @param \Magento\Catalog\Model\Attribute\ScopeOverriddenValue $scopeOverriddenValue */ public function __construct( \Magento\Catalog\Model\ProductRepository $productRepository, @@ -77,7 +83,8 @@ public function __construct( \Walkthechat\Walkthechat\Model\QueueService $queueService, \Walkthechat\Walkthechat\Api\QueueRepositoryInterface $queueRepository, \Magento\CatalogRule\Model\RuleFactory $ruleFactory, - \Magento\ConfigurableProduct\Model\Product\Type\Configurable $configurable + \Magento\ConfigurableProduct\Model\Product\Type\Configurable $configurable, + \Magento\Catalog\Model\Attribute\ScopeOverriddenValue $scopeOverriddenValue ) { $this->productRepository = $productRepository; $this->searchCriteriaBuilder = $searchCriteriaBuilder; @@ -87,6 +94,7 @@ public function __construct( $this->queueRepository = $queueRepository; $this->ruleFactory = $ruleFactory; $this->configurable = $configurable; + $this->scopeOverriddenValue = $scopeOverriddenValue; } /** @@ -304,15 +312,18 @@ public function getAllForDelete() public function prepareProductData($product, $isNew = true, array $imagesData = [], array $mediaContentData = []) { $rule = $this->ruleFactory->create(); - + if ($this->helper->isDifferentCurrency($this->helper->getStore()->getBaseCurrencyCode())) { - $baseProduct = $this->productRepository->getById($product->getId()); - - if ($baseProduct->getPrice() == $product->getPrice()) { + if (!$this->scopeOverriddenValue->containsValue( + \Magento\Catalog\Api\Data\ProductInterface::class, + $product, + 'price', + $this->helper->getStore()->getId()) + ) { throw new \Magento\Framework\Exception\NoSuchEntityException(__('Product price is not set in the WTC store view')); } } - + $mainPrice = $this->helper->convertPrice($product->getPrice()); $mainSpecialPrice = null; if (!$product->getSpecialFromDate() && !$product->getSpecialToDate()) {