custom/plugins/AcrisSuppliesUpsellingCS/src/Storefront/Page/Product/ProductPageLoader.php line 37

Open in your IDE?
  1. <?php declare(strict_types=1);
  2. namespace Acris\SuppliesUpselling\Storefront\Page\Product;
  3. use Shopware\Core\Content\Category\Exception\CategoryNotFoundException;
  4. use Shopware\Core\Content\Product\Exception\ProductNotFoundException;
  5. use Shopware\Core\Framework\DataAbstractionLayer\Exception\InconsistentCriteriaIdsException;
  6. use Shopware\Core\Framework\Routing\Exception\MissingRequestParameterException;
  7. use Shopware\Core\Framework\Struct\ArrayEntity;
  8. use Shopware\Core\System\SalesChannel\SalesChannelContext;
  9. use Shopware\Core\System\SystemConfig\SystemConfigService;
  10. use Shopware\Storefront\Page\Product\ProductPage;
  11. use Symfony\Component\HttpFoundation\Request;
  12. use Shopware\Storefront\Page\Product\ProductPageLoader as ParentClass;
  13. class ProductPageLoader extends ParentClass
  14. {
  15.     private ParentClass $parentProductPageLoader;
  16.     private SystemConfigService $systemConfigService;
  17.     public function __construct(
  18.         ParentClass $parentProductPageLoader,
  19.         SystemConfigService $systemConfigService
  20.     ) {
  21.         $this->parentProductPageLoader $parentProductPageLoader;
  22.         $this->systemConfigService $systemConfigService;
  23.     }
  24.     /**
  25.      * @throws CategoryNotFoundException
  26.      * @throws InconsistentCriteriaIdsException
  27.      * @throws MissingRequestParameterException
  28.      * @throws ProductNotFoundException
  29.      */
  30.     public function load(Request $requestSalesChannelContext $salesChannelContext): ProductPage
  31.     {
  32.         $enableAsynchronousLoading $this->systemConfigService->get('AcrisSuppliesUpsellingCS.config.enableAsynchronousLoading'$salesChannelContext->getSalesChannel()->getId());
  33.         if ($enableAsynchronousLoading) {
  34.             $salesChannelContext->addExtension('acrisCrossSellingAsynchronousLoading', new ArrayEntity([
  35.                 'asynchronousLoading' => $enableAsynchronousLoading
  36.             ]));
  37.         }
  38.         return $this->parentProductPageLoader->load($request$salesChannelContext);
  39.     }
  40. }