vendor/shopware/platform/src/Core/Content/ImportExport/Event/Subscriber/CategoryCriteriaSubscriber.php line 19

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.     public static function getSubscribedEvents()
  10.     {
  11.         return [
  12.             EnrichExportCriteriaEvent::class => 'enrich',
  13.         ];
  14.     }
  15.     public function enrich(EnrichExportCriteriaEvent $event): void
  16.     {
  17.         if ($event->getLogEntity()->getProfile()->getSourceEntity() !== CategoryDefinition::ENTITY_NAME) {
  18.             return;
  19.         }
  20.         $criteria $event->getCriteria();
  21.         $criteria->resetSorting();
  22.         $criteria->addSorting(new FieldSorting('level'));
  23.         $criteria->addSorting(new FieldSorting('id'));
  24.     }
  25. }