Если не проверять ваш код
private function list_elements_query($time, $cat_ids)
{
switch($this->diafan->configmodules("sort"))
{
case 1:
$order = 's.id DESC';
break;
case 2:
$order = 's.id ASC';
break;
case 3:
$order = 's.name'._LANG.' ASC';
break;
default:
$order = 's.sort DESC, s.id DESC';
}
$rows = DB::query_range_fetch_all(
"SELECT s.id, s.[name], s.timeedit, s.[anons], s.site_id, s.brand_id, s.no_buy, s.article,"
." s.hit, s.new, s.action, s.is_file FROM {shop} AS s"
.($this->diafan->_route->sort == 1 || $this->diafan->_route->sort == 2 ?
" LEFT JOIN {shop_price} AS pr ON pr.good_id=s.id AND pr.trash='0'"
." AND pr.date_start<=".time()." AND (pr.date_start=0 OR pr.date_finish>=".time().")"
." AND pr.currency_id=0"
." AND pr.role_id".($this->diafan->_users->role_id ? " IN (0,".$this->diafan->_users->role_id.")" : "=0")
." AND (pr.person='0'".($this->person_discount_ids ? " OR pr.discount_id IN(".implode(",", $this->person_discount_ids).")" : "").")"
: '')
.($this->sort_config['use_params_for_sort'] ? " LEFT JOIN {shop_param_element} AS sp ON sp.element_id=s.id AND sp.trash='0' AND sp.param_id=".$this->sort_config['param_ids'][$this->diafan->_route->sort] : '')
.($this->diafan->configmodules('where_access_element') ? " LEFT JOIN {access} AS a ON a.element_id=s.id AND a.module_name='shop' AND a.element_type='element'" : "")
.($cat_ids ? " INNER JOIN {shop_category_rel} AS r ON s.id=r.element_id" : '')
." WHERE s.[act]='1' AND s.trash='0' "
.($cat_ids ? "AND r.cat_id IN (".implode(',', $cat_ids).")" : 'AND s.site_id='.$this->diafan->_site->id)
.($this->diafan->configmodules('where_period_element') ? " AND s.date_start<=".$time." AND (s.date_finish=0 OR s.date_finish>=".$time.")" : '')
.($this->diafan->_route->brand ? " AND s.brand_id=".$this->diafan->_route->brand : '')
.($this->diafan->configmodules('where_access_element') ? " AND (s.access='0' OR s.access='1' AND a.role_id=".$this->diafan->_users->role_id.")" : '')
." GROUP BY s.id ORDER BY "
.($this->diafan->_route->sort ? $this->sort_config['sort_directions'][$this->diafan->_route->sort].',' : '')
."s.no_buy ASC, ".$order,
$this->diafan->_paginator->polog, $this->diafan->_paginator->nastr
);
return $rows;
}
То найдите в выше приведенном Вами коде строчку
LEFT JOIN {shop_param_element} AS sp ON sp.element_id=s.id AND sp.trash='0' AND sp.param_id=".$this->sort_config['param_ids'][$this->diafan->_route->sort] : '')
.($this->diafan->configmodules('where_access_element') ? " LEFT JOIN {access}
И замените ее на эту строчку
LEFT JOIN {shop_param_element} AS sp ON sp.element_id=s.id AND sp.trash='0' AND sp.param_id=".$this->sort_config['param_ids'][$this->diafan->_route->sort] : '')
.($this->diafan->configmodules('where_access_element') ? " AND sp.value='1' LEFT JOIN {access}
Теперь, в результате получим то, что вы хотели
Как поправить запрос, чтобы выдавались только те товары, у которых в таблице {shop_param_element} присутствовало значение value1=2?