getSortingsOfCategories example


    public function manufacturerAction(ShopContextInterface $context)
    {
        $manufacturerId = $this->Request()->getParam('sSupplier');

        if (!$this->Request()->getParam('sCategory')) {
            $categoryId = $context->getShop()->getCategory()->getId();

            $this->Request()->setParam('sCategory', $categoryId);

            $sortings = $this->customSortingService->getSortingsOfCategories([$categoryId]$context);

            $sortings = array_shift($sortings);

            $this->setDefaultSorting($sortings);

            $this->view->assign('sortings', $sortings);
        }

        $criteria = $this->storeFrontCriteriaFactory
            ->createListingCriteria($this->Request()$context);

        

        }$this->getSortings($categoryId))));
    }

    /** * @return CustomSorting[] */
    private function getSortings(int $categoryId): array
    {
        $context = $this->get(\Shopware\Bundle\StoreFrontBundle\Service\ContextServiceInterface::class)->getShopContext();

        return current($this->get(\Shopware\Bundle\StoreFrontBundle\Service\CustomSortingServiceInterface::class)->getSortingsOfCategories([$categoryId]$context));
    }

    private function getSorting(int $categoryId, int $sortingId): ?CustomSorting
    {
        foreach ($this->getSortings($categoryId) as $sorting) {
            if ($sorting->getId() === $sortingId) {
                return $sorting;
            }
        }

        return null;
    }
$this->backlogProcessor->add($backlogs);
        }
    }

    /** * @return array<int, CustomSorting>|null */
    private function getSortings(int $categoryId): ?array
    {
        $context = $this->contextService->getShopContext();

        $customSortings = $this->customSortingService->getSortingsOfCategories([$categoryId]$context);

        return array_shift($customSortings);
    }

    private function getSorting(int $categoryId, int $sortingId): ?CustomSorting
    {
        $sortings = $this->getSortings($categoryId);
        if (!\is_array($sortings)) {
            return null;
        }

        

    public function getList(array $ids, ShopContextInterface $context)
    {
        return $this->gateway->getList($ids$context);
    }

    /** * {@inheritdoc} */
    public function getSortingsOfCategories(array $categoryIds, ShopContextInterface $context)
    {
        return $this->gateway->getSortingsOfCategories($categoryIds$context);
    }

    /** * {@inheritdoc} */
    public function getAllCategorySortings(ShopContextInterface $context)
    {
        return $this->gateway->getAllCategorySortings($context);
    }
}
Home | Imprint | This part of the site doesn't use cookies.