joinPriceGroup example

$query = $this->connection->createQueryBuilder();

        $selection = 'MIN(' . $this->listingPriceHelper->getSelection($context) . ') as cheapest_price';

        $query->select(['prices.*', $selection]);
        $query->from('s_articles', 'product');
        $query->innerJoin('product', 's_core_tax', 'tax', 'tax.id = product.taxID');
        $query->innerJoin('product', '(' . $priceTable->getSQL() . ')', 'prices', 'product.id = prices.articleID');

        $this->joinAvailableVariant($query);
        $this->listingPriceHelper->joinPriceGroup($query);

        $query->andWhere('prices.articledetailsID = availableVariant.id');

        if ($this->config->get('useLastGraduationForCheapestPrice')) {
            $query->andWhere("IF(priceGroup.id IS NOT NULL, prices.from = 1, prices.to = 'beliebig')");
        } else {
            $query->andWhere('prices.from = 1');
        }

        $query->groupBy('product.id');

        
$priceTable = $this->listingPriceHelper->getPriceTable($context);
        $priceTable->andWhere('defaultPrice.articledetailsID IN (:variants)');

        $priceListingQuery->select('DISTINCT prices.`articledetailsID` as articledetailsID');
        $priceListingQuery->addSelect('prices.`articleID` as articleID');
        $priceListingQuery->addSelect($this->listingPriceHelper->getSelection($context) . 'as price');
        $priceListingQuery->from('s_articles', 'product');
        $priceListingQuery->innerJoin('product', 's_articles_details', 'availableVariant', 'availableVariant.articleId = product.id');
        $priceListingQuery->innerJoin('prices', 's_article_configurator_option_relations', 'relations', 'relations.article_id = prices.articledetailsID');
        $priceListingQuery->innerJoin('relations', 's_article_configurator_options', 'options', 'relations.option_id = options.id');
        $priceListingQuery->innerJoin('product', 's_core_tax', 'tax', 'tax.id = product.taxID');
        $this->listingPriceHelper->joinPriceGroup($priceListingQuery);

        $priceListingQuery->andWhere('prices.articleID IN (:products)');
        $priceListingQuery->andWhere('prices.articledetailsID IN (:variants)');

        $onSalePriceListingQuery = clone $priceListingQuery;

        $priceListingQuery->innerJoin('availableVariant', '(' . $priceTable . ')', 'prices', 'availableVariant.id = prices.articledetailsID');
        if ($this->config->get('useLastGraduationForCheapestPrice')) {
            $priceListingQuery->andWhere("prices.to = 'beliebig'");
        } else {
            $priceListingQuery->andWhere('prices.from = 1');
        }
$priceTable->andWhere('(details.laststock * details.instock) >= (details.laststock * details.minpurchase)');
        $priceTable->andWhere('details.active = 1');

        $query->from('s_articles', 'product');
        $query->innerJoin('product', '(' . $priceTable->getSQL() . ')', 'prices', 'product.id = prices.articleID');
        $query->innerJoin('prices', 's_articles_details', 'variant', 'variant.id = prices.articledetailsID AND variant.active = 1');
        $query->innerJoin('product', 's_core_tax', 'tax', 'tax.id = product.taxID');

        $this->joinAvailableVariant($query);
        $query->andWhere('prices.articledetailsID = availableVariant.id');

        $this->listingPriceHelper->joinPriceGroup($query);

        $conditions = $criteria->getConditionsByClass(VariantCondition::class);

        /** @var VariantCondition $condition */
        foreach ($conditions as $condition) {
            if (!$condition->expandVariants()) {
                continue;
            }

            $tableKey = $condition->getName();
            $column = $tableKey . '.option_id AS ' . $tableKey . '_id';
            
Home | Imprint | This part of the site doesn't use cookies.