Skip to content

Commit

Permalink
Multiwebsite Feature Added
Browse files Browse the repository at this point in the history
  • Loading branch information
amjadm61 committed Nov 4, 2022
1 parent fe366fe commit 5925ae9
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions Observer/Predispatch.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ class Predispatch implements ObserverInterface {

public function __construct (
\Magento\Framework\App\Response\Http $redirect,
\Magento\ConfigurableProduct\Model\ResourceModel\Product\Type\Configurable $productTypeConfigurable,
\Magento\ConfigurableProduct\Model\Product\Type\Configurable $productTypeConfigurable,
\Magento\Catalog\Model\ProductRepository $productRepository,
\Magento\Store\Model\StoreManagerInterface $storeManager,
\Magento\Framework\App\Config\ScopeConfigInterface $scopeConfig,
Expand Down Expand Up @@ -56,7 +56,13 @@ public function execute(Observer $observer)

foreach ($configProductIds as $configProductId) {
try {
$configProduct = $this->_productRepository->getById($configProductId, false, $this->_storeManager->getStore()->getId());
$currentWebsiteId = $this->_storeManager->getStore()->getWebsiteId();
$websiteIds = $this->_productRepository->getById($configProductId)->getWebsiteIds();
if(in_array($currentWebsiteId, $websiteIds)){
$configProduct = $this->_productRepository->getById($configProductId);
} else {
return;
}
} catch (NoSuchEntityException $e) {
continue;
}
Expand Down

0 comments on commit 5925ae9

Please sign in to comment.