vendor/shopware/core/Content/ImportExport/Event/Subscriber/CategoryCriteriaSubscriber.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\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 Shopware\Core\Framework\Log\Package;
  8. use Symfony\Component\EventDispatcher\EventSubscriberInterface;
  9. /**
  10.  * @deprecated tag:v6.5.0 - reason:becomes-internal - EventSubscribers will become internal in v6.5.0
  11.  */
  12. #[Package('system-settings')]
  13. class CategoryCriteriaSubscriber 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() !== CategoryDefinition::ENTITY_NAME) {
  29.             return;
  30.         }
  31.         $criteria $event->getCriteria();
  32.         $criteria->resetSorting();
  33.         $criteria->addSorting(new FieldSorting('level'));
  34.         $criteria->addSorting(new FieldSorting('id'));
  35.     }
  36. }