vendor/shopware/core/Content/Product/Cart/ProductGateway.php line 35

Open in your IDE?
  1. <?php declare(strict_types=1);
  2. namespace Shopware\Core\Content\Product\Cart;
  3. use Shopware\Core\Content\Product\Events\ProductGatewayCriteriaEvent;
  4. use Shopware\Core\Content\Product\ProductCollection;
  5. use Shopware\Core\Framework\DataAbstractionLayer\Search\Criteria;
  6. use Shopware\Core\System\SalesChannel\Entity\SalesChannelRepositoryInterface;
  7. use Shopware\Core\System\SalesChannel\SalesChannelContext;
  8. use Symfony\Contracts\EventDispatcher\EventDispatcherInterface;
  9. class ProductGateway implements ProductGatewayInterface
  10. {
  11.     /**
  12.      * @var SalesChannelRepositoryInterface
  13.      */
  14.     private $repository;
  15.     /**
  16.      * @var EventDispatcherInterface
  17.      */
  18.     private $eventDispatcher;
  19.     /**
  20.      * @internal
  21.      */
  22.     public function __construct(
  23.         SalesChannelRepositoryInterface $repository,
  24.         EventDispatcherInterface $eventDispatcher
  25.     ) {
  26.         $this->repository $repository;
  27.         $this->eventDispatcher $eventDispatcher;
  28.     }
  29.     public function get(array $idsSalesChannelContext $context): ProductCollection
  30.     {
  31.         $criteria = new Criteria($ids);
  32.         $criteria->setTitle('cart::products');
  33.         $criteria->addAssociation('cover');
  34.         $criteria->addAssociation('options.group');
  35.         $criteria->addAssociation('featureSet');
  36.         $criteria->addAssociation('properties.group');
  37.         $this->eventDispatcher->dispatch(
  38.             new ProductGatewayCriteriaEvent($ids$criteria$context)
  39.         );
  40.         /** @var ProductCollection $result */
  41.         $result $this->repository->search($criteria$context)->getEntities();
  42.         return $result;
  43.     }
  44. }