vendor/shopware/core/Content/Product/SalesChannel/Sorting/ProductSortingCollection.php line 12

Open in your IDE?
  1. <?php declare(strict_types=1);
  2. namespace Shopware\Core\Content\Product\SalesChannel\Sorting;
  3. use Shopware\Core\Framework\DataAbstractionLayer\EntityCollection;
  4. use Shopware\Core\Framework\Log\Package;
  5. /**
  6.  * @extends EntityCollection<ProductSortingEntity>
  7.  */
  8. #[Package('inventory')]
  9. class ProductSortingCollection extends EntityCollection
  10. {
  11.     public function sortByKeyArray(array $keys): void
  12.     {
  13.         $sorted = [];
  14.         foreach ($keys as $key) {
  15.             $sorting $this->getByKey($key);
  16.             if ($sorting !== null) {
  17.                 $sorted[$sorting->getId()] = $this->elements[$sorting->getId()];
  18.             }
  19.         }
  20.         $this->elements $sorted;
  21.     }
  22.     public function getByKey(string $key): ?ProductSortingEntity
  23.     {
  24.         return $this->filterByProperty('key'$key)->first();
  25.     }
  26.     public function getApiAlias(): string
  27.     {
  28.         return 'product_sorting_collection';
  29.     }
  30.     protected function getExpectedClass(): string
  31.     {
  32.         return ProductSortingEntity::class;
  33.     }
  34. }