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

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\Framework\DataAbstractionLayer\Search\Sorting\FieldSorting;
  6. use Symfony\Component\EventDispatcher\EventSubscriberInterface;
  7. class CategoryCriteriaSubscriber implements EventSubscriberInterface
  8. {
  9.     /**
  10.      * @return array<string, string|array{0: string, 1: int}|list<array{0: string, 1?: int}>>
  11.      */
  12.     public static function getSubscribedEvents()
  13.     {
  14.         return [
  15.             EnrichExportCriteriaEvent::class => 'enrich',
  16.         ];
  17.     }
  18.     public function enrich(EnrichExportCriteriaEvent $event): void
  19.     {
  20.         if ($event->getLogEntity()->getProfile()->getSourceEntity() !== CategoryDefinition::ENTITY_NAME) {
  21.             return;
  22.         }
  23.         $criteria $event->getCriteria();
  24.         $criteria->resetSorting();
  25.         $criteria->addSorting(new FieldSorting('level'));
  26.         $criteria->addSorting(new FieldSorting('id'));
  27.     }
  28. }