Добрый день.
Помогите программно исправить запрос views
node.type AS node_type,
node.title AS node_title,
node_data_field_old_price.field_old_price_value AS node_data_field_old_price_field_old_price_value,
node.vid AS node_vid,
uc_products.sell_price AS uc_products_sell_price,
node_data_field_old_price.field_image_cache_fid AS node_data_field_old_price_field_image_cache_fid,
node_data_field_old_price.field_image_cache_list AS node_data_field_old_price_field_image_cache_list,
node_data_field_old_price.field_image_cache_data AS node_data_field_old_price_field_image_cache_data,
node.sticky AS node_sticky,
node.created AS node_created
FROM node node
INNER JOIN term_node term_node ON node.vid = term_node.vid
LEFT JOIN content_type_product node_data_field_old_price ON node.vid = node_data_field_old_price.vid
LEFT JOIN uc_products uc_products ON node.vid = uc_products.vid
WHERE (node.status = 1) AND (node.type IN ('product')) AND (term_node.tid = 216)
ORDER BY node_sticky DESC, node_created DESC
на
SELECT node.nid AS nid,
node.type AS node_type,
node.title AS node_title,
node_data_field_old_price.field_old_price_value AS node_data_field_old_price_field_old_price_value,
node.vid AS node_vid,
uc_products.sell_price AS uc_products_sell_price,
node_data_field_old_price.field_image_cache_fid AS node_data_field_old_price_field_image_cache_fid,
node_data_field_old_price.field_image_cache_list AS node_data_field_old_price_field_image_cache_list,
node_data_field_old_price.field_image_cache_data AS node_data_field_old_price_field_image_cache_data,
node.sticky AS node_sticky,
node.created AS node_created
sort_node.sort AS sorting
FROM node
INNER JOIN term_node term_node ON node.vid = term_node.vid
LEFT JOIN sort_node ON node.nid = sort_node.nid
LEFT JOIN content_type_product node_data_field_old_price ON node.vid = node_data_field_old_price.vid
LEFT JOIN uc_products uc_products ON node.vid = uc_products.vid
WHERE (node.status = 1) AND (node.type IN ('product')) AND (term_node.tid = 216) AND (sort_node.tid = term_node.tid)
ORDER BY sorting, node_sticky DESC, node_created DESC
Комментарии
Результат я получил. Ток мне не нравится каким методом.
Сделал так
if ($view->name == 'new_catalog') {
$view->build_info['query'] = "SELECT ......"
}
}
Хотелось бы сделать норм через
hook_views_query_alter(&$view, &$query)
Но не нашёл API
Посмотрите тут http://drupalace.ru/lesson/programmnoe-izmenenie-zaprosa-k-baze-dannyh-v...
Недавно с похожей задачей разбирался, если надо будет подскажу поподробнее.
Комент удалил - был дубль.