Skip to content

Commit

Permalink
[Store] optimize Store Context resolving with fallback and admin/non-…
Browse files Browse the repository at this point in the history
…admin also for area bricks
  • Loading branch information
dpfaffenbauer committed Dec 19, 2024
1 parent d556fdd commit 26b32e0
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ services:
CoreShop\Component\Store\Context\RequestBased\PimcoreAreaBrickRenderResolver:
public: false
arguments:
- '@coreshop.repository.store'
- '@CoreShop\Component\Store\Context\SiteBasedResolverInterface'
tags:
- { name: coreshop.context.store.request_based.resolver, priority: 220 }

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@

namespace CoreShop\Component\Store\Context\RequestBased;

use CoreShop\Component\Store\Context\SiteBasedResolverInterface;
use CoreShop\Component\Store\Context\StoreNotFoundException;
use CoreShop\Component\Store\Model\StoreInterface;
use CoreShop\Component\Store\Repository\StoreRepositoryInterface;
Expand All @@ -29,7 +30,7 @@
final class PimcoreAreaBrickRenderResolver implements RequestResolverInterface
{
public function __construct(
private StoreRepositoryInterface $storeRepository,
private SiteBasedResolverInterface $siteBasedResolver,
) {
}

Expand All @@ -44,9 +45,13 @@ public function findStore(Request $request): ?StoreInterface
if ($document) {
$site = Frontend::getSiteForDocument($document);

if ($site instanceof Site) {
return $this->storeRepository->findOneBySite($site->getId());
$store = $this->siteBasedResolver->resolveSiteWithDefaultForStore($site);

if (null === $store) {
throw new StoreNotFoundException();
}

return $store;
}
}
}
Expand Down

0 comments on commit 26b32e0

Please sign in to comment.