Skip to content

Commit 5925ae9

Browse files
committed
Multiwebsite Feature Added
1 parent fe366fe commit 5925ae9

File tree

1 file changed

+8
-2
lines changed

1 file changed

+8
-2
lines changed

Observer/Predispatch.php

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ class Predispatch implements ObserverInterface {
1515

1616
public function __construct (
1717
\Magento\Framework\App\Response\Http $redirect,
18-
\Magento\ConfigurableProduct\Model\ResourceModel\Product\Type\Configurable $productTypeConfigurable,
18+
\Magento\ConfigurableProduct\Model\Product\Type\Configurable $productTypeConfigurable,
1919
\Magento\Catalog\Model\ProductRepository $productRepository,
2020
\Magento\Store\Model\StoreManagerInterface $storeManager,
2121
\Magento\Framework\App\Config\ScopeConfigInterface $scopeConfig,
@@ -56,7 +56,13 @@ public function execute(Observer $observer)
5656

5757
foreach ($configProductIds as $configProductId) {
5858
try {
59-
$configProduct = $this->_productRepository->getById($configProductId, false, $this->_storeManager->getStore()->getId());
59+
$currentWebsiteId = $this->_storeManager->getStore()->getWebsiteId();
60+
$websiteIds = $this->_productRepository->getById($configProductId)->getWebsiteIds();
61+
if(in_array($currentWebsiteId, $websiteIds)){
62+
$configProduct = $this->_productRepository->getById($configProductId);
63+
} else {
64+
return;
65+
}
6066
} catch (NoSuchEntityException $e) {
6167
continue;
6268
}

0 commit comments

Comments
 (0)