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