vendor/shopware/core/Content/ImportExport/Event/Subscriber/ProductCriteriaSubscriber.php line 28

Open in your IDE?
  1. <?php declare(strict_types=1);
  2. namespace Shopware\Core\Content\ImportExport\Event\Subscriber;
  3. use Shopware\Core\Content\ImportExport\Event\EnrichExportCriteriaEvent;
  4. use Shopware\Core\Content\ImportExport\ImportExportProfileEntity;
  5. use Shopware\Core\Content\ImportExport\Struct\Config;
  6. use Shopware\Core\Content\Product\ProductDefinition;
  7. use Shopware\Core\Framework\DataAbstractionLayer\Search\Filter\EqualsFilter;
  8. use Shopware\Core\Framework\DataAbstractionLayer\Search\Sorting\FieldSorting;
  9. use Symfony\Component\EventDispatcher\EventSubscriberInterface;
  10. /**
  11.  * @deprecated tag:v6.5.0 - reason:becomes-internal - EventSubscribers will become internal in v6.5.0
  12.  */
  13. class ProductCriteriaSubscriber implements EventSubscriberInterface
  14. {
  15.     /**
  16.      * @return array<string, string|array{0: string, 1: int}|list<array{0: string, 1?: int}>>
  17.      */
  18.     public static function getSubscribedEvents()
  19.     {
  20.         return [
  21.             EnrichExportCriteriaEvent::class => 'enrich',
  22.         ];
  23.     }
  24.     public function enrich(EnrichExportCriteriaEvent $event): void
  25.     {
  26.         /** @var ImportExportProfileEntity $profile */
  27.         $profile $event->getLogEntity()->getProfile();
  28.         if ($profile->getSourceEntity() !== ProductDefinition::ENTITY_NAME) {
  29.             return;
  30.         }
  31.         $criteria $event->getCriteria();
  32.         $criteria->resetSorting();
  33.         $criteria->addSorting(new FieldSorting('autoIncrement'));
  34.         $config Config::fromLog($event->getLogEntity());
  35.         if ($config->get('includeVariants') !== true) {
  36.             $criteria->addFilter(new EqualsFilter('parentId'null));
  37.         }
  38.     }
  39. }