$q2 = $this->modx->newQuery($this->classKey);
$offersAlias = "offer";
$q2->setClassAlias($offersAlias);
$q2->select(array(
"property_198",
"GROUP_CONCAT({$offersAlias}.id SEPARATOR '||') as offers_id",
"GROUP_CONCAT({$offersAlias}.price SEPARATOR '||') as prices",
"GROUP_CONCAT({$offersAlias}.article SEPARATOR '||') as articles",
"GROUP_CONCAT({$offersAlias}.packaging SEPARATOR '||') as packages",
));
$q2->where(array(
"{$offersAlias}.published" => 1,
"{$offersAlias}.deleted" => 0,
"{$offersAlias}.hidemenu" => 0,
"{$offersAlias}.property_198:!=" => "",
));
$q2->groupby("{$offersAlias}.property_198");
$q2->prepare();
$sql = $q2->toSQL();
$c->query['from']['joins'][] = array(
"type" => "left join",
"table" => "({$sql})",
"alias" => "t1",
"conditions" => array(
new xPDOQueryCondition(array(
"sql" => "{$alias}.property_198 = t1.property_198",
)),
),
);
$c->select(array(
"if(t1.offers_id IS NOT NULL, t1.offers_id, {$alias}.id) as offers_id",
"if(t1.prices IS NOT NULL, t1.prices, {$alias}.price) as prices",
"if(t1.articles IS NOT NULL, t1.articles, {$alias}.article) as articles",
"if(t1.packages IS NOT NULL, t1.packages, {$alias}.packaging) as packages",
));