createQueryWithSorting example


        $criteria = new Criteria();
        $criteria->addBaseCondition(new CategoryCondition([$categoryId]));
        $criteria->addSorting(new ManualSorting());
        $criteria->offset($start);
        $criteria->limit($limit);

        foreach ($customSorting->getSortings() as $sorting) {
            $criteria->addSorting($sorting);
        }

        $query = $this->queryBuilderFactory->createQueryWithSorting($criteria$this->contextService->getShopContext());

        $data = [];
        $query
            ->leftJoin('variant', 's_articles_prices', 'price', 'price.articledetailsID = variant.id AND price.from = 1 AND price.pricegroup = \'EK\'')
            ->leftJoin('product', 's_core_tax', 'tax', 'tax.id = product.taxID')
            ->leftJoin('product', 's_articles_img', 'img', 'img.articleID = product.id AND img.main = 1')
            ->leftJoin('img', 's_media', 'media', 'media.id = img.media_id')
            ->addSelect('SQL_CALC_FOUND_ROWS product.id as id')
            ->addSelect('product.name')
            
$this->addSorting($criteria$query$context);

        return $query;
    }

    /** * {@inheritdoc} */
    public function createProductQuery(Criteria $criteria, ShopContextInterface $context)
    {
        $query = $this->createQueryWithSorting($criteria$context);

        $select = $query->getQueryPart('select');

        if ($criteria->fetchCount()) {
            $query->select([
                'SQL_CALC_FOUND_ROWS product.id as __product_id',
                'variant.id as __variant_id',
                'variant.ordernumber as __variant_ordernumber',
            ]);
        } else {
            $query->select([
                
Home | Imprint | This part of the site doesn't use cookies.