23 lines
787 B
PHP
23 lines
787 B
PHP
<?php
|
|
|
|
namespace KupShop\FeedsBundle\Query;
|
|
|
|
use Query\QueryBuilder;
|
|
|
|
class FeedProductQuery
|
|
{
|
|
public static function withFeedProducts(int $feedID): callable
|
|
{
|
|
return function (QueryBuilder $qb) use ($feedID) {
|
|
$qb->leftJoin('p', 'feed_products', 'fp', 'fp.id_product = p.id AND id_feed = :fp_id_feed')
|
|
->setParameter('fp_id_feed', $feedID)
|
|
->addSelect('p.max_cpc AS max_cpc, fp.title AS fp_title, fp.cpc AS fp_cpc, fp.id_section AS fp_id_section, COALESCE(pv.ean, p.ean) ean');
|
|
if (findModule(\Modules::PRODUCTS, \Modules::SUB_WEIGHT)) {
|
|
$qb->addSelect('COALESCE(pv.weight, p.weight) weight');
|
|
}
|
|
|
|
return "COALESCE(fp.active, p.show_in_feed) IN (1, 'Y')";
|
|
};
|
|
}
|
|
}
|