createListingCriteria example

$result->getTotalCount(),
            $facetFilter->filter($result->getFacets()$criteria),
            $criteria,
            $context
        );
    }

    private function fetchCategoryListing(): ProductSearchResult
    {
        $context = $this->container->get(ContextServiceInterface::class)->getShopContext();

        $criteria = $this->container->get(StoreFrontCriteriaFactoryInterface::class)->createListingCriteria($this->Request()$context);

        $criteria->setGeneratePartialFacets(
            $this->container->get(Shopware_Components_Config::class)->get('listingMode') === 'filter_ajax_reload'
        );

        if (!$this->Request()->get('loadFacets')) {
            $criteria->resetFacets();
        }

        $search = $this->container->get(ProductSearchInterface::class);

        
$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);

        if ($condition = $criteria->getCondition('manufacturer')) {
            $criteria->removeCondition('manufacturer');
            $criteria->addBaseCondition($condition);
        }

        $categoryProducts = Shopware()->Modules()->Articles()->sGetArticlesByCategory(
            $context->getShop()->getCategory()->getId(),
            $criteria
        );
        if (!\is_array($categoryProducts)) {
            
return false;
        }

        $context = $this->contextService->getShopContext();

        $request = Shopware()->Container()->get('front')->Request();
        if (!$request instanceof Enlight_Controller_Request_Request) {
            throw new RuntimeException('Required request not available');
        }

        if (!$criteria instanceof Criteria) {
            $criteria = $this->storeFrontCriteriaFactory->createListingCriteria($request$context);
        }

        $result = $this->getListing($categoryId$context$request$criteria);

        return $this->legacyEventManager->fireArticlesByCategoryEvents($result$categoryId$this);
    }

    /** * @deprecated in 5.6, will be removed in 5.8 without replacement * * Get supplier by id * * Uses the new Supplier Manager * * TestCase: /_tests/Shopware/Tests/Modules/Articles/SuppliersTest.php * * @param int $id - s_articles_supplier.id * * @return array */
public function __construct(StoreFrontCriteriaFactoryInterface $criteriaFactory)
    {
        $this->criteriaFactory = $criteriaFactory;
    }

    /** * @return Criteria */
    public function createCriteria(Request $request, ShopContextInterface $context)
    {
        $criteria = $this->criteriaFactory->createListingCriteria($request$context);

        $criteria->removeBaseCondition('category');
        $criteria->resetFacets();

        $category = $context->getShop()->getCategory()->getId();
        $criteria->addBaseCondition(new CategoryCondition([$category]));

        return $criteria;
    }
}
Home | Imprint | This part of the site doesn't use cookies.