Skip to content

Commit

Permalink
fix: show 404 when page is not active for store (#94)
Browse files Browse the repository at this point in the history
fix: show 404 when page is not active for store
  • Loading branch information
ah-net authored Sep 24, 2024
1 parent f39c6be commit acc10a7
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion src/Controller/LandingPage/View.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
use Magento\Framework\Exception\NotFoundException;
use Magento\Framework\Registry;
use Magento\Framework\View\Result\PageFactory;
use Magento\Store\Model\StoreManagerInterface;

class View extends Action
{
Expand Down Expand Up @@ -69,7 +70,8 @@ public function __construct(
Registry $registry,
LandingPageRepositoryInterface $landingPageRepository,
CategoryRepositoryInterface $categoryRepository,
FilterApplierInterface $filterApplier
FilterApplierInterface $filterApplier,
private readonly StoreManagerInterface $storeManager
) {
$this->resultPageFactory = $resultPageFactory;
$this->coreRegistry = $registry;
Expand Down Expand Up @@ -97,6 +99,13 @@ public function execute(): ResultInterface
throw new NotFoundException(__('Page not active'));
}

$storeId = $this->storeManager->getStore()->getId();
$landingPageStoreIds = $landingPage->getStoreIds();

if ((!in_array($storeId, $landingPage->getStoreIds())) && (!in_array(0, $landingPage->getStoreIds()))) {
throw new NotFoundException(__('Page not active for this store'));
}

$this->landingPageContext->setLandingPage($landingPage);
$this->setCategoryInRegistry($landingPage);
$this->filterApplier->applyFilters($landingPage);
Expand Down

0 comments on commit acc10a7

Please sign in to comment.