vendor/shopware/core/Content/ImportExport/Event/Subscriber/CategoryCriteriaSubscriber.php line 26

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