Как отключить подсчет товара в группах
Здравствуйте, хочу отключить подсчет товаров в группах. Пробовал использовать $param['xml_show_all_count_items_and_groups'] = false;
Но все равно выводит количество товаров, а значит считает.
Но все равно выводит количество товаров, а значит считает.
HostCMS, версия 5.9.36/Редакция Халява.
На базе стандартного шаблона типовой динамической, с небольшими корректировками. Хочу отключить подсчет, т.к. читал на форуме, что дает прирост в производительности при большом количестве товаров.
XML
XSL
На базе стандартного шаблона типовой динамической, с небольшими корректировками. Хочу отключить подсчет, т.к. читал на форуме, что дает прирост в производительности при большом количестве товаров.
<?php
function SetGroups($mas_groups, $set)
{
$mas_groups = to_array($mas_groups);
foreach ($mas_groups as $key=>$value)
{
foreach ($value as $key1=>$value1)
{
$set[] = $value1;
if ($value1 == $key)
{
$set[] = $key;
SetGroups($mas_groups, $set);
}
}
}
return $set;
}
$xsl_catalog = to_str($GLOBALS['LA']['xsl_catalog']);
$xsl_item = to_str($GLOBALS['LA']['xsl_item']);
$current_shop_id = to_int($GLOBALS['LA']['shop_id']);
$param = array();
$shop = & singleton('shop');
if ($GLOBALS['shop_item_path'] != false)
{
$external_propertys = array();
if (class_exists("SiteUsers"))
{
/* Получаем id текущего пользователя сайта */
$SiteUsers = & singleton('SiteUsers');
$site_user_id = $SiteUsers->GetCurrentSiteUser();
$param['user_id'] = $site_user_id;
$external_propertys['user_id'] = $site_user_id;
}
else
{
$site_user_id = 0;
$external_propertys['user_id'] = 0;
}
// Если добавление комментария
if (isset($_POST['submit_comment']) && !empty($GLOBALS['shop_item_path']['item'])
&& isset($_POST['email']) && isset($_POST['author']) && $_POST['email'] == 'comment@localhost.ru' && $_POST['author'] == '')
{
/* Проверяем CAPCHA*/
$Captcha = new Captcha();
$xmlData = '<?xml version="1.0" encoding="UTF-8"?>' . "\n";
$xmlData .= '<document>' . "\n";
if ($site_user_id > 0
|| $Captcha->ValidCaptcha(to_str($_POST['captcha_key']), to_str($_POST['captcha_keystring'])))
{
$param['shop_items_catalog_item_id'] = $GLOBALS['shop_item_path']['item'];
$param['shop_comment_user_name'] = to_str($_REQUEST['shop_comment_user_name']);
$param['shop_comment_user_email'] = to_str($_REQUEST['shop_comment_user_email']);
$param['shop_comment_subject'] = to_str($_REQUEST['shop_comment_subject']);
$param['shop_comment_text'] = to_str($_REQUEST['shop_comment_text']);
$param['shop_comment_grade'] = to_int($_REQUEST['shop_comment_grade']);
$param['shop_comment_date_time'] = date("Y-m-d H:i:s");
/* Активность/неактивность комментария */
$shop_row = $shop->GetShop($current_shop_id);
if ($shop_row)
{
$param['shop_comment_active'] = to_int($shop_row['shop_comment_active']);
}
else
{
$param['shop_comment_active'] = false;
}
$external_propertys['comment_is_active'] = $param['shop_comment_active'];
// Если есть модуль "Пользователи сайта", получим текущего пользователя
if (class_exists('SiteUsers'))
{
$SiteUsers = & singleton('SiteUsers');
$param['site_users_id'] = $SiteUsers->GetCurrentSiteUser();
}
else
{
$param['site_users_id'] = 0;
}
$shop_comment_id = $shop->InsertComment($param);
// Задан XSL для формирования письма администратору о добавлении комментария к товару
if (to_str($GLOBALS['LA']['xsl_add_comment_letter_to_admin']) != '')
{
// Формируем XML для комментария
$xmlData .= $shop->GenXml4Comment($shop_comment_id);
$xmlData .= '</document>' . "\n";
$xsl = new xsl();
// Формируем текст письма администратору
$message = $xsl->build($xmlData, $GLOBALS['LA']['xsl_add_comment_letter_to_admin']);
// Формат письма - текст
if (to_int($GLOBALS['LA']['comment_mail_type']) == 0)
{
$comment_mail_type = 'text/plain';
}
else
{
$comment_mail_type = 'text/html';
}
$subject = $GLOBALS['MSG_shops']['subject_report_for_comment'];
$kernel = & singleton('kernel');
// Получаем e-mail куратора магазина
$email_to = to_str($shop_row['shop_shops_admin_mail']);
if (!empty($email_to))
{
$kernel->SendMailWithFile($email_to, EMAIL_TO, $subject, $message, array(), $comment_mail_type);
}
}
}
else
{
/* Неправильно введен код изображенный на картинке */
$external_propertys['error'] = 1;
/* Запоминаем значения */
$external_propertys['shop_comment_user_name'] = strip_tags(to_str($_REQUEST['shop_comment_user_name']));
$external_propertys['shop_comment_user_email'] = strip_tags(to_str($_REQUEST['shop_comment_user_email']));
$external_propertys['shop_comment_subject'] = strip_tags(to_str($_REQUEST['shop_comment_subject']));
$external_propertys['shop_comment_text'] = strip_tags(to_str($_REQUEST['shop_comment_text']));
$external_propertys['shop_comment_grade'] = to_int($_REQUEST['shop_comment_grade']);
$external_propertys['shop_comment_date_time'] = date("Y-m-d H:i:s");
}
}
/* Вывод списка */
if (!$GLOBALS['shop_item_path']['item'])
{
$param['current_group_id'] = $GLOBALS['shop_item_path']['group']; // корневая группа
/* Определяем номер элемента, с которого начинается показ в текущей группе */
$page = end($GLOBALS['URL_ARRAY']);
$page = to_str($page);
$shop_row = $shop->GetShop($current_shop_id);
if ($shop_row)
{
if (!isset($GLOBALS['shop_item_path']['tag_name'])) {
$param['items_on_page'] = 25;
$items_on_page = 25;
}
else $items_on_page = $shop_row['shop_items_on_page'];
}
else
{
$items_on_page = 10;
}
/*
Порядок сортировки ('Asc' - по возрастанию, 'Desc' - по убыванию, 'Rand' - произвольный порядок)
$param['items_order'] = 'Asc';
Поле, по которому сортируем (наименование элемента)
$param['items_field_order'] = 'shop_items_catalog_name';
*/
if (isset($_GET['all_group']))
{
// Выводим из всех групп
$param['current_group_id'] = false;
$external_propertys['property_xml'] = "&all_group=1";
$external_propertys['apply_filter'] = true;
}
/* Ограничиваем по производителю */
if (to_int($_GET['producer_id']) > 0)
{
$element['type'] = 0; // 0 - основное св-во, 1 - дополнительное
$element['name'] = 'shop_producers_list_id';
$element['prefix'] = 'AND'; // префикс
$element['if'] = '='; // Условие
$element['value'] = to_int($_GET['producer_id']);
$element['sufix'] = '';
$param['select'][] = $element;
$external_propertys['producer_id'] = to_int($_GET['producer_id']);
/* Применять фильтр */
$external_propertys['apply_filter'] = true;
}
/* Ограничиваем по продавцу */
if (to_int($_GET['saller_id']) > 0)
{
$element['type'] = 0; // 0 - основное св-во, 1 - дополнительное
$element['name'] = 'shop_sallers_id';
$element['prefix'] = 'AND'; // префикс
$element['if'] = '='; // Условие
$element['value'] = to_int($_GET['saller_id']);
$element['sufix'] = '';
$param['select'][] = $element;
$external_propertys['saller_id'] = to_int($_GET['saller_id']);
/* Применять фильтр */
$external_propertys['apply_filter'] = true;
}
$price_from = str_replace(',', '.', to_float($_GET['price_from']));
/* Ограничиваем по цене ОТ */
if ($price_from > 0)
{
$external_propertys['price_from'] = $price_from;
/* Применять фильтр */
$external_propertys['apply_filter'] = true;
}
$price_to = str_replace(',', '.', to_float($_GET['price_to']));
/* Ограничиваем по цене ДО */
if ($price_to > 0)
{
$external_propertys['price_to'] = $price_to;
/* Применять фильтр */
$external_propertys['apply_filter'] = true;
}
/* Число элементов на странице */
$on_page = to_int($_GET['on_page']);
if ($on_page > 0 && $on_page < 150)
{
$param['items_on_page'] = $on_page;
$external_propertys['on_page'] = $on_page;
/* Применять фильтр */
$external_propertys['apply_filter'] = true;
}
// Определяем номер страницы.
if ($on_page)
{
$items_on_page = $on_page;
}
if (ereg("^page-([0-9]*)$", $page, $regs) && to_int($regs[1]) > 1)
{
/* Страница умножается на кол-во элементов, выводимых на страницу */
$items_begin = ($regs[1] - 1) * $items_on_page;
}
else
{
$items_begin = 0;
}
$param['items_begin'] = $items_begin;
/* Направление сортировки, 0 - по-возрастанию, 1 - по-убыванию */
$order_direction = to_int($_GET['order_direction']);
switch ($order_direction)
{
case 1: /* По-возрастанию */
{
$order_direction = 'ASC';
break;
}
case 2: /* По-убыванию */
{
$order_direction = 'DESC';
break;
}
default: /* по умолчанию */
{
$order_direction = 'ASC';
break;
}
}
/* Поле сортировки */
$sort_field = to_int($_GET['sort_by_field']);
switch ($sort_field)
{
case 1: /* По имени */
{
$param['items_field_order'] = 'shop_items_catalog_name';
$param['items_order'] = $order_direction;
$external_propertys['sort_by_field'] = $sort_field;
$external_propertys['order_direction'] = $order_direction;
break;
}
case 2: /* По цене */
{
//$param['items_field_order'] = 'shop_items_catalog_price';
$param['items_field_order'] = 'item_price_absolute';
$param['items_order'] = $order_direction;
$external_propertys['sort_by_field'] = $sort_field;
$external_propertys['order_direction'] = $order_direction;
break;
}
case 3: /* По оценке*/
{
$param['items_field_order'] = 'shop_comment_grade';
$param['items_order'] = $order_direction;
$external_propertys['sort_by_field'] = $sort_field;
$external_propertys['order_direction'] = $order_direction;
break;
}
}
// Задан фильтр и/или сортировка по цене
if ($price_from > 0 || $price_to > 0 || $sort_field == 2)
{
// Получаем список валют магазина
$currency_result = $shop->GetAllCurrency();
$query_currency_switch = 'shop_items_catalog_price';
if(isset($param['sql_external_select']))
{
$param['sql_external_select'] .= ', shop_discount_table.shop_discount_percent';
}
else
{
$param['sql_external_select'] = ', shop_discount_table.shop_discount_percent';
}
// Цикл по валютам магазина
while ($currency_row = mysql_fetch_assoc($currency_result))
{
// Получаем коэффициент пересчета для каждой валюты
$currency_coefficient = $shop->GetCurrencyCoefficientToShopCurrency($currency_row['shop_currency_id'], $shop_row['shop_currency_id']);
$query_currency_switch = "IF (shop_items_catalog_table.shop_currency_id = {$currency_row['shop_currency_id']}, IF (shop_discount_table.shop_discount_percent, shop_items_catalog_price * (100 - shop_discount_table.shop_discount_percent) * $currency_coefficient / 100, shop_items_catalog_table.shop_items_catalog_price * $currency_coefficient), $query_currency_switch)";
}
$param['sql_external_select'] .= ', ' . $query_currency_switch . ' AS item_price_absolute';
$current_date = date('Y-m-d H:i:s');
if(!isset($param['select_discount']))
{
if(isset($param['sql_from']))
{
$param['sql_from'] .= "LEFT JOIN shop_item_discount_table ON (shop_items_catalog_table.shop_items_catalog_item_id = shop_item_discount_table.shop_items_catalog_item_id) LEFT JOIN shop_discount_table ON (shop_item_discount_table.shop_discount_id = shop_discount_table.shop_discount_id AND (shop_discount_table.shop_discount_to >= '$current_date' OR shop_discount_table.shop_discount_to ='0000-00-00 00:00:00') AND shop_discount_table.shop_discount_from <= '$current_date')";
}
else
{
$param['sql_from'] = "LEFT JOIN shop_item_discount_table ON (shop_items_catalog_table.shop_items_catalog_item_id = shop_item_discount_table.shop_items_catalog_item_id) LEFT JOIN shop_discount_table ON (shop_item_discount_table.shop_discount_id = shop_discount_table.shop_discount_id AND (shop_discount_table.shop_discount_to >= '$current_date' OR shop_discount_table.shop_discount_to ='0000-00-00 00:00:00') AND shop_discount_table.shop_discount_from <= '$current_date')";
}
}
}
/* Обработка дополнительных свойств.
Получаем список свойств, разрешенных для отображения в данной группе и в фильтре */
$resource_properties = $shop->GetPropertiesOfGroupForXml($current_shop_id, $param['current_group_id']);
if ($resource_properties)
{
$element['type'] = 0; /* 0 - основное св-во, 1 - дополнительное */
/* Префикс, если нужен. */
$element['prefix'] = ' AND ('; // префикс
/* ОСТАВЛЯЕТЕ БЕЗ ИЗМЕНЕНИЙ, ЭТО НУЖНО ДЛЯ СОРТИРОВКИ */
$element['name'] = ''; // Имя
/* поля для основного св-ва, если тип = 1, то не указывается */
$element['if'] = ''; // Условие
/* Вот здесь передается ID доп. св-ва, по которому производится сортировка.
ID ВАШЕГО ПОЛЯ УКАЗЫВАЕТЕ ЗДЕСЬ */
$element['value'] = ''; /* Значение поля (или параметра) */
$element['sufix'] = ' ';
/* Добавляем в общий список условий */
$param['select'][] = $element;
$count_condition = 0;
$property_xml = '';
$count_properties = mysql_num_rows($resource_properties);
// Массив идентификаторов доп. свойств, для которых задан тип отображения "Список - флажками"
$mas_key_list_checkbox = array();
for ($i = 0; $i < $count_properties; $i++)
{
$row = mysql_fetch_assoc($resource_properties);
$element['value'] = 0;
switch ($row['shop_list_of_properties_show_kind'])
{
case 1: // Поле ввода
case 2: // Список - списком
case 3: // Список - переключателями
case 5: // Флажок
{
/* Выбираем режим отображения */
$get_param = 'property_id_' . $row['shop_list_of_properties_id'];
if (isset($_GET[$get_param]))
{
if ($row['shop_list_of_properties_type'] == 0
|| $row['shop_list_of_properties_show_kind'] == 1)
{
if (to_str($_GET[$get_param]) !== '')
{
$element['value'] = quote_smart(to_str($_GET[$get_param]));
$external_propertys['property_id_' . to_int($row['shop_list_of_properties_id'])] = $element['value'];
$property_xml .= '&property_id_' . to_int($row['shop_list_of_properties_id']) . '=' . $element['value'];
//$element['value'] = '%' . $element['value'] . '%';
}
}
// Флажок
elseif($row['shop_list_of_properties_type'] == 7)
{
$element['value'] = 1;
$external_propertys['property_id_' . to_int($row['shop_list_of_properties_id'])] = $element['value'];
$property_xml .= '&property_id_' . to_int($row['shop_list_of_properties_id']) . '=' . $element['value'];
}
else
{
if (to_int($_GET[$get_param]) > 0)
{
$element['value'] = to_int($_GET[$get_param]);
$external_propertys['property_id_'.to_int($row['shop_list_of_properties_id'])] = $element['value'];
$property_xml .= '&property_id_'.to_int($row['shop_list_of_properties_id']).'='.$element['value'];
}
}
}
if ($element['value'])
{
/* Применять фильтр */
$external_propertys['apply_filter'] = true;
$element['property_id'] = to_int($row['shop_list_of_properties_id']);
$element['type'] = 1; /* 0 - основное св-во, 1 - дополнительное */
//$element['prefix'] = ''; /* префикс */
// Способ отображения "Поле ввода"
if ($row['shop_list_of_properties_show_kind'] == 1 && !is_numeric($_GET[$get_param]))
{
$element['value'] = '%' . $element['value'] . '%';
$element['if'] = ' LIKE '; /* Условие */
}
else
{
$element['if'] = '='; /* Условие */
}
$element['sufix'] = '';
if ($count_condition)
{
$element['prefix'] = ' OR '; /* префикс */
}
else
{
$element['prefix'] = ' '; /* префикс */
}
$count_condition++;
$param['select'][] = $element;
}
break;
}
case 4: // Тип отображения - список флажками
{
// Модуль "Списки" подключен и значенич доп. свойства не обработаны ранее
//if (class_exists('lists') && !in_array($row['lists_id'], $mas_key_list_checkbox))
if (class_exists('lists'))
{
//$mas_key_list_checkbox[] = $row['lists_id'];
$lists = & singleton('lists');
// Получаем информацию о элементах списка, который задан для доп. свойства
$list_items_resource = $lists->SelectListsItems($row['lists_id']);
$k = 0;
// Цикл по элементам списка
while($row_list_item = mysql_fetch_assoc($list_items_resource))
{
// Передано значение элемента списка. Формируем запрос.
if (isset($_GET['property_id_' . $row['shop_list_of_properties_id'] .'_item_id_' . $row_list_item['lists_items_id']]))
{
if ($count_condition || $k > 0)
{
$element['prefix'] = ' OR '; /* префикс */
}
else
{
$element['prefix'] = ' ';
}
$element['property_id'] = to_int($row['shop_list_of_properties_id']);
$element['type'] = 1; /* 0 - основное св-во, 1 - дополнительное */
$element['if'] = '='; /* Условие */
$element['value'] = $row_list_item['lists_items_id'];
$element['sufix'] = '';
$param['select'][] = $element;
/* Применять фильтр */
$external_propertys['apply_filter'] = true;
$external_propertys['property_id_' . to_int($row['shop_list_of_properties_id']) . '_item_id_' . $row_list_item['lists_items_id']] = $element['value'];
$property_xml .= '&property_id_' . to_int($row['shop_list_of_properties_id']) . '_item_id_' . $row_list_item['lists_items_id'] . '=' . $element['value'];
$k++;
}
}
// Задан фильтр по одному из значений списка
if ($k > 0)
{
$count_condition++;
}
}
break;
}
case 6: // Тип отображения - диапазон
{
$get_param_from = 'property_id_' . $row['shop_list_of_properties_id'] . '_from';
$get_param_to = 'property_id_' . $row['shop_list_of_properties_id'] . '_to';
if (isset($_GET[$get_param_from]) && mb_strlen($_GET[$get_param_from]) > 0)
{
$value = floatval($_GET[$get_param_from]);
/* Применять фильтр */
$external_propertys['apply_filter'] = true;
$external_propertys['property_id_'.to_int($row['shop_list_of_properties_id']) . '_from'] = $value;
$property_xml .= '&property_id_' . to_int($row['shop_list_of_properties_id']).'_from=' . $value;
$element['type'] = 1; /* 0 - основное св-во, 1 - дополнительное */
$element['property_id'] = to_int($row['shop_list_of_properties_id']);
$element['if'] = 'IS NOT NULL'; /* Условие */
$element['value'] = '';
$property_row = $shop->GetPropretyOfItems($element['property_id']);
if($property_row['shop_list_of_properties_type'] == 2)
{
$lists_id = to_int($property_row['lists_id']);
$lists = & singleton('lists');
$list_row = $lists->GetListItemsById($lists_id);
$in = array();
if (is_array($list_row) && count($list_row) > 0)
{
foreach ($list_row as $row_lists_items_value)
{
if ($row_lists_items_value['lists_items_value'] >= $value)
{
$in[] = $row_lists_items_value['lists_items_id'];
}
}
}
if(count($in) > 0)
{
$element['sufix'] = 'AND shop_properties_items_table.shop_properties_items_value - 0.0 IN ('.implode(',', $in).') ';
}
else
{
$element['sufix'] = "";
}
}
else
{
$element['sufix'] = " AND shop_properties_items_table.shop_properties_items_value - 0.0 >=$value";
}
if ($count_condition)
{
$element['prefix'] = ' OR '; /* префикс */
}
else
{
$element['prefix'] = ' '; /* префикс */
}
$param['select'][] = $element;
$count_condition++;
}
if (isset($_GET[$get_param_to]) && mb_strlen($_GET[$get_param_to]) > 0)
{
$value = floatval($_GET[$get_param_to]);
/* Применять фильтр */
$external_propertys['apply_filter'] = true;
$external_propertys['property_id_'.to_int($row['shop_list_of_properties_id']) . '_to'] = $value;
$property_xml .= '&property_id_'.to_int($row['shop_list_of_properties_id']).'_to='.$value;
$element['property_id'] = to_int($row['shop_list_of_properties_id']);
$element['type'] = 1; /* 0 - основное св-во, 1 - дополнительное */
$element['if'] = 'IS NOT NULL'; /* Условие */
$element['value'] = '';
$property_row = $shop->GetPropretyOfItems($element['property_id']);
if ($property_row['shop_list_of_properties_type'] == 2)
{
$lists_id = to_int($property_row['lists_id']);
$lists = & singleton('lists');
$list_row = $lists->GetListItemsById($lists_id);
$in = array();
if (is_array($list_row) && count($list_row) > 0)
{
foreach ($list_row as $row_lists_items_value)
{
if($row_lists_items_value['lists_items_value'] <= $value)
{
$in[] = $row_lists_items_value['lists_items_id'];
}
}
}
if(count($in) > 0)
{
$element['sufix'] = 'AND shop_properties_items_table.shop_properties_items_value - 0.0 IN ('.implode(',', $in).') ';
}
else
{
$element['sufix'] = "";
}
}
else
{
$element['sufix'] = "AND shop_properties_items_table.shop_properties_items_value - 0.0 <= $value";
}
if (!(isset($_GET[$get_param_from]) && mb_strlen($_GET[$get_param_from]) > 0))
{
if ($count_condition)
{
$element['prefix'] = ' OR '; /* префикс */
}
else
{
$element['prefix'] = ' '; /* префикс */
}
$count_condition++;
}
else
{
$element['prefix'] = ' AND ';
}
$param['select'][] = $element;
}
break;
}
case 7: // Список - список с множественным выбором
{
// Модуль "Списки" подключен и передан массив значений доп. свойства
if (class_exists('lists') && isset($_GET['property_id_' . $row['shop_list_of_properties_id']]) && is_array($_GET['property_id_' . $row['shop_list_of_properties_id']]))
{
$lists = & singleton('lists');
// Получаем информацию о элементах списка, который задан для доп. свойства
$list_items_resource = $lists->SelectListsItems($row['lists_id']);
$k = 0;
// Цикл по элементам списка
while($row_list_item = mysql_fetch_assoc($list_items_resource))
{
// Передано значение элемента списка. Формируем запрос.
if (in_array($row_list_item['lists_items_id'], $_GET['property_id_' . $row['shop_list_of_properties_id']]))
{
if ($count_condition || $k > 0)
{
$element['prefix'] = ' OR '; /* префикс */
}
else
{
$element['prefix'] = ' ';
}
$element['property_id'] = to_int($row['shop_list_of_properties_id']);
$element['type'] = 1; /* 0 - основное св-во, 1 - дополнительное */
$element['if'] = '='; /* Условие */
$element['value'] = $row_list_item['lists_items_id'];
$element['sufix'] = '';
$param['select'][] = $element;
$external_propertys['property_id_' . to_int($row['shop_list_of_properties_id']) . '_item_id_' . $row_list_item['lists_items_id']] = $element['value'];
$property_xml .= '&property_id_' . to_int($row['shop_list_of_properties_id']) . '_item_id_' . $row_list_item['lists_items_id'] . '=' . $element['value'];
$k++;
}
}
// Задан фильтр по одному из значений списка
if ($k > 0)
{
$count_condition++;
}
}
break;
}
}
}
if (!$count_condition)
{
$element['prefix'] = ' 1'; /* префикс */
}
else
{
$element['prefix'] = ''; // префикс
}
/* добавляем конечный элемент, содержащий HAVING */
$element['type'] = 0; /* 0 - основное св-во, 1 - дополнительное */
/* ОСТАВЛЯЕТЕ БЕЗ ИЗМЕНЕНИЙ, ЭТО НУЖНО ДЛЯ СОРТИРОВКИ */
$element['name'] = ''; /* Имя */
/* поля для основного св-ва, если тип = 1, то не указывается */
$element['if'] = ''; /* Условие */
/* Вот здесь передается ID доп. св-ва, по которому производится сортировка.
ID ВАШЕГО ПОЛЯ УКАЗЫВАЕТЕ ЗДЕСЬ */
$element['value'] = ''; // Значение поля (или параметра)
//if ($count_condition != 0 && ($price_from > 0 || $price_to >0))
if ($count_condition != 0)
{
$param['sql_group_by'] = 'GROUP BY shop_items_catalog_table.shop_items_catalog_item_id';
$param['sql_having'] = "HAVING COUNT(shop_properties_items_table.shop_properties_items_id) = {$count_condition}";
}
else
{
$param['sql_having'] = 'HAVING 1 ';
}
$element['sufix'] = ' ) ';
/* Добавляем в общий список условий */
$param['select'][] = $element;
}
else
{
$param['sql_having'] = 'HAVING 1 ';
}
if ($price_from > 0)
{
$param['sql_having'] .= ' AND item_price_absolute >= ' . $price_from;
}
if ($price_to > 0)
{
$param['sql_having'] .= ' AND item_price_absolute <= ' . $price_to;
}
/* добавляем конечный элемент, содержащий HAVING */
/*$element['type'] = 0; // 0 - основное св-во, 1 - дополнительное
$element['prefix'] = ' AND';
$element['name'] = 'shop_items_catalog_table.shop_shops_id';
$element['if'] = '=';
$element['value'] = $current_shop_id; // Значение поля (или параметра)
$element['sufix'] = '';
$param['select'][] = $element;*/
if (!empty($property_xml))
{
$external_propertys['property_xml'] = $property_xml;
}
// Если передано имя тэга - фильтруем
if (isset($GLOBALS['shop_item_path']['tag_name']))
{
if (class_exists('Tag'))
{
$oTag = & singleton('Tag');
$tag_row = $oTag->GetTagByPath($GLOBALS['shop_item_path']['tag_name']);
$param['tags'] = array($tag_row['tag_id']);
// При выводе тэгов вывод элементов ведется из всех групп
//$param['current_group_id'] = false;
}
}
// При выводе списка товаров получать подробное описание каждого товара не нужно
$param['show_text'] = true;
// При выводе списка товаров получать сопутствующие товары не нужно
$param['xml_show_tying_products'] = true;
// Запрещаем передачу в XML свойств групп
$param['xml_show_group_property'] = true;
$param['xml_show_all_sellers'] = true;
/* $param['sql_from'] = 'LEFT JOIN shop_prices_to_item_table ON shop_prices_to_item_table.shop_items_catalog_item_id = shop_items_catalog_table.shop_items_catalog_item_id';
$element = array();
$element['type'] = 0;
$element['prefix'] = ' AND';
$element['name'] = 'shop_prices_to_item_id ';
$element['if'] = 'IS NOT NULL';
$element['value'] = '';
$element['sufix'] = '';
$param['select'][] = $element; */
/*$element['type'] = 1;
$element['property_id'] = 153;
$element['prefix'] = ' AND (';
$element['if'] = '!=';
$element['value'] = "''";
$element['sufix'] = " AND CONVERT(CONCAT(SUBSTRING(shop_properties_items_value, 7, 4), CHAR(45), SUBSTRING(shop_properties_items_value, 4, 2), CHAR(45), SUBSTRING(shop_properties_items_value, 1, 2)), DATETIME) > '". date('Y-m-d H:i:s') ."')";
$param['select'][] = $element;*/
$shop->ShowShop($current_shop_id, $xsl_catalog, $param, $external_propertys);
}
else
{
/* Вывод конкретного элемент */
//$param['show_catalog_item_type'] = array('active', 'inactive');
$param['xml_show_group_type'] = 'tree';
$param['current_group_id'] = $GLOBALS['shop_item_path']['group'];
// Запрещаем передачу в XML свойств групп
$param['xml_show_group_property'] = false;
/* Вывод конкретного элемента */
$shop->ShowItem($GLOBALS['shop_item_path']['item'], $xsl_item, $param, $external_propertys);
/* Вывод рекламы прочих товаров */
$external_propertys['this_item_id'] = $GLOBALS['shop_item_path']['item'];
$xsl_catalog = 'МагазинКаталогТоваровРеклама';
$param['items_on_page'] = 10;
$param['items_order'] = 'rand';
$shop->ShowShop($current_shop_id, $xsl_catalog, $param, $external_propertys);
}
}
?>
function SetGroups($mas_groups, $set)
{
$mas_groups = to_array($mas_groups);
foreach ($mas_groups as $key=>$value)
{
foreach ($value as $key1=>$value1)
{
$set[] = $value1;
if ($value1 == $key)
{
$set[] = $key;
SetGroups($mas_groups, $set);
}
}
}
return $set;
}
$xsl_catalog = to_str($GLOBALS['LA']['xsl_catalog']);
$xsl_item = to_str($GLOBALS['LA']['xsl_item']);
$current_shop_id = to_int($GLOBALS['LA']['shop_id']);
$param = array();
$shop = & singleton('shop');
if ($GLOBALS['shop_item_path'] != false)
{
$external_propertys = array();
if (class_exists("SiteUsers"))
{
/* Получаем id текущего пользователя сайта */
$SiteUsers = & singleton('SiteUsers');
$site_user_id = $SiteUsers->GetCurrentSiteUser();
$param['user_id'] = $site_user_id;
$external_propertys['user_id'] = $site_user_id;
}
else
{
$site_user_id = 0;
$external_propertys['user_id'] = 0;
}
// Если добавление комментария
if (isset($_POST['submit_comment']) && !empty($GLOBALS['shop_item_path']['item'])
&& isset($_POST['email']) && isset($_POST['author']) && $_POST['email'] == 'comment@localhost.ru' && $_POST['author'] == '')
{
/* Проверяем CAPCHA*/
$Captcha = new Captcha();
$xmlData = '<?xml version="1.0" encoding="UTF-8"?>' . "\n";
$xmlData .= '<document>' . "\n";
if ($site_user_id > 0
|| $Captcha->ValidCaptcha(to_str($_POST['captcha_key']), to_str($_POST['captcha_keystring'])))
{
$param['shop_items_catalog_item_id'] = $GLOBALS['shop_item_path']['item'];
$param['shop_comment_user_name'] = to_str($_REQUEST['shop_comment_user_name']);
$param['shop_comment_user_email'] = to_str($_REQUEST['shop_comment_user_email']);
$param['shop_comment_subject'] = to_str($_REQUEST['shop_comment_subject']);
$param['shop_comment_text'] = to_str($_REQUEST['shop_comment_text']);
$param['shop_comment_grade'] = to_int($_REQUEST['shop_comment_grade']);
$param['shop_comment_date_time'] = date("Y-m-d H:i:s");
/* Активность/неактивность комментария */
$shop_row = $shop->GetShop($current_shop_id);
if ($shop_row)
{
$param['shop_comment_active'] = to_int($shop_row['shop_comment_active']);
}
else
{
$param['shop_comment_active'] = false;
}
$external_propertys['comment_is_active'] = $param['shop_comment_active'];
// Если есть модуль "Пользователи сайта", получим текущего пользователя
if (class_exists('SiteUsers'))
{
$SiteUsers = & singleton('SiteUsers');
$param['site_users_id'] = $SiteUsers->GetCurrentSiteUser();
}
else
{
$param['site_users_id'] = 0;
}
$shop_comment_id = $shop->InsertComment($param);
// Задан XSL для формирования письма администратору о добавлении комментария к товару
if (to_str($GLOBALS['LA']['xsl_add_comment_letter_to_admin']) != '')
{
// Формируем XML для комментария
$xmlData .= $shop->GenXml4Comment($shop_comment_id);
$xmlData .= '</document>' . "\n";
$xsl = new xsl();
// Формируем текст письма администратору
$message = $xsl->build($xmlData, $GLOBALS['LA']['xsl_add_comment_letter_to_admin']);
// Формат письма - текст
if (to_int($GLOBALS['LA']['comment_mail_type']) == 0)
{
$comment_mail_type = 'text/plain';
}
else
{
$comment_mail_type = 'text/html';
}
$subject = $GLOBALS['MSG_shops']['subject_report_for_comment'];
$kernel = & singleton('kernel');
// Получаем e-mail куратора магазина
$email_to = to_str($shop_row['shop_shops_admin_mail']);
if (!empty($email_to))
{
$kernel->SendMailWithFile($email_to, EMAIL_TO, $subject, $message, array(), $comment_mail_type);
}
}
}
else
{
/* Неправильно введен код изображенный на картинке */
$external_propertys['error'] = 1;
/* Запоминаем значения */
$external_propertys['shop_comment_user_name'] = strip_tags(to_str($_REQUEST['shop_comment_user_name']));
$external_propertys['shop_comment_user_email'] = strip_tags(to_str($_REQUEST['shop_comment_user_email']));
$external_propertys['shop_comment_subject'] = strip_tags(to_str($_REQUEST['shop_comment_subject']));
$external_propertys['shop_comment_text'] = strip_tags(to_str($_REQUEST['shop_comment_text']));
$external_propertys['shop_comment_grade'] = to_int($_REQUEST['shop_comment_grade']);
$external_propertys['shop_comment_date_time'] = date("Y-m-d H:i:s");
}
}
/* Вывод списка */
if (!$GLOBALS['shop_item_path']['item'])
{
$param['current_group_id'] = $GLOBALS['shop_item_path']['group']; // корневая группа
/* Определяем номер элемента, с которого начинается показ в текущей группе */
$page = end($GLOBALS['URL_ARRAY']);
$page = to_str($page);
$shop_row = $shop->GetShop($current_shop_id);
if ($shop_row)
{
if (!isset($GLOBALS['shop_item_path']['tag_name'])) {
$param['items_on_page'] = 25;
$items_on_page = 25;
}
else $items_on_page = $shop_row['shop_items_on_page'];
}
else
{
$items_on_page = 10;
}
/*
Порядок сортировки ('Asc' - по возрастанию, 'Desc' - по убыванию, 'Rand' - произвольный порядок)
$param['items_order'] = 'Asc';
Поле, по которому сортируем (наименование элемента)
$param['items_field_order'] = 'shop_items_catalog_name';
*/
if (isset($_GET['all_group']))
{
// Выводим из всех групп
$param['current_group_id'] = false;
$external_propertys['property_xml'] = "&all_group=1";
$external_propertys['apply_filter'] = true;
}
/* Ограничиваем по производителю */
if (to_int($_GET['producer_id']) > 0)
{
$element['type'] = 0; // 0 - основное св-во, 1 - дополнительное
$element['name'] = 'shop_producers_list_id';
$element['prefix'] = 'AND'; // префикс
$element['if'] = '='; // Условие
$element['value'] = to_int($_GET['producer_id']);
$element['sufix'] = '';
$param['select'][] = $element;
$external_propertys['producer_id'] = to_int($_GET['producer_id']);
/* Применять фильтр */
$external_propertys['apply_filter'] = true;
}
/* Ограничиваем по продавцу */
if (to_int($_GET['saller_id']) > 0)
{
$element['type'] = 0; // 0 - основное св-во, 1 - дополнительное
$element['name'] = 'shop_sallers_id';
$element['prefix'] = 'AND'; // префикс
$element['if'] = '='; // Условие
$element['value'] = to_int($_GET['saller_id']);
$element['sufix'] = '';
$param['select'][] = $element;
$external_propertys['saller_id'] = to_int($_GET['saller_id']);
/* Применять фильтр */
$external_propertys['apply_filter'] = true;
}
$price_from = str_replace(',', '.', to_float($_GET['price_from']));
/* Ограничиваем по цене ОТ */
if ($price_from > 0)
{
$external_propertys['price_from'] = $price_from;
/* Применять фильтр */
$external_propertys['apply_filter'] = true;
}
$price_to = str_replace(',', '.', to_float($_GET['price_to']));
/* Ограничиваем по цене ДО */
if ($price_to > 0)
{
$external_propertys['price_to'] = $price_to;
/* Применять фильтр */
$external_propertys['apply_filter'] = true;
}
/* Число элементов на странице */
$on_page = to_int($_GET['on_page']);
if ($on_page > 0 && $on_page < 150)
{
$param['items_on_page'] = $on_page;
$external_propertys['on_page'] = $on_page;
/* Применять фильтр */
$external_propertys['apply_filter'] = true;
}
// Определяем номер страницы.
if ($on_page)
{
$items_on_page = $on_page;
}
if (ereg("^page-([0-9]*)$", $page, $regs) && to_int($regs[1]) > 1)
{
/* Страница умножается на кол-во элементов, выводимых на страницу */
$items_begin = ($regs[1] - 1) * $items_on_page;
}
else
{
$items_begin = 0;
}
$param['items_begin'] = $items_begin;
/* Направление сортировки, 0 - по-возрастанию, 1 - по-убыванию */
$order_direction = to_int($_GET['order_direction']);
switch ($order_direction)
{
case 1: /* По-возрастанию */
{
$order_direction = 'ASC';
break;
}
case 2: /* По-убыванию */
{
$order_direction = 'DESC';
break;
}
default: /* по умолчанию */
{
$order_direction = 'ASC';
break;
}
}
/* Поле сортировки */
$sort_field = to_int($_GET['sort_by_field']);
switch ($sort_field)
{
case 1: /* По имени */
{
$param['items_field_order'] = 'shop_items_catalog_name';
$param['items_order'] = $order_direction;
$external_propertys['sort_by_field'] = $sort_field;
$external_propertys['order_direction'] = $order_direction;
break;
}
case 2: /* По цене */
{
//$param['items_field_order'] = 'shop_items_catalog_price';
$param['items_field_order'] = 'item_price_absolute';
$param['items_order'] = $order_direction;
$external_propertys['sort_by_field'] = $sort_field;
$external_propertys['order_direction'] = $order_direction;
break;
}
case 3: /* По оценке*/
{
$param['items_field_order'] = 'shop_comment_grade';
$param['items_order'] = $order_direction;
$external_propertys['sort_by_field'] = $sort_field;
$external_propertys['order_direction'] = $order_direction;
break;
}
}
// Задан фильтр и/или сортировка по цене
if ($price_from > 0 || $price_to > 0 || $sort_field == 2)
{
// Получаем список валют магазина
$currency_result = $shop->GetAllCurrency();
$query_currency_switch = 'shop_items_catalog_price';
if(isset($param['sql_external_select']))
{
$param['sql_external_select'] .= ', shop_discount_table.shop_discount_percent';
}
else
{
$param['sql_external_select'] = ', shop_discount_table.shop_discount_percent';
}
// Цикл по валютам магазина
while ($currency_row = mysql_fetch_assoc($currency_result))
{
// Получаем коэффициент пересчета для каждой валюты
$currency_coefficient = $shop->GetCurrencyCoefficientToShopCurrency($currency_row['shop_currency_id'], $shop_row['shop_currency_id']);
$query_currency_switch = "IF (shop_items_catalog_table.shop_currency_id = {$currency_row['shop_currency_id']}, IF (shop_discount_table.shop_discount_percent, shop_items_catalog_price * (100 - shop_discount_table.shop_discount_percent) * $currency_coefficient / 100, shop_items_catalog_table.shop_items_catalog_price * $currency_coefficient), $query_currency_switch)";
}
$param['sql_external_select'] .= ', ' . $query_currency_switch . ' AS item_price_absolute';
$current_date = date('Y-m-d H:i:s');
if(!isset($param['select_discount']))
{
if(isset($param['sql_from']))
{
$param['sql_from'] .= "LEFT JOIN shop_item_discount_table ON (shop_items_catalog_table.shop_items_catalog_item_id = shop_item_discount_table.shop_items_catalog_item_id) LEFT JOIN shop_discount_table ON (shop_item_discount_table.shop_discount_id = shop_discount_table.shop_discount_id AND (shop_discount_table.shop_discount_to >= '$current_date' OR shop_discount_table.shop_discount_to ='0000-00-00 00:00:00') AND shop_discount_table.shop_discount_from <= '$current_date')";
}
else
{
$param['sql_from'] = "LEFT JOIN shop_item_discount_table ON (shop_items_catalog_table.shop_items_catalog_item_id = shop_item_discount_table.shop_items_catalog_item_id) LEFT JOIN shop_discount_table ON (shop_item_discount_table.shop_discount_id = shop_discount_table.shop_discount_id AND (shop_discount_table.shop_discount_to >= '$current_date' OR shop_discount_table.shop_discount_to ='0000-00-00 00:00:00') AND shop_discount_table.shop_discount_from <= '$current_date')";
}
}
}
/* Обработка дополнительных свойств.
Получаем список свойств, разрешенных для отображения в данной группе и в фильтре */
$resource_properties = $shop->GetPropertiesOfGroupForXml($current_shop_id, $param['current_group_id']);
if ($resource_properties)
{
$element['type'] = 0; /* 0 - основное св-во, 1 - дополнительное */
/* Префикс, если нужен. */
$element['prefix'] = ' AND ('; // префикс
/* ОСТАВЛЯЕТЕ БЕЗ ИЗМЕНЕНИЙ, ЭТО НУЖНО ДЛЯ СОРТИРОВКИ */
$element['name'] = ''; // Имя
/* поля для основного св-ва, если тип = 1, то не указывается */
$element['if'] = ''; // Условие
/* Вот здесь передается ID доп. св-ва, по которому производится сортировка.
ID ВАШЕГО ПОЛЯ УКАЗЫВАЕТЕ ЗДЕСЬ */
$element['value'] = ''; /* Значение поля (или параметра) */
$element['sufix'] = ' ';
/* Добавляем в общий список условий */
$param['select'][] = $element;
$count_condition = 0;
$property_xml = '';
$count_properties = mysql_num_rows($resource_properties);
// Массив идентификаторов доп. свойств, для которых задан тип отображения "Список - флажками"
$mas_key_list_checkbox = array();
for ($i = 0; $i < $count_properties; $i++)
{
$row = mysql_fetch_assoc($resource_properties);
$element['value'] = 0;
switch ($row['shop_list_of_properties_show_kind'])
{
case 1: // Поле ввода
case 2: // Список - списком
case 3: // Список - переключателями
case 5: // Флажок
{
/* Выбираем режим отображения */
$get_param = 'property_id_' . $row['shop_list_of_properties_id'];
if (isset($_GET[$get_param]))
{
if ($row['shop_list_of_properties_type'] == 0
|| $row['shop_list_of_properties_show_kind'] == 1)
{
if (to_str($_GET[$get_param]) !== '')
{
$element['value'] = quote_smart(to_str($_GET[$get_param]));
$external_propertys['property_id_' . to_int($row['shop_list_of_properties_id'])] = $element['value'];
$property_xml .= '&property_id_' . to_int($row['shop_list_of_properties_id']) . '=' . $element['value'];
//$element['value'] = '%' . $element['value'] . '%';
}
}
// Флажок
elseif($row['shop_list_of_properties_type'] == 7)
{
$element['value'] = 1;
$external_propertys['property_id_' . to_int($row['shop_list_of_properties_id'])] = $element['value'];
$property_xml .= '&property_id_' . to_int($row['shop_list_of_properties_id']) . '=' . $element['value'];
}
else
{
if (to_int($_GET[$get_param]) > 0)
{
$element['value'] = to_int($_GET[$get_param]);
$external_propertys['property_id_'.to_int($row['shop_list_of_properties_id'])] = $element['value'];
$property_xml .= '&property_id_'.to_int($row['shop_list_of_properties_id']).'='.$element['value'];
}
}
}
if ($element['value'])
{
/* Применять фильтр */
$external_propertys['apply_filter'] = true;
$element['property_id'] = to_int($row['shop_list_of_properties_id']);
$element['type'] = 1; /* 0 - основное св-во, 1 - дополнительное */
//$element['prefix'] = ''; /* префикс */
// Способ отображения "Поле ввода"
if ($row['shop_list_of_properties_show_kind'] == 1 && !is_numeric($_GET[$get_param]))
{
$element['value'] = '%' . $element['value'] . '%';
$element['if'] = ' LIKE '; /* Условие */
}
else
{
$element['if'] = '='; /* Условие */
}
$element['sufix'] = '';
if ($count_condition)
{
$element['prefix'] = ' OR '; /* префикс */
}
else
{
$element['prefix'] = ' '; /* префикс */
}
$count_condition++;
$param['select'][] = $element;
}
break;
}
case 4: // Тип отображения - список флажками
{
// Модуль "Списки" подключен и значенич доп. свойства не обработаны ранее
//if (class_exists('lists') && !in_array($row['lists_id'], $mas_key_list_checkbox))
if (class_exists('lists'))
{
//$mas_key_list_checkbox[] = $row['lists_id'];
$lists = & singleton('lists');
// Получаем информацию о элементах списка, который задан для доп. свойства
$list_items_resource = $lists->SelectListsItems($row['lists_id']);
$k = 0;
// Цикл по элементам списка
while($row_list_item = mysql_fetch_assoc($list_items_resource))
{
// Передано значение элемента списка. Формируем запрос.
if (isset($_GET['property_id_' . $row['shop_list_of_properties_id'] .'_item_id_' . $row_list_item['lists_items_id']]))
{
if ($count_condition || $k > 0)
{
$element['prefix'] = ' OR '; /* префикс */
}
else
{
$element['prefix'] = ' ';
}
$element['property_id'] = to_int($row['shop_list_of_properties_id']);
$element['type'] = 1; /* 0 - основное св-во, 1 - дополнительное */
$element['if'] = '='; /* Условие */
$element['value'] = $row_list_item['lists_items_id'];
$element['sufix'] = '';
$param['select'][] = $element;
/* Применять фильтр */
$external_propertys['apply_filter'] = true;
$external_propertys['property_id_' . to_int($row['shop_list_of_properties_id']) . '_item_id_' . $row_list_item['lists_items_id']] = $element['value'];
$property_xml .= '&property_id_' . to_int($row['shop_list_of_properties_id']) . '_item_id_' . $row_list_item['lists_items_id'] . '=' . $element['value'];
$k++;
}
}
// Задан фильтр по одному из значений списка
if ($k > 0)
{
$count_condition++;
}
}
break;
}
case 6: // Тип отображения - диапазон
{
$get_param_from = 'property_id_' . $row['shop_list_of_properties_id'] . '_from';
$get_param_to = 'property_id_' . $row['shop_list_of_properties_id'] . '_to';
if (isset($_GET[$get_param_from]) && mb_strlen($_GET[$get_param_from]) > 0)
{
$value = floatval($_GET[$get_param_from]);
/* Применять фильтр */
$external_propertys['apply_filter'] = true;
$external_propertys['property_id_'.to_int($row['shop_list_of_properties_id']) . '_from'] = $value;
$property_xml .= '&property_id_' . to_int($row['shop_list_of_properties_id']).'_from=' . $value;
$element['type'] = 1; /* 0 - основное св-во, 1 - дополнительное */
$element['property_id'] = to_int($row['shop_list_of_properties_id']);
$element['if'] = 'IS NOT NULL'; /* Условие */
$element['value'] = '';
$property_row = $shop->GetPropretyOfItems($element['property_id']);
if($property_row['shop_list_of_properties_type'] == 2)
{
$lists_id = to_int($property_row['lists_id']);
$lists = & singleton('lists');
$list_row = $lists->GetListItemsById($lists_id);
$in = array();
if (is_array($list_row) && count($list_row) > 0)
{
foreach ($list_row as $row_lists_items_value)
{
if ($row_lists_items_value['lists_items_value'] >= $value)
{
$in[] = $row_lists_items_value['lists_items_id'];
}
}
}
if(count($in) > 0)
{
$element['sufix'] = 'AND shop_properties_items_table.shop_properties_items_value - 0.0 IN ('.implode(',', $in).') ';
}
else
{
$element['sufix'] = "";
}
}
else
{
$element['sufix'] = " AND shop_properties_items_table.shop_properties_items_value - 0.0 >=$value";
}
if ($count_condition)
{
$element['prefix'] = ' OR '; /* префикс */
}
else
{
$element['prefix'] = ' '; /* префикс */
}
$param['select'][] = $element;
$count_condition++;
}
if (isset($_GET[$get_param_to]) && mb_strlen($_GET[$get_param_to]) > 0)
{
$value = floatval($_GET[$get_param_to]);
/* Применять фильтр */
$external_propertys['apply_filter'] = true;
$external_propertys['property_id_'.to_int($row['shop_list_of_properties_id']) . '_to'] = $value;
$property_xml .= '&property_id_'.to_int($row['shop_list_of_properties_id']).'_to='.$value;
$element['property_id'] = to_int($row['shop_list_of_properties_id']);
$element['type'] = 1; /* 0 - основное св-во, 1 - дополнительное */
$element['if'] = 'IS NOT NULL'; /* Условие */
$element['value'] = '';
$property_row = $shop->GetPropretyOfItems($element['property_id']);
if ($property_row['shop_list_of_properties_type'] == 2)
{
$lists_id = to_int($property_row['lists_id']);
$lists = & singleton('lists');
$list_row = $lists->GetListItemsById($lists_id);
$in = array();
if (is_array($list_row) && count($list_row) > 0)
{
foreach ($list_row as $row_lists_items_value)
{
if($row_lists_items_value['lists_items_value'] <= $value)
{
$in[] = $row_lists_items_value['lists_items_id'];
}
}
}
if(count($in) > 0)
{
$element['sufix'] = 'AND shop_properties_items_table.shop_properties_items_value - 0.0 IN ('.implode(',', $in).') ';
}
else
{
$element['sufix'] = "";
}
}
else
{
$element['sufix'] = "AND shop_properties_items_table.shop_properties_items_value - 0.0 <= $value";
}
if (!(isset($_GET[$get_param_from]) && mb_strlen($_GET[$get_param_from]) > 0))
{
if ($count_condition)
{
$element['prefix'] = ' OR '; /* префикс */
}
else
{
$element['prefix'] = ' '; /* префикс */
}
$count_condition++;
}
else
{
$element['prefix'] = ' AND ';
}
$param['select'][] = $element;
}
break;
}
case 7: // Список - список с множественным выбором
{
// Модуль "Списки" подключен и передан массив значений доп. свойства
if (class_exists('lists') && isset($_GET['property_id_' . $row['shop_list_of_properties_id']]) && is_array($_GET['property_id_' . $row['shop_list_of_properties_id']]))
{
$lists = & singleton('lists');
// Получаем информацию о элементах списка, который задан для доп. свойства
$list_items_resource = $lists->SelectListsItems($row['lists_id']);
$k = 0;
// Цикл по элементам списка
while($row_list_item = mysql_fetch_assoc($list_items_resource))
{
// Передано значение элемента списка. Формируем запрос.
if (in_array($row_list_item['lists_items_id'], $_GET['property_id_' . $row['shop_list_of_properties_id']]))
{
if ($count_condition || $k > 0)
{
$element['prefix'] = ' OR '; /* префикс */
}
else
{
$element['prefix'] = ' ';
}
$element['property_id'] = to_int($row['shop_list_of_properties_id']);
$element['type'] = 1; /* 0 - основное св-во, 1 - дополнительное */
$element['if'] = '='; /* Условие */
$element['value'] = $row_list_item['lists_items_id'];
$element['sufix'] = '';
$param['select'][] = $element;
$external_propertys['property_id_' . to_int($row['shop_list_of_properties_id']) . '_item_id_' . $row_list_item['lists_items_id']] = $element['value'];
$property_xml .= '&property_id_' . to_int($row['shop_list_of_properties_id']) . '_item_id_' . $row_list_item['lists_items_id'] . '=' . $element['value'];
$k++;
}
}
// Задан фильтр по одному из значений списка
if ($k > 0)
{
$count_condition++;
}
}
break;
}
}
}
if (!$count_condition)
{
$element['prefix'] = ' 1'; /* префикс */
}
else
{
$element['prefix'] = ''; // префикс
}
/* добавляем конечный элемент, содержащий HAVING */
$element['type'] = 0; /* 0 - основное св-во, 1 - дополнительное */
/* ОСТАВЛЯЕТЕ БЕЗ ИЗМЕНЕНИЙ, ЭТО НУЖНО ДЛЯ СОРТИРОВКИ */
$element['name'] = ''; /* Имя */
/* поля для основного св-ва, если тип = 1, то не указывается */
$element['if'] = ''; /* Условие */
/* Вот здесь передается ID доп. св-ва, по которому производится сортировка.
ID ВАШЕГО ПОЛЯ УКАЗЫВАЕТЕ ЗДЕСЬ */
$element['value'] = ''; // Значение поля (или параметра)
//if ($count_condition != 0 && ($price_from > 0 || $price_to >0))
if ($count_condition != 0)
{
$param['sql_group_by'] = 'GROUP BY shop_items_catalog_table.shop_items_catalog_item_id';
$param['sql_having'] = "HAVING COUNT(shop_properties_items_table.shop_properties_items_id) = {$count_condition}";
}
else
{
$param['sql_having'] = 'HAVING 1 ';
}
$element['sufix'] = ' ) ';
/* Добавляем в общий список условий */
$param['select'][] = $element;
}
else
{
$param['sql_having'] = 'HAVING 1 ';
}
if ($price_from > 0)
{
$param['sql_having'] .= ' AND item_price_absolute >= ' . $price_from;
}
if ($price_to > 0)
{
$param['sql_having'] .= ' AND item_price_absolute <= ' . $price_to;
}
/* добавляем конечный элемент, содержащий HAVING */
/*$element['type'] = 0; // 0 - основное св-во, 1 - дополнительное
$element['prefix'] = ' AND';
$element['name'] = 'shop_items_catalog_table.shop_shops_id';
$element['if'] = '=';
$element['value'] = $current_shop_id; // Значение поля (или параметра)
$element['sufix'] = '';
$param['select'][] = $element;*/
if (!empty($property_xml))
{
$external_propertys['property_xml'] = $property_xml;
}
// Если передано имя тэга - фильтруем
if (isset($GLOBALS['shop_item_path']['tag_name']))
{
if (class_exists('Tag'))
{
$oTag = & singleton('Tag');
$tag_row = $oTag->GetTagByPath($GLOBALS['shop_item_path']['tag_name']);
$param['tags'] = array($tag_row['tag_id']);
// При выводе тэгов вывод элементов ведется из всех групп
//$param['current_group_id'] = false;
}
}
// При выводе списка товаров получать подробное описание каждого товара не нужно
$param['show_text'] = true;
// При выводе списка товаров получать сопутствующие товары не нужно
$param['xml_show_tying_products'] = true;
// Запрещаем передачу в XML свойств групп
$param['xml_show_group_property'] = true;
$param['xml_show_all_sellers'] = true;
/* $param['sql_from'] = 'LEFT JOIN shop_prices_to_item_table ON shop_prices_to_item_table.shop_items_catalog_item_id = shop_items_catalog_table.shop_items_catalog_item_id';
$element = array();
$element['type'] = 0;
$element['prefix'] = ' AND';
$element['name'] = 'shop_prices_to_item_id ';
$element['if'] = 'IS NOT NULL';
$element['value'] = '';
$element['sufix'] = '';
$param['select'][] = $element; */
/*$element['type'] = 1;
$element['property_id'] = 153;
$element['prefix'] = ' AND (';
$element['if'] = '!=';
$element['value'] = "''";
$element['sufix'] = " AND CONVERT(CONCAT(SUBSTRING(shop_properties_items_value, 7, 4), CHAR(45), SUBSTRING(shop_properties_items_value, 4, 2), CHAR(45), SUBSTRING(shop_properties_items_value, 1, 2)), DATETIME) > '". date('Y-m-d H:i:s') ."')";
$param['select'][] = $element;*/
$shop->ShowShop($current_shop_id, $xsl_catalog, $param, $external_propertys);
}
else
{
/* Вывод конкретного элемент */
//$param['show_catalog_item_type'] = array('active', 'inactive');
$param['xml_show_group_type'] = 'tree';
$param['current_group_id'] = $GLOBALS['shop_item_path']['group'];
// Запрещаем передачу в XML свойств групп
$param['xml_show_group_property'] = false;
/* Вывод конкретного элемента */
$shop->ShowItem($GLOBALS['shop_item_path']['item'], $xsl_item, $param, $external_propertys);
/* Вывод рекламы прочих товаров */
$external_propertys['this_item_id'] = $GLOBALS['shop_item_path']['item'];
$xsl_catalog = 'МагазинКаталогТоваровРеклама';
$param['items_on_page'] = 10;
$param['items_order'] = 'rand';
$shop->ShowShop($current_shop_id, $xsl_catalog, $param, $external_propertys);
}
}
?>
XML
<?xml version="1.0" encoding="UTF-8"?>
<shop id="1" current_group_id="0">
<user_id>0</user_id>
<name>Каталог кузовных запчастей</name>
<description><p>Наш онлайн <strong>каталог кузовных запчастей и радиаторов</strong> для иномарок содержит более 15 000 наименований. Большинство позиций, представленных в нашем каталоге, находятся на складе в Москве.</p>
<p><strong>К</strong><strong>аталог кузовных запчастей и радиаторов</strong> регулярно обновляется и содержит актуальную информацию по наличию товара.</p></description>
<path>/shop/</path>
<site_id>1</site_id>
<shop_image_small_max_width>169</shop_image_small_max_width>
<shop_image_big_max_width>640</shop_image_big_max_width>
<shop_image_small_max_height>88</shop_image_small_max_height>
<shop_image_big_max_height>480</shop_image_big_max_height>
<structure_id>42</structure_id>
<shop_country_id>175</shop_country_id>
<shop_currency id="1">
<shop_currency_name>руб.</shop_currency_name>
<shop_currency_international_name>RUB</shop_currency_international_name>
<shop_currency_value_in_basic_currency>1.000000</shop_currency_value_in_basic_currency>
<shop_currency_is_default>1</shop_currency_is_default>
</shop_currency>
<all_currency>
<shop_currency id="1">
<shop_currency_name>руб.</shop_currency_name>
<shop_currency_international_name>RUB</shop_currency_international_name>
<shop_currency_value_in_basic_currency>1.000000</shop_currency_value_in_basic_currency>
<shop_currency_is_default>1</shop_currency_is_default>
<shop_currency_coefficient>1</shop_currency_coefficient>
</shop_currency>
<shop_currency id="2">
<shop_currency_name>&euro;</shop_currency_name>
<shop_currency_international_name>EUR</shop_currency_international_name>
<shop_currency_value_in_basic_currency>36.889479</shop_currency_value_in_basic_currency>
<shop_currency_is_default>0</shop_currency_is_default>
<shop_currency_coefficient>0.027108000088589</shop_currency_coefficient>
</shop_currency>
<shop_currency id="3">
<shop_currency_name>$</shop_currency_name>
<shop_currency_international_name>USD</shop_currency_international_name>
<shop_currency_value_in_basic_currency>23.639664</shop_currency_value_in_basic_currency>
<shop_currency_is_default>0</shop_currency_is_default>
<shop_currency_coefficient>0.042301785676818</shop_currency_coefficient>
</shop_currency>
</all_currency>
<shop_order_status id="1">
<shop_order_status_name>В обработке</shop_order_status_name>
<shop_order_status_description></shop_order_status_description>
</shop_order_status>
<shop_mesures id="0">
</shop_mesures>
<shop_shops_send_order_mail_admin>1</shop_shops_send_order_mail_admin>
<shop_shops_send_order_mail_user>1</shop_shops_send_order_mail_user>
<shop_shops_admin_mail>order@optikadepo.ru</shop_shops_admin_mail>
<warehouses>
<warehouse id="3">
<shop_warehouse_name>Основной</shop_warehouse_name>
<shop_warehouse_activity>1</shop_warehouse_activity>
<shop_warehouse_address>ул. Боровая, д. 7</shop_warehouse_address>
<shop_warehouse_order>0</shop_warehouse_order>
<shop_warehouse_default>1</shop_warehouse_default>
<shop_country_id>175</shop_country_id>
<shop_country_name>Россия</shop_country_name>
<shop_location_id>1</shop_location_id>
<shop_location_name>Москва и Московская обл.</shop_location_name>
<shop_city_id>1</shop_city_id>
<shop_city_name>Москва</shop_city_name>
</warehouse>
</warehouses>
<group id="669" parent="0">
<name>АМЕРИКА</name>
<description></description>
<order>0</order>
<indexation>1</indexation>
<path>669</path>
<fullpath>669/</fullpath>
<count_items>0</count_items>
<count_groups>10</count_groups>
<count_all_items>1330</count_all_items>
<count_all_groups>171</count_all_groups>
<seo_title></seo_title>
<seo_description></seo_description>
<seo_keywords></seo_keywords>
<propertys>
</propertys>
</group>
<group id="758" parent="0">
<name>ГРУЗОВИКИ</name>
<description></description>
<order>0</order>
<indexation>1</indexation>
<path>758</path>
<fullpath>758/</fullpath>
<count_items>0</count_items>
<count_groups>7</count_groups>
<count_all_items>275</count_all_items>
<count_all_groups>39</count_all_groups>
<seo_title></seo_title>
<seo_description></seo_description>
<seo_keywords></seo_keywords>
<propertys>
</propertys>
</group>
<group id="1" parent="0">
<name>ЕВРОПА</name>
<description></description>
<order>0</order>
<indexation>1</indexation>
<path>1</path>
<fullpath>1/</fullpath>
<count_items>0</count_items>
<count_groups>24</count_groups>
<count_all_items>10177</count_all_items>
<count_all_groups>512</count_all_groups>
<seo_title></seo_title>
<seo_description></seo_description>
<seo_keywords></seo_keywords>
<propertys>
</propertys>
</group>
<group id="789" parent="0">
<name>КИТАЙ</name>
<description></description>
<order>0</order>
<indexation>1</indexation>
<path>789</path>
<fullpath>789/</fullpath>
<count_items>0</count_items>
<count_groups>3</count_groups>
<count_all_items>60</count_all_items>
<count_all_groups>9</count_all_groups>
<seo_title></seo_title>
<seo_description></seo_description>
<seo_keywords></seo_keywords>
<propertys>
</propertys>
</group>
<group id="589" parent="0">
<name>КОРЕЯ</name>
<description></description>
<order>0</order>
<indexation>1</indexation>
<path>589</path>
<fullpath>589/</fullpath>
<count_items>0</count_items>
<count_groups>4</count_groups>
<count_all_items>1644</count_all_items>
<count_all_groups>128</count_all_groups>
<seo_title></seo_title>
<seo_description></seo_description>
<seo_keywords></seo_keywords>
<propertys>
</propertys>
</group>
<group id="322" parent="0">
<name>ЯПОНИЯ</name>
<description></description>
<order>0</order>
<indexation>1</indexation>
<path>322</path>
<fullpath>322/</fullpath>
<count_items>0</count_items>
<count_groups>10</count_groups>
<count_all_items>7359</count_all_items>
<count_all_groups>400</count_all_groups>
<seo_title></seo_title>
<seo_description></seo_description>
<seo_keywords></seo_keywords>
<propertys>
</propertys>
</group>
<sallers>
<saller id="1">
<sallers_name>ООО «Автодемпинг»</sallers_name>
<sallers_contact_person></sallers_contact_person>
<sallers_comment></sallers_comment>
<sallers_address>г. Москва ул. Боровая, д. 7</sallers_address>
<sallers_phone>8 (495) 972-05-55</sallers_phone>
<sallers_fax></sallers_fax>
<sallers_http>http://оптикадепо.рф/</sallers_http>
<sallers_email>заказ@оптикадепо.рф</sallers_email>
<sallers_inn>7722729797</sallers_inn>
<site_users_id>0</site_users_id>
</saller>
</sallers>
<taxes>
<tax id="2">
<tax_name>НДС 18 (входит в цену)</tax_name>
<tax_rate>18</tax_rate>
<tax_is_in_price>1</tax_is_in_price>
</tax>
<tax id="5">
<tax_name>НДС 18 (не входит в цену)</tax_name>
<tax_rate>18</tax_rate>
<tax_is_in_price>0</tax_is_in_price>
</tax>
<tax id="19">
<tax_name>НДС 10 (входит в цену)</tax_name>
<tax_rate>10</tax_rate>
<tax_is_in_price>1</tax_is_in_price>
</tax>
<tax id="20">
<tax_name>НДС 10 (не входит в цену)</tax_name>
<tax_rate>10</tax_rate>
<tax_is_in_price>0</tax_is_in_price>
</tax>
<tax id="21">
<tax_name>НДС (без налога)</tax_name>
<tax_rate>0</tax_rate>
<tax_is_in_price>1</tax_is_in_price>
</tax>
</taxes>
<properties_for_group>
<property id="134" parent_id="0" xml_name="model_year">
<name>Модельный год</name>
<property_name>Модельный год</property_name>
<shop_list_of_properties_type>0</shop_list_of_properties_type>
<shop_list_of_properties_prefics></shop_list_of_properties_prefics>
<shop_list_of_properties_description></shop_list_of_properties_description>
<property_show_kind>0</property_show_kind>
</property>
<property id="135" parent_id="0" xml_name="waiting">
<name>Наличие</name>
<property_name>Наличие</property_name>
<shop_list_of_properties_type>0</shop_list_of_properties_type>
<shop_list_of_properties_prefics></shop_list_of_properties_prefics>
<shop_list_of_properties_description></shop_list_of_properties_description>
<property_show_kind>0</property_show_kind>
</property>
<property id="138" parent_id="0" xml_name="air_condition">
<name>Наличие кондиционера</name>
<property_name>Наличие кондиционера</property_name>
<shop_list_of_properties_type>0</shop_list_of_properties_type>
<shop_list_of_properties_prefics></shop_list_of_properties_prefics>
<shop_list_of_properties_description></shop_list_of_properties_description>
<property_show_kind>0</property_show_kind>
</property>
<property id="136" parent_id="0" xml_name="depo_number">
<name>Номер по производителю</name>
<property_name>Номер по производителю</property_name>
<shop_list_of_properties_type>0</shop_list_of_properties_type>
<shop_list_of_properties_prefics></shop_list_of_properties_prefics>
<shop_list_of_properties_description></shop_list_of_properties_description>
<property_show_kind>0</property_show_kind>
</property>
<property id="133" parent_id="0" xml_name="original_number">
<name>Оригинальный номер</name>
<property_name>Оригинальный номер</property_name>
<shop_list_of_properties_type>0</shop_list_of_properties_type>
<shop_list_of_properties_prefics></shop_list_of_properties_prefics>
<shop_list_of_properties_description></shop_list_of_properties_description>
<property_show_kind>0</property_show_kind>
</property>
<property id="139" parent_id="0" xml_name="engine_type">
<name>Тип ДВС</name>
<property_name>Тип ДВС</property_name>
<shop_list_of_properties_type>0</shop_list_of_properties_type>
<shop_list_of_properties_prefics></shop_list_of_properties_prefics>
<shop_list_of_properties_description></shop_list_of_properties_description>
<property_show_kind>0</property_show_kind>
</property>
<property id="137" parent_id="0" xml_name="kpp_type">
<name>Тип КПП</name>
<property_name>Тип КПП</property_name>
<shop_list_of_properties_type>0</shop_list_of_properties_type>
<shop_list_of_properties_prefics></shop_list_of_properties_prefics>
<shop_list_of_properties_description></shop_list_of_properties_description>
<property_show_kind>0</property_show_kind>
</property>
</properties_for_group>
<count_items>0</count_items>
<current_page>0</current_page>
<items_on_page>25</items_on_page>
</shop>
<shop id="1" current_group_id="0">
<user_id>0</user_id>
<name>Каталог кузовных запчастей</name>
<description><p>Наш онлайн <strong>каталог кузовных запчастей и радиаторов</strong> для иномарок содержит более 15 000 наименований. Большинство позиций, представленных в нашем каталоге, находятся на складе в Москве.</p>
<p><strong>К</strong><strong>аталог кузовных запчастей и радиаторов</strong> регулярно обновляется и содержит актуальную информацию по наличию товара.</p></description>
<path>/shop/</path>
<site_id>1</site_id>
<shop_image_small_max_width>169</shop_image_small_max_width>
<shop_image_big_max_width>640</shop_image_big_max_width>
<shop_image_small_max_height>88</shop_image_small_max_height>
<shop_image_big_max_height>480</shop_image_big_max_height>
<structure_id>42</structure_id>
<shop_country_id>175</shop_country_id>
<shop_currency id="1">
<shop_currency_name>руб.</shop_currency_name>
<shop_currency_international_name>RUB</shop_currency_international_name>
<shop_currency_value_in_basic_currency>1.000000</shop_currency_value_in_basic_currency>
<shop_currency_is_default>1</shop_currency_is_default>
</shop_currency>
<all_currency>
<shop_currency id="1">
<shop_currency_name>руб.</shop_currency_name>
<shop_currency_international_name>RUB</shop_currency_international_name>
<shop_currency_value_in_basic_currency>1.000000</shop_currency_value_in_basic_currency>
<shop_currency_is_default>1</shop_currency_is_default>
<shop_currency_coefficient>1</shop_currency_coefficient>
</shop_currency>
<shop_currency id="2">
<shop_currency_name>&euro;</shop_currency_name>
<shop_currency_international_name>EUR</shop_currency_international_name>
<shop_currency_value_in_basic_currency>36.889479</shop_currency_value_in_basic_currency>
<shop_currency_is_default>0</shop_currency_is_default>
<shop_currency_coefficient>0.027108000088589</shop_currency_coefficient>
</shop_currency>
<shop_currency id="3">
<shop_currency_name>$</shop_currency_name>
<shop_currency_international_name>USD</shop_currency_international_name>
<shop_currency_value_in_basic_currency>23.639664</shop_currency_value_in_basic_currency>
<shop_currency_is_default>0</shop_currency_is_default>
<shop_currency_coefficient>0.042301785676818</shop_currency_coefficient>
</shop_currency>
</all_currency>
<shop_order_status id="1">
<shop_order_status_name>В обработке</shop_order_status_name>
<shop_order_status_description></shop_order_status_description>
</shop_order_status>
<shop_mesures id="0">
</shop_mesures>
<shop_shops_send_order_mail_admin>1</shop_shops_send_order_mail_admin>
<shop_shops_send_order_mail_user>1</shop_shops_send_order_mail_user>
<shop_shops_admin_mail>order@optikadepo.ru</shop_shops_admin_mail>
<warehouses>
<warehouse id="3">
<shop_warehouse_name>Основной</shop_warehouse_name>
<shop_warehouse_activity>1</shop_warehouse_activity>
<shop_warehouse_address>ул. Боровая, д. 7</shop_warehouse_address>
<shop_warehouse_order>0</shop_warehouse_order>
<shop_warehouse_default>1</shop_warehouse_default>
<shop_country_id>175</shop_country_id>
<shop_country_name>Россия</shop_country_name>
<shop_location_id>1</shop_location_id>
<shop_location_name>Москва и Московская обл.</shop_location_name>
<shop_city_id>1</shop_city_id>
<shop_city_name>Москва</shop_city_name>
</warehouse>
</warehouses>
<group id="669" parent="0">
<name>АМЕРИКА</name>
<description></description>
<order>0</order>
<indexation>1</indexation>
<path>669</path>
<fullpath>669/</fullpath>
<count_items>0</count_items>
<count_groups>10</count_groups>
<count_all_items>1330</count_all_items>
<count_all_groups>171</count_all_groups>
<seo_title></seo_title>
<seo_description></seo_description>
<seo_keywords></seo_keywords>
<propertys>
</propertys>
</group>
<group id="758" parent="0">
<name>ГРУЗОВИКИ</name>
<description></description>
<order>0</order>
<indexation>1</indexation>
<path>758</path>
<fullpath>758/</fullpath>
<count_items>0</count_items>
<count_groups>7</count_groups>
<count_all_items>275</count_all_items>
<count_all_groups>39</count_all_groups>
<seo_title></seo_title>
<seo_description></seo_description>
<seo_keywords></seo_keywords>
<propertys>
</propertys>
</group>
<group id="1" parent="0">
<name>ЕВРОПА</name>
<description></description>
<order>0</order>
<indexation>1</indexation>
<path>1</path>
<fullpath>1/</fullpath>
<count_items>0</count_items>
<count_groups>24</count_groups>
<count_all_items>10177</count_all_items>
<count_all_groups>512</count_all_groups>
<seo_title></seo_title>
<seo_description></seo_description>
<seo_keywords></seo_keywords>
<propertys>
</propertys>
</group>
<group id="789" parent="0">
<name>КИТАЙ</name>
<description></description>
<order>0</order>
<indexation>1</indexation>
<path>789</path>
<fullpath>789/</fullpath>
<count_items>0</count_items>
<count_groups>3</count_groups>
<count_all_items>60</count_all_items>
<count_all_groups>9</count_all_groups>
<seo_title></seo_title>
<seo_description></seo_description>
<seo_keywords></seo_keywords>
<propertys>
</propertys>
</group>
<group id="589" parent="0">
<name>КОРЕЯ</name>
<description></description>
<order>0</order>
<indexation>1</indexation>
<path>589</path>
<fullpath>589/</fullpath>
<count_items>0</count_items>
<count_groups>4</count_groups>
<count_all_items>1644</count_all_items>
<count_all_groups>128</count_all_groups>
<seo_title></seo_title>
<seo_description></seo_description>
<seo_keywords></seo_keywords>
<propertys>
</propertys>
</group>
<group id="322" parent="0">
<name>ЯПОНИЯ</name>
<description></description>
<order>0</order>
<indexation>1</indexation>
<path>322</path>
<fullpath>322/</fullpath>
<count_items>0</count_items>
<count_groups>10</count_groups>
<count_all_items>7359</count_all_items>
<count_all_groups>400</count_all_groups>
<seo_title></seo_title>
<seo_description></seo_description>
<seo_keywords></seo_keywords>
<propertys>
</propertys>
</group>
<sallers>
<saller id="1">
<sallers_name>ООО «Автодемпинг»</sallers_name>
<sallers_contact_person></sallers_contact_person>
<sallers_comment></sallers_comment>
<sallers_address>г. Москва ул. Боровая, д. 7</sallers_address>
<sallers_phone>8 (495) 972-05-55</sallers_phone>
<sallers_fax></sallers_fax>
<sallers_http>http://оптикадепо.рф/</sallers_http>
<sallers_email>заказ@оптикадепо.рф</sallers_email>
<sallers_inn>7722729797</sallers_inn>
<site_users_id>0</site_users_id>
</saller>
</sallers>
<taxes>
<tax id="2">
<tax_name>НДС 18 (входит в цену)</tax_name>
<tax_rate>18</tax_rate>
<tax_is_in_price>1</tax_is_in_price>
</tax>
<tax id="5">
<tax_name>НДС 18 (не входит в цену)</tax_name>
<tax_rate>18</tax_rate>
<tax_is_in_price>0</tax_is_in_price>
</tax>
<tax id="19">
<tax_name>НДС 10 (входит в цену)</tax_name>
<tax_rate>10</tax_rate>
<tax_is_in_price>1</tax_is_in_price>
</tax>
<tax id="20">
<tax_name>НДС 10 (не входит в цену)</tax_name>
<tax_rate>10</tax_rate>
<tax_is_in_price>0</tax_is_in_price>
</tax>
<tax id="21">
<tax_name>НДС (без налога)</tax_name>
<tax_rate>0</tax_rate>
<tax_is_in_price>1</tax_is_in_price>
</tax>
</taxes>
<properties_for_group>
<property id="134" parent_id="0" xml_name="model_year">
<name>Модельный год</name>
<property_name>Модельный год</property_name>
<shop_list_of_properties_type>0</shop_list_of_properties_type>
<shop_list_of_properties_prefics></shop_list_of_properties_prefics>
<shop_list_of_properties_description></shop_list_of_properties_description>
<property_show_kind>0</property_show_kind>
</property>
<property id="135" parent_id="0" xml_name="waiting">
<name>Наличие</name>
<property_name>Наличие</property_name>
<shop_list_of_properties_type>0</shop_list_of_properties_type>
<shop_list_of_properties_prefics></shop_list_of_properties_prefics>
<shop_list_of_properties_description></shop_list_of_properties_description>
<property_show_kind>0</property_show_kind>
</property>
<property id="138" parent_id="0" xml_name="air_condition">
<name>Наличие кондиционера</name>
<property_name>Наличие кондиционера</property_name>
<shop_list_of_properties_type>0</shop_list_of_properties_type>
<shop_list_of_properties_prefics></shop_list_of_properties_prefics>
<shop_list_of_properties_description></shop_list_of_properties_description>
<property_show_kind>0</property_show_kind>
</property>
<property id="136" parent_id="0" xml_name="depo_number">
<name>Номер по производителю</name>
<property_name>Номер по производителю</property_name>
<shop_list_of_properties_type>0</shop_list_of_properties_type>
<shop_list_of_properties_prefics></shop_list_of_properties_prefics>
<shop_list_of_properties_description></shop_list_of_properties_description>
<property_show_kind>0</property_show_kind>
</property>
<property id="133" parent_id="0" xml_name="original_number">
<name>Оригинальный номер</name>
<property_name>Оригинальный номер</property_name>
<shop_list_of_properties_type>0</shop_list_of_properties_type>
<shop_list_of_properties_prefics></shop_list_of_properties_prefics>
<shop_list_of_properties_description></shop_list_of_properties_description>
<property_show_kind>0</property_show_kind>
</property>
<property id="139" parent_id="0" xml_name="engine_type">
<name>Тип ДВС</name>
<property_name>Тип ДВС</property_name>
<shop_list_of_properties_type>0</shop_list_of_properties_type>
<shop_list_of_properties_prefics></shop_list_of_properties_prefics>
<shop_list_of_properties_description></shop_list_of_properties_description>
<property_show_kind>0</property_show_kind>
</property>
<property id="137" parent_id="0" xml_name="kpp_type">
<name>Тип КПП</name>
<property_name>Тип КПП</property_name>
<shop_list_of_properties_type>0</shop_list_of_properties_type>
<shop_list_of_properties_prefics></shop_list_of_properties_prefics>
<shop_list_of_properties_description></shop_list_of_properties_description>
<property_show_kind>0</property_show_kind>
</property>
</properties_for_group>
<count_items>0</count_items>
<current_page>0</current_page>
<items_on_page>25</items_on_page>
</shop>
XSL
<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE xsl:stylesheet>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:output xmlns="http://www.w3.org/TR/xhtml1/strict" doctype-public="-//W3C//DTD XHTML 1.0 Strict//EN" encoding="utf-8" indent="yes" method="html" omit-xml-declaration="no" version="1.0" media-type="text/xml"/>
<xsl:decimal-format name="my" decimal-separator="," grouping-separator=" "/>
<xsl:template match="/">
<xsl:apply-templates select="/shop"/>
</xsl:template>
<!-- Шаблон для магазина -->
<xsl:template match="/shop">
<!-- Получаем ID родительской группы и записываем в переменную $parent_group_id -->
<xsl:variable name="parent_group_id" select="@current_group_id"/>
<!-- Если в находимся корне - выводим название и описание информационной системы -->
<xsl:if test="$parent_group_id = 0 and count(selected_tags/tag) != 0">
<h1>
<xsl:value-of disable-output-escaping="yes" select="/shop/selected_tags/tag/tag_name"/>
</h1>
<xsl:value-of disable-output-escaping="yes" select="/shop/selected_tags/tag/tag_description"/>
</xsl:if>
<xsl:if test="$parent_group_id = 0 and count(selected_tags/tag) = 0">
<h1>
<xsl:value-of disable-output-escaping="yes" select="/shop/name"/>
</h1>
<xsl:value-of disable-output-escaping="yes" select="/shop/description"/>
</xsl:if>
<!-- Если в находимся в группе - выводим название группы -->
<xsl:choose>
<xsl:when test="$parent_group_id != 0 and .//group[@id=$parent_group_id]/description != '' and count(selected_tags/tag) > 0">
<xsl:value-of disable-output-escaping="yes" select=".//group[@id=$parent_group_id]/description"/>
</xsl:when>
<xsl:when test="$parent_group_id != 0 and .//group[@id=$parent_group_id]/propertys/property[@xml_name = 'parts_description']/value != '' and count(selected_tags/tag) = 0">
<xsl:value-of disable-output-escaping="yes" select=".//group[@id=$parent_group_id]/propertys/property[@xml_name = 'parts_description']/value"/>
</xsl:when>
<xsl:otherwise>
<h1><xsl:value-of disable-output-escaping="yes" select=".//group[@id=$parent_group_id]/name"/></h1>
</xsl:otherwise>
</xsl:choose>
<!-- Обработка выбранных тэгов -->
<!-- xsl:if test="count(selected_tags/tag) = 1">
<h2>Метка — <strong><xsl:value-of select="selected_tags/tag/tag_name"/></strong>.</h2>
</xsl:if-->
<xsl:variable name="count">1</xsl:variable>
<!-- Отображение подгрупп данной группы, только если подгруппы есть -->
<xsl:if test="count(//group[@parent=$parent_group_id]) > 0">
<table width="100%" border="0" cellpadding="3" cellspacing="0">
<xsl:apply-templates select=".//group[@parent=$parent_group_id and count_all_items != 0]"/>
</table>
</xsl:if>
<!-- дополнение пути для action, если выбрана метка -->
<xsl:variable name="form_tag_path"><xsl:if test="count(selected_tags/tag) = 1">tag/<xsl:value-of select="selected_tags/tag/tag_path_name"/>/</xsl:if></xsl:variable>
<xsl:if test="count(item) > 0 or apply_filter = 1">
<form method="get" action="{/shop/path}{//group[@id=$parent_group_id]/fullpath}{$form_tag_path}">
<xsl:if test="property_xml/node() and property_xml='&all_group=1'">
<input type="hidden" name="all_group" value="1"/>
</xsl:if>
<div class="shop_block">
<div>
Цена от: 
<input name="price_from" size="5" type="text">
<xsl:if test="/shop/price_from != 0">
<xsl:attribute name="value">
<xsl:value-of disable-output-escaping="yes" select="/shop/price_from"/>
</xsl:attribute>
</xsl:if>
</input> 
до: 
<input name="price_to" size="5" type="text">
<xsl:if test="/shop/price_to != 0">
<xsl:attribute name="value">
<xsl:value-of disable-output-escaping="yes" select="/shop/price_to"/>
</xsl:attribute>
</xsl:if>
</input> 
<span style="white-space: nowrap">Товаров на странице:</span> 
<select name="on_page">
<option value="0">…</option>
<xsl:call-template name="for_on_page">
<xsl:with-param name="i" select="10"/>
<xsl:with-param name="n" select="50"/>
</xsl:call-template>
</select> 
<input name="apply_filter" value="Применить" type="submit"/>
</div>
</div>
<!-- Сортировка товаров -->
<div class="shop_block">
<!-- Определяем ссылку с параметрами фильтра -->
<xsl:variable name="filter">
<xsl:if test="/shop/apply_filter/node()">?action=apply_filter&price_from=<xsl:value-of select="/shop/price_from"/>&price_to=<xsl:value-of select="/shop/price_to"/>&on_page=<xsl:value-of select="/shop/on_page"/>
<xsl:if test="/shop/property_xml/node()">
<!-- GET для доп. свойств -->
<xsl:value-of select="/shop/property_xml"/>
</xsl:if>
</xsl:if>
</xsl:variable>
<!-- Определяем первый символ вопрос или амперсанд -->
<xsl:variable name="first_symbol">
<xsl:choose>
<xsl:when test="$filter != ''">&</xsl:when>
<xsl:otherwise>?</xsl:otherwise>
</xsl:choose>
</xsl:variable>
<div style="float:left;">
Сортировать по алфавиту
</div>
<xsl:choose>
<xsl:when test="/shop/sort_by_field = 1 and /shop/order_direction = 'ASC'">
<div class="arrow_up">
<img src="/hostcmsfiles/images/arrow_up.png" style="float: left; filter: alpha(opacity=0); margin: 0px 0px -4px 0px" alt="по возрастанию"/>
</div>
</xsl:when>
<xsl:otherwise>
<div class="arrow_up_gray">
<a href="{$filter}{$first_symbol}sort_by_field=1&order_direction=1" class="without_decor">
<img src="/hostcmsfiles/images/arrow_up_gray.png" alt="по возрастанию"/>
</a>
</div>
</xsl:otherwise>
</xsl:choose>
<xsl:choose>
<xsl:when test="/shop/sort_by_field = 1 and /shop/order_direction = 'DESC'">
<div class="arrow_down">
<img src="/hostcmsfiles/images/arrow_down.png" alt="по убыванию"/>
</div>
</xsl:when>
<xsl:otherwise>
<div class="arrow_down_gray">
<a href="{$filter}{$first_symbol}sort_by_field=1&order_direction=2" class="without_decor">
<img src="/hostcmsfiles/images/arrow_down_gray.png" alt="по убыванию"/>
</a>
</div>
</xsl:otherwise>
</xsl:choose><div style="float:left;">, по цене</div>
<xsl:choose>
<xsl:when test="/shop/sort_by_field = 2 and /shop/order_direction = 'ASC'">
<div class="arrow_up">
<img src="/hostcmsfiles/images/arrow_up.png" alt="по возрастанию"/>
</div>
</xsl:when>
<xsl:otherwise>
<div class="arrow_up_gray">
<a href="{$filter}{$first_symbol}sort_by_field=2&order_direction=1" class="without_decor">
<img src="/hostcmsfiles/images/arrow_up_gray.png" alt="по возрастанию"/></a>
</div>
</xsl:otherwise>
</xsl:choose>
<xsl:choose>
<xsl:when test="/shop/sort_by_field = 2 and /shop/order_direction = 'DESC'">
<div class="arrow_down">
<img src="/hostcmsfiles/images/arrow_down.png" style="filter: alpha(opacity=0); margin: 0px 0px -4px 0px" alt="по убыванию"/>
</div>
</xsl:when>
<xsl:otherwise>
<div class="arrow_down_gray">
<a href="{$filter}{$first_symbol}sort_by_field=2&order_direction=2" class="without_decor">
<img src="/hostcmsfiles/images/arrow_down_gray.png" alt="по убыванию"/>
</a>
</div>
</xsl:otherwise>
</xsl:choose>
<div class="clear"></div>
</div>
<!-- Определяем ссылку с параметрами фильтра -->
<xsl:variable name="filter">
<xsl:choose>
<xsl:when test="/shop/apply_filter/node()">?action=apply_filter&producer_id=<xsl:value-of select="/shop/producer_id"/>&saller_id=<xsl:value-of select="/shop/saller_id"/>&price_from=<xsl:value-of select="/shop/price_from"/>&price_to=<xsl:value-of select="/shop/price_to"/>&on_page=<xsl:value-of select="/shop/on_page"/>
<xsl:if test="/shop/property_xml/node()">
<!-- GET для доп. свойств -->
<xsl:value-of select="/shop/property_xml"/>
</xsl:if>
</xsl:when>
<xsl:otherwise></xsl:otherwise>
</xsl:choose>
</xsl:variable>
<!-- Определяем первый символ вопрос или амперсанд -->
<xsl:variable name="first_symbol">
<xsl:choose>
<xsl:when test="$filter != ''">&</xsl:when>
<xsl:otherwise>?</xsl:otherwise>
</xsl:choose>
</xsl:variable>
<!-- Вывод товаров -->
<div class="content_items_line_in_catalog">
<xsl:choose>
<xsl:when test="/shop/selected_tags/tag/tag_path_name = 'optika'">
<xsl:apply-templates select="item" mode="first"/>
</xsl:when>
<xsl:otherwise>
<table width="100%" cellpadding="0" cellspacing="0" class="table-catalog">
<tr>
<th>Фото</th>
<th>Артикул</th>
<th>Наименование</th>
<th>Год</th>
<th>Оригинальный №</th>
<th>Цена</th>
<th></th>
<th>Наличие</th>
</tr>
<xsl:apply-templates select="item" mode="second"/>
</table>
</xsl:otherwise>
</xsl:choose>
<div class="clear"></div>
</div>
<xsl:if test="count_items > 0 and items_on_page > 0 and count_items > items_on_page">
<xsl:variable name="count_pages" select="ceiling(count_items div items_on_page)"/>
<xsl:variable name="visible_pages" select="5"/>
<xsl:variable name="real_visible_pages"><xsl:choose>
<xsl:when test="$count_pages < $visible_pages"><xsl:value-of select="$count_pages"/></xsl:when>
<xsl:otherwise><xsl:value-of select="$visible_pages"/></xsl:otherwise>
</xsl:choose></xsl:variable>
<!-- Считаем количество выводимых ссылок перед текущим элементом -->
<xsl:variable name="pre_count_page"><xsl:choose>
<xsl:when test="current_page - (floor($real_visible_pages div 2)) < 0">
<xsl:value-of select="current_page"/>
</xsl:when>
<xsl:when test="($count_pages - current_page - 1) < floor($real_visible_pages div 2)">
<xsl:value-of select="$real_visible_pages - ($count_pages - current_page - 1) - 1"/>
</xsl:when>
<xsl:otherwise>
<xsl:choose>
<xsl:when test="round($real_visible_pages div 2) = $real_visible_pages div 2">
<xsl:value-of select="floor($real_visible_pages div 2) - 1"/>
</xsl:when>
<xsl:otherwise>
<xsl:value-of select="floor($real_visible_pages div 2)"/>
</xsl:otherwise>
</xsl:choose>
</xsl:otherwise>
</xsl:choose></xsl:variable>
<!-- Считаем количество выводимых ссылок после текущего элемента -->
<xsl:variable name="post_count_page"><xsl:choose>
<xsl:when test="0 > current_page - (floor($real_visible_pages div 2) - 1)">
<xsl:value-of select="$real_visible_pages - current_page - 1"/>
</xsl:when>
<xsl:when test="($count_pages - current_page - 1) < floor($real_visible_pages div 2)">
<xsl:value-of select="$real_visible_pages - $pre_count_page - 1"/>
</xsl:when>
<xsl:otherwise>
<xsl:value-of select="$real_visible_pages - $pre_count_page - 1"/>
</xsl:otherwise>
</xsl:choose></xsl:variable>
<xsl:variable name="i"><xsl:choose>
<xsl:when test="current_page + 1 = $count_pages"><xsl:value-of select="current_page - $real_visible_pages + 1"/></xsl:when>
<xsl:when test="current_page - $pre_count_page > 0"><xsl:value-of select="current_page - $pre_count_page"/></xsl:when>
<xsl:otherwise>0</xsl:otherwise>
</xsl:choose></xsl:variable>
<div class="pages">
<xsl:call-template name="for">
<xsl:with-param name="items_on_page" select="items_on_page"/>
<xsl:with-param name="current_page" select="current_page"/>
<xsl:with-param name="count_items" select="count_items"/>
<xsl:with-param name="i" select="$i"/>
<xsl:with-param name="post_count_page" select="$post_count_page"/>
<xsl:with-param name="pre_count_page" select="$pre_count_page"/>
<xsl:with-param name="visible_pages" select="$real_visible_pages"/>
</xsl:call-template>
</div>
<div class="clear"></div>
</xsl:if>
</form>
</xsl:if>
</xsl:template>
<!-- Цикл с шагом 10 для select'a количества элементов на страницу -->
<xsl:template name="for_on_page">
<xsl:param name="i" select="0"/>
<xsl:param name="n"/>
<option value="{$i}">
<xsl:if test="$i = /shop/on_page">
<xsl:attribute name="selected">
</xsl:attribute>
</xsl:if>
<xsl:value-of select="$i"/>
</option>
<xsl:if test="$n > $i">
<!-- Рекурсивный вызов шаблона -->
<xsl:call-template name="for_on_page">
<xsl:with-param name="i" select="$i + 10"/>
<xsl:with-param name="n" select="$n"/>
</xsl:call-template>
</xsl:if>
</xsl:template>
<!-- Шаблон для групп товара -->
<xsl:template match="group">
<xsl:variable name="parent_id" select="@parent"/>
<!-- Если был передан тег, допишем в ссылки с группы -->
<xsl:variable name="tagpath">
<xsl:choose>
<xsl:when test="count(/shop/selected_tags/tag) > 0">tag/<xsl:value-of select="/shop/selected_tags/tag/tag_path_name" />/</xsl:when>
<xsl:otherwise></xsl:otherwise>
</xsl:choose>
</xsl:variable>
<td width="33%" valign="top">
<div style="margin-bottom:10px;">
<a href="{/shop/path}{fullpath}{$tagpath}" style="font-weight: bold">
<xsl:value-of disable-output-escaping="yes" select="name"/>
</a> <span style="color: #aaaaaa">(<xsl:value-of select="count_all_items"/>)</span>
<xsl:if test="count(group) > 1">
<xsl:apply-templates select="group" mode="sub_group"/>
</xsl:if>
</div>
</td>
<xsl:if test="position() mod 3 = 0">
<xsl:text disable-output-escaping="yes">
</tr>
<tr>
</xsl:text>
</xsl:if>
</xsl:template>
<!-- Шаблон для подразделов -->
<xsl:template match="group" mode="sub_group">
<a href="{/shop/path}{fullpath}">
<xsl:value-of disable-output-escaping="yes" select="name"/>
</a>
<xsl:variable name="parent_id" select="@parent"/>
<!-- Ставим запятую после группы, за которой следуют еще группы из данной родителской группы -->
<xsl:if test="position() != last() and count(//group[@parent = $parent_id]) > 1">, </xsl:if>
</xsl:template>
<!-- Шаблон для товара -->
<xsl:template match="item" mode="first">
<!-- Определяем цвет фона -->
<xsl:variable name="background_color">
<xsl:choose>
<xsl:when test="(position() + 1) mod 2 > 0">#f7f7f7</xsl:when>
<xsl:otherwise>#ffffff</xsl:otherwise>
</xsl:choose>
</xsl:variable>
<div class="content_item_in_catalog">
<!-- Изображение для товара, если есть -->
<xsl:choose>
<xsl:when test="small_image!=''">
<a href="{/shop/path}{fullpath}{path}/">
<img src="/images/nophoto_small.jpg" width="169" height="88" alt="" />
</a>
</xsl:when>
<xsl:otherwise>
<a href="{/shop/path}{fullpath}{path}/">
<img src="/images/catalog/{marking_of_goods}.jpg" width="169" height="88" alt="" />
</a>
</xsl:otherwise>
</xsl:choose>
<!-- Название товара -->
<p><a href="{/shop/path}{fullpath}{path}/" class="item_title">
<xsl:value-of disable-output-escaping="yes" select="name"/>
</a><br />
<span class="code">
<xsl:value-of select="property[@xml_name = 'depo_number']/value"/>
</span></p>
<!-- Цена товара -->
<p class="price">
<xsl:choose>
<xsl:when test="price_discount != 0">
<xsl:variable name="price" select="price_discount"/>
<xsl:value-of select="format-number($price, '### ##0', 'my')"/> <xsl:value-of disable-output-escaping="yes" select="currency"/>
</xsl:when>
<xsl:otherwise>
цена договорная
</xsl:otherwise>
</xsl:choose>
<!-- Ссылку на добавление в корзины выводим, если:
type != 1 - простой тип товара или делимый (0 - простой, 2 - делимый)
type = 1 - электронный товар, при этом остаток на складе больше 0 или -1,
что означает неограниченное количество -->
<xsl:if test="type != 1 or (type = 1 and (eitem_count > 0 or eitem_count = -1))">
<input type="hidden" size="3" value="1" id="count_{@id}"/>
<a href="{/shop/path}cart/?action=add&item_id={@id}" onclick="return AddIntoCart('{/shop/path}', {@id}, document.getElementById('count_{@id}').value)">
<img alt="В корзину" title="В корзину" src="/images/cart.png" style="margin:0 0 -4px 10px" />
</a>
</xsl:if>
</p>
</div>
<!-- На строку - не более 3-х пунктов, если уже 3 выведено - начинаем новую строку -->
<xsl:if test="position() mod 3 = 0 and position() != last()">
<xsl:text disable-output-escaping="yes">
<div class="clear"></div>
</div>
<div class="content_items_line_in_catalog">
</xsl:text>
</xsl:if>
</xsl:template>
<!-- Шаблон для товара (таблица) -->
<xsl:template match="item" mode="second">
<tr>
<td width="25" align="center">
<!-- Изображение для товара, если есть -->
<xsl:choose>
<xsl:when test="small_image!=''">
</xsl:when>
<xsl:otherwise>
<a href="/images/catalog/{marking_of_goods}.jpg" class="lightbox">
<img src="/images/camera.png" width="16" height="16" alt="" style="vertical-align:middle;" />
</a>
</xsl:otherwise>
</xsl:choose>
</td>
<td align="center">
<xsl:choose>
<xsl:when test="marking_of_goods != ''">
<xsl:value-of disable-output-escaping="yes" select="marking_of_goods"/>
</xsl:when>
<xsl:otherwise>
<xsl:value-of select="property[@xml_name = 'depo_number']/value"/>
</xsl:otherwise>
</xsl:choose>
</td>
<td width="300">
<a href="{/shop/path}{fullpath}{path}/">
<xsl:value-of disable-output-escaping="yes" select="name"/>
</a>
</td>
<td align="center"><xsl:value-of select="property[@xml_name = 'model_year']/value"/></td>
<td align="center">
<div class="divide-line">
<xsl:value-of select="property[@xml_name = 'original_number']/value"/>
</div>
</td>
<!-- Цена товара -->
<td width="85" align="right" style="color:#2365b0; font-weight:bold;">
<xsl:choose>
<xsl:when test="price_discount != 0">
<xsl:variable name="price" select="price_discount"/>
<xsl:value-of select="format-number($price, '### ##0', 'my')"/> <xsl:value-of disable-output-escaping="yes" select="currency"/>
</xsl:when>
<xsl:otherwise>
звоните
</xsl:otherwise>
</xsl:choose>
</td>
<td>
<!-- Ссылку на добавление в корзины выводим, если:
type != 1 - простой тип товара или делимый (0 - простой, 2 - делимый)
type = 1 - электронный товар, при этом остаток на складе больше 0 или -1,
что означает неограниченное количество -->
<xsl:if test="(type != 1 or (type = 1 and (eitem_count > 0 or eitem_count = -1))) and property[@xml_name = 'waiting']/value != 'нет'">
<input type="hidden" size="3" value="1" id="count_{@id}"/>
<a href="{/shop/path}cart/?action=add&item_id={@id}" onclick="return AddIntoCart('{/shop/path}', {@id}, document.getElementById('count_{@id}').value)">
<img alt="В корзину" title="В корзину" src="/images/cart.png" width="16" style="margin:0 0 -4px 10px" />
</a>
</xsl:if>
</td>
<td align="center">
<xsl:choose>
<xsl:when test="property[@xml_name = 'waiting']/value = 'нет'">
<xsl:attribute name="style">color:red</xsl:attribute>
</xsl:when>
<xsl:otherwise>
<xsl:attribute name="style">color:green</xsl:attribute>
</xsl:otherwise>
</xsl:choose>
<xsl:value-of select="property[@xml_name = 'waiting']/value"/>
</td>
</tr>
</xsl:template>
<!-- Цикл для вывода строк ссылок -->
<xsl:template name="for">
<xsl:param name="items_on_page"/>
<xsl:param name="current_page"/>
<xsl:param name="pre_count_page"/>
<xsl:param name="post_count_page"/>
<xsl:param name="i" select="0"/>
<xsl:param name="count_items"/>
<xsl:param name="visible_pages"/>
<xsl:variable name="n" select="ceiling($count_items div $items_on_page)"/>
<xsl:variable name="start_page"><xsl:choose>
<xsl:when test="$current_page + 1 = $n"><xsl:value-of select="$current_page - $visible_pages + 1"/></xsl:when>
<xsl:when test="$current_page - $pre_count_page > 0"><xsl:value-of select="$current_page - $pre_count_page"/></xsl:when>
<xsl:otherwise>0</xsl:otherwise>
</xsl:choose></xsl:variable>
<xsl:if test="$i = $start_page and $current_page != 0">
<span>
← Ctrl
</span>
</xsl:if>
<xsl:if test="$i = ($current_page + $post_count_page + 1) and $n != ($current_page+1)">
<span>
Ctrl →
</span>
</xsl:if>
<xsl:if test="$count_items > $items_on_page and ($current_page + $post_count_page + 1) > $i">
<!-- Заносим в переменную $parent_group_id идентификатор текущей группы -->
<xsl:variable name="parent_group_id" select="/shop/@current_group_id"/>
<!-- Путь для тэга -->
<xsl:variable name="tag_path">
<xsl:if test="count(/shop/selected_tags/tag) = 1">tag/<xsl:value-of select="/shop/selected_tags/tag/tag_path_name"/>/</xsl:if>
</xsl:variable>
<!-- Определяем группу для формирования адреса ссылки -->
<xsl:variable name="group_link">
<xsl:choose>
<!-- Если группа не корневая (!=0) -->
<xsl:when test="$parent_group_id != 0">
<xsl:value-of select="/shop//group[@id=$parent_group_id]/fullpath"/>
</xsl:when>
<!-- Иначе если нулевой уровень - просто ссылка на страницу со списком элементов -->
<xsl:otherwise></xsl:otherwise>
</xsl:choose>
</xsl:variable>
<!-- Определяем адрес ссылки -->
<xsl:variable name="number_link">
<xsl:choose>
<!-- Если не нулевой уровень -->
<xsl:when test="$i != 0">page-<xsl:value-of select="$i + 1"/>/</xsl:when>
<!-- Иначе если нулевой уровень - просто ссылка на страницу со списком элементов -->
<xsl:otherwise></xsl:otherwise>
</xsl:choose>
</xsl:variable>
<!-- Передаем фильтр -->
<xsl:variable name="filter">
<xsl:choose>
<xsl:when test="/shop/apply_filter/node()">?action=apply_filter&producer_id=<xsl:value-of select="/shop/producer_id"/>&saller_id=<xsl:value-of select="/shop/saller_id"/>&price_from=<xsl:value-of select="/shop/price_from"/>&price_to=<xsl:value-of select="/shop/price_to"/>&on_page=<xsl:value-of select="/shop/on_page"/>
<xsl:if test="/shop/property_xml/node()">
<!-- GET для доп. свойств -->
<xsl:value-of select="/shop/property_xml"/>
</xsl:if>
</xsl:when>
<xsl:otherwise></xsl:otherwise>
</xsl:choose>
</xsl:variable>
<!-- Определяем первый символ вопрос или амперсанд -->
<xsl:variable name="first_symbol">
<xsl:choose>
<xsl:when test="$filter != ''">&</xsl:when>
<xsl:otherwise>?</xsl:otherwise>
</xsl:choose>
</xsl:variable>
<!-- Данные для стрелок сортировки -->
<xsl:variable name="arrows">
<xsl:choose>
<xsl:when test="(/shop/sort_by_field = 1) or (/shop/sort_by_field = 2)">
<xsl:choose>
<!-- Стрелка вверх -->
<xsl:when test="/shop/order_direction = 'ASC'">
<xsl:value-of select="$first_symbol"/>sort_by_field=<xsl:value-of select="/shop/sort_by_field"/>&order_direction=1</xsl:when>
<!-- Стрелка вниз -->
<xsl:otherwise>
<xsl:value-of select="$first_symbol"/>sort_by_field=<xsl:value-of select="/shop/sort_by_field"/>&order_direction=2</xsl:otherwise>
</xsl:choose>
</xsl:when>
<xsl:otherwise></xsl:otherwise>
</xsl:choose>
</xsl:variable>
<!-- Выводим ссылку на первую страницу -->
<xsl:if test="$current_page - $pre_count_page > 0 and $i = $start_page">
<span><a href="{/shop/path}{$group_link}{$tag_path}{$filter}{$arrows}" class="page_link" style="text-decoration: none;">←</a></span>
</xsl:if>
<!-- Ставим ссылку на страницу-->
<xsl:if test="$i != $current_page">
<xsl:if test="($current_page - $pre_count_page) <= $i and $i < $n">
<!-- Выводим ссылки на видимые страницы -->
<span><a href="{/shop/path}{$group_link}{$tag_path}{$number_link}{$filter}{$arrows}" class="page_link">
<xsl:value-of select="$i + 1"/>
</a></span>
</xsl:if>
<!-- Выводим ссылку на последнюю страницу -->
<xsl:if test="$i+1 >= ($current_page + $post_count_page + 1) and $n > ($current_page + 1 + $post_count_page)">
<!-- Выводим ссылку на последнюю страницу -->
<span><a href="{/shop/path}{$group_link}{$tag_path}page-{$n}/{$filter}{$arrows}" class="page_link" style="text-decoration: none;">→</a></span>
</xsl:if>
</xsl:if>
<!-- Ссылка на предыдущую страницу для Ctrl + влево -->
<xsl:if test="$current_page != 0 and $i = $current_page">
<xsl:variable name="prev_number_link">
<xsl:choose>
<!-- Если не нулевой уровень -->
<xsl:when test="($current_page - 1) != 0">page-<xsl:value-of select="$i"/>/</xsl:when>
<!-- Иначе если нулевой уровень - просто ссылка на страницу со списком элементов -->
<xsl:otherwise></xsl:otherwise>
</xsl:choose>
</xsl:variable>
<a href="{/shop/path}{$group_link}{$tag_path}{$prev_number_link}{$filter}{$arrows}" id="id_prev"></a>
</xsl:if>
<!-- Ссылка на следующую страницу для Ctrl + вправо -->
<xsl:if test="($n - 1) > $current_page and $i = $current_page">
<a href="{/shop/path}{$group_link}{$tag_path}page-{$current_page+2}/{$filter}{$arrows}" id="id_next"></a>
</xsl:if>
<!-- Не ставим ссылку на страницу-->
<xsl:if test="$i = $current_page">
<span class="cur_page">
<xsl:value-of select="$i+1"/>
</span>
</xsl:if>
<!-- Рекурсивный вызов шаблона. НЕОБХОДИМО ПЕРЕДАВАТЬ ВСЕ НЕОБХОДИМЫЕ ПАРАМЕТРЫ! -->
<xsl:call-template name="for">
<xsl:with-param name="i" select="$i + 1"/>
<xsl:with-param name="items_on_page" select="$items_on_page"/>
<xsl:with-param name="current_page" select="$current_page"/>
<xsl:with-param name="count_items" select="$count_items"/>
<xsl:with-param name="pre_count_page" select="$pre_count_page"/>
<xsl:with-param name="post_count_page" select="$post_count_page"/>
<xsl:with-param name="visible_pages" select="$visible_pages"/>
</xsl:call-template>
</xsl:if>
</xsl:template>
</xsl:stylesheet>
<!DOCTYPE xsl:stylesheet>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:output xmlns="http://www.w3.org/TR/xhtml1/strict" doctype-public="-//W3C//DTD XHTML 1.0 Strict//EN" encoding="utf-8" indent="yes" method="html" omit-xml-declaration="no" version="1.0" media-type="text/xml"/>
<xsl:decimal-format name="my" decimal-separator="," grouping-separator=" "/>
<xsl:template match="/">
<xsl:apply-templates select="/shop"/>
</xsl:template>
<!-- Шаблон для магазина -->
<xsl:template match="/shop">
<!-- Получаем ID родительской группы и записываем в переменную $parent_group_id -->
<xsl:variable name="parent_group_id" select="@current_group_id"/>
<!-- Если в находимся корне - выводим название и описание информационной системы -->
<xsl:if test="$parent_group_id = 0 and count(selected_tags/tag) != 0">
<h1>
<xsl:value-of disable-output-escaping="yes" select="/shop/selected_tags/tag/tag_name"/>
</h1>
<xsl:value-of disable-output-escaping="yes" select="/shop/selected_tags/tag/tag_description"/>
</xsl:if>
<xsl:if test="$parent_group_id = 0 and count(selected_tags/tag) = 0">
<h1>
<xsl:value-of disable-output-escaping="yes" select="/shop/name"/>
</h1>
<xsl:value-of disable-output-escaping="yes" select="/shop/description"/>
</xsl:if>
<!-- Если в находимся в группе - выводим название группы -->
<xsl:choose>
<xsl:when test="$parent_group_id != 0 and .//group[@id=$parent_group_id]/description != '' and count(selected_tags/tag) > 0">
<xsl:value-of disable-output-escaping="yes" select=".//group[@id=$parent_group_id]/description"/>
</xsl:when>
<xsl:when test="$parent_group_id != 0 and .//group[@id=$parent_group_id]/propertys/property[@xml_name = 'parts_description']/value != '' and count(selected_tags/tag) = 0">
<xsl:value-of disable-output-escaping="yes" select=".//group[@id=$parent_group_id]/propertys/property[@xml_name = 'parts_description']/value"/>
</xsl:when>
<xsl:otherwise>
<h1><xsl:value-of disable-output-escaping="yes" select=".//group[@id=$parent_group_id]/name"/></h1>
</xsl:otherwise>
</xsl:choose>
<!-- Обработка выбранных тэгов -->
<!-- xsl:if test="count(selected_tags/tag) = 1">
<h2>Метка — <strong><xsl:value-of select="selected_tags/tag/tag_name"/></strong>.</h2>
</xsl:if-->
<xsl:variable name="count">1</xsl:variable>
<!-- Отображение подгрупп данной группы, только если подгруппы есть -->
<xsl:if test="count(//group[@parent=$parent_group_id]) > 0">
<table width="100%" border="0" cellpadding="3" cellspacing="0">
<xsl:apply-templates select=".//group[@parent=$parent_group_id and count_all_items != 0]"/>
</table>
</xsl:if>
<!-- дополнение пути для action, если выбрана метка -->
<xsl:variable name="form_tag_path"><xsl:if test="count(selected_tags/tag) = 1">tag/<xsl:value-of select="selected_tags/tag/tag_path_name"/>/</xsl:if></xsl:variable>
<xsl:if test="count(item) > 0 or apply_filter = 1">
<form method="get" action="{/shop/path}{//group[@id=$parent_group_id]/fullpath}{$form_tag_path}">
<xsl:if test="property_xml/node() and property_xml='&all_group=1'">
<input type="hidden" name="all_group" value="1"/>
</xsl:if>
<div class="shop_block">
<div>
Цена от: 
<input name="price_from" size="5" type="text">
<xsl:if test="/shop/price_from != 0">
<xsl:attribute name="value">
<xsl:value-of disable-output-escaping="yes" select="/shop/price_from"/>
</xsl:attribute>
</xsl:if>
</input> 
до: 
<input name="price_to" size="5" type="text">
<xsl:if test="/shop/price_to != 0">
<xsl:attribute name="value">
<xsl:value-of disable-output-escaping="yes" select="/shop/price_to"/>
</xsl:attribute>
</xsl:if>
</input> 
<span style="white-space: nowrap">Товаров на странице:</span> 
<select name="on_page">
<option value="0">…</option>
<xsl:call-template name="for_on_page">
<xsl:with-param name="i" select="10"/>
<xsl:with-param name="n" select="50"/>
</xsl:call-template>
</select> 
<input name="apply_filter" value="Применить" type="submit"/>
</div>
</div>
<!-- Сортировка товаров -->
<div class="shop_block">
<!-- Определяем ссылку с параметрами фильтра -->
<xsl:variable name="filter">
<xsl:if test="/shop/apply_filter/node()">?action=apply_filter&price_from=<xsl:value-of select="/shop/price_from"/>&price_to=<xsl:value-of select="/shop/price_to"/>&on_page=<xsl:value-of select="/shop/on_page"/>
<xsl:if test="/shop/property_xml/node()">
<!-- GET для доп. свойств -->
<xsl:value-of select="/shop/property_xml"/>
</xsl:if>
</xsl:if>
</xsl:variable>
<!-- Определяем первый символ вопрос или амперсанд -->
<xsl:variable name="first_symbol">
<xsl:choose>
<xsl:when test="$filter != ''">&</xsl:when>
<xsl:otherwise>?</xsl:otherwise>
</xsl:choose>
</xsl:variable>
<div style="float:left;">
Сортировать по алфавиту
</div>
<xsl:choose>
<xsl:when test="/shop/sort_by_field = 1 and /shop/order_direction = 'ASC'">
<div class="arrow_up">
<img src="/hostcmsfiles/images/arrow_up.png" style="float: left; filter: alpha(opacity=0); margin: 0px 0px -4px 0px" alt="по возрастанию"/>
</div>
</xsl:when>
<xsl:otherwise>
<div class="arrow_up_gray">
<a href="{$filter}{$first_symbol}sort_by_field=1&order_direction=1" class="without_decor">
<img src="/hostcmsfiles/images/arrow_up_gray.png" alt="по возрастанию"/>
</a>
</div>
</xsl:otherwise>
</xsl:choose>
<xsl:choose>
<xsl:when test="/shop/sort_by_field = 1 and /shop/order_direction = 'DESC'">
<div class="arrow_down">
<img src="/hostcmsfiles/images/arrow_down.png" alt="по убыванию"/>
</div>
</xsl:when>
<xsl:otherwise>
<div class="arrow_down_gray">
<a href="{$filter}{$first_symbol}sort_by_field=1&order_direction=2" class="without_decor">
<img src="/hostcmsfiles/images/arrow_down_gray.png" alt="по убыванию"/>
</a>
</div>
</xsl:otherwise>
</xsl:choose><div style="float:left;">, по цене</div>
<xsl:choose>
<xsl:when test="/shop/sort_by_field = 2 and /shop/order_direction = 'ASC'">
<div class="arrow_up">
<img src="/hostcmsfiles/images/arrow_up.png" alt="по возрастанию"/>
</div>
</xsl:when>
<xsl:otherwise>
<div class="arrow_up_gray">
<a href="{$filter}{$first_symbol}sort_by_field=2&order_direction=1" class="without_decor">
<img src="/hostcmsfiles/images/arrow_up_gray.png" alt="по возрастанию"/></a>
</div>
</xsl:otherwise>
</xsl:choose>
<xsl:choose>
<xsl:when test="/shop/sort_by_field = 2 and /shop/order_direction = 'DESC'">
<div class="arrow_down">
<img src="/hostcmsfiles/images/arrow_down.png" style="filter: alpha(opacity=0); margin: 0px 0px -4px 0px" alt="по убыванию"/>
</div>
</xsl:when>
<xsl:otherwise>
<div class="arrow_down_gray">
<a href="{$filter}{$first_symbol}sort_by_field=2&order_direction=2" class="without_decor">
<img src="/hostcmsfiles/images/arrow_down_gray.png" alt="по убыванию"/>
</a>
</div>
</xsl:otherwise>
</xsl:choose>
<div class="clear"></div>
</div>
<!-- Определяем ссылку с параметрами фильтра -->
<xsl:variable name="filter">
<xsl:choose>
<xsl:when test="/shop/apply_filter/node()">?action=apply_filter&producer_id=<xsl:value-of select="/shop/producer_id"/>&saller_id=<xsl:value-of select="/shop/saller_id"/>&price_from=<xsl:value-of select="/shop/price_from"/>&price_to=<xsl:value-of select="/shop/price_to"/>&on_page=<xsl:value-of select="/shop/on_page"/>
<xsl:if test="/shop/property_xml/node()">
<!-- GET для доп. свойств -->
<xsl:value-of select="/shop/property_xml"/>
</xsl:if>
</xsl:when>
<xsl:otherwise></xsl:otherwise>
</xsl:choose>
</xsl:variable>
<!-- Определяем первый символ вопрос или амперсанд -->
<xsl:variable name="first_symbol">
<xsl:choose>
<xsl:when test="$filter != ''">&</xsl:when>
<xsl:otherwise>?</xsl:otherwise>
</xsl:choose>
</xsl:variable>
<!-- Вывод товаров -->
<div class="content_items_line_in_catalog">
<xsl:choose>
<xsl:when test="/shop/selected_tags/tag/tag_path_name = 'optika'">
<xsl:apply-templates select="item" mode="first"/>
</xsl:when>
<xsl:otherwise>
<table width="100%" cellpadding="0" cellspacing="0" class="table-catalog">
<tr>
<th>Фото</th>
<th>Артикул</th>
<th>Наименование</th>
<th>Год</th>
<th>Оригинальный №</th>
<th>Цена</th>
<th></th>
<th>Наличие</th>
</tr>
<xsl:apply-templates select="item" mode="second"/>
</table>
</xsl:otherwise>
</xsl:choose>
<div class="clear"></div>
</div>
<xsl:if test="count_items > 0 and items_on_page > 0 and count_items > items_on_page">
<xsl:variable name="count_pages" select="ceiling(count_items div items_on_page)"/>
<xsl:variable name="visible_pages" select="5"/>
<xsl:variable name="real_visible_pages"><xsl:choose>
<xsl:when test="$count_pages < $visible_pages"><xsl:value-of select="$count_pages"/></xsl:when>
<xsl:otherwise><xsl:value-of select="$visible_pages"/></xsl:otherwise>
</xsl:choose></xsl:variable>
<!-- Считаем количество выводимых ссылок перед текущим элементом -->
<xsl:variable name="pre_count_page"><xsl:choose>
<xsl:when test="current_page - (floor($real_visible_pages div 2)) < 0">
<xsl:value-of select="current_page"/>
</xsl:when>
<xsl:when test="($count_pages - current_page - 1) < floor($real_visible_pages div 2)">
<xsl:value-of select="$real_visible_pages - ($count_pages - current_page - 1) - 1"/>
</xsl:when>
<xsl:otherwise>
<xsl:choose>
<xsl:when test="round($real_visible_pages div 2) = $real_visible_pages div 2">
<xsl:value-of select="floor($real_visible_pages div 2) - 1"/>
</xsl:when>
<xsl:otherwise>
<xsl:value-of select="floor($real_visible_pages div 2)"/>
</xsl:otherwise>
</xsl:choose>
</xsl:otherwise>
</xsl:choose></xsl:variable>
<!-- Считаем количество выводимых ссылок после текущего элемента -->
<xsl:variable name="post_count_page"><xsl:choose>
<xsl:when test="0 > current_page - (floor($real_visible_pages div 2) - 1)">
<xsl:value-of select="$real_visible_pages - current_page - 1"/>
</xsl:when>
<xsl:when test="($count_pages - current_page - 1) < floor($real_visible_pages div 2)">
<xsl:value-of select="$real_visible_pages - $pre_count_page - 1"/>
</xsl:when>
<xsl:otherwise>
<xsl:value-of select="$real_visible_pages - $pre_count_page - 1"/>
</xsl:otherwise>
</xsl:choose></xsl:variable>
<xsl:variable name="i"><xsl:choose>
<xsl:when test="current_page + 1 = $count_pages"><xsl:value-of select="current_page - $real_visible_pages + 1"/></xsl:when>
<xsl:when test="current_page - $pre_count_page > 0"><xsl:value-of select="current_page - $pre_count_page"/></xsl:when>
<xsl:otherwise>0</xsl:otherwise>
</xsl:choose></xsl:variable>
<div class="pages">
<xsl:call-template name="for">
<xsl:with-param name="items_on_page" select="items_on_page"/>
<xsl:with-param name="current_page" select="current_page"/>
<xsl:with-param name="count_items" select="count_items"/>
<xsl:with-param name="i" select="$i"/>
<xsl:with-param name="post_count_page" select="$post_count_page"/>
<xsl:with-param name="pre_count_page" select="$pre_count_page"/>
<xsl:with-param name="visible_pages" select="$real_visible_pages"/>
</xsl:call-template>
</div>
<div class="clear"></div>
</xsl:if>
</form>
</xsl:if>
</xsl:template>
<!-- Цикл с шагом 10 для select'a количества элементов на страницу -->
<xsl:template name="for_on_page">
<xsl:param name="i" select="0"/>
<xsl:param name="n"/>
<option value="{$i}">
<xsl:if test="$i = /shop/on_page">
<xsl:attribute name="selected">
</xsl:attribute>
</xsl:if>
<xsl:value-of select="$i"/>
</option>
<xsl:if test="$n > $i">
<!-- Рекурсивный вызов шаблона -->
<xsl:call-template name="for_on_page">
<xsl:with-param name="i" select="$i + 10"/>
<xsl:with-param name="n" select="$n"/>
</xsl:call-template>
</xsl:if>
</xsl:template>
<!-- Шаблон для групп товара -->
<xsl:template match="group">
<xsl:variable name="parent_id" select="@parent"/>
<!-- Если был передан тег, допишем в ссылки с группы -->
<xsl:variable name="tagpath">
<xsl:choose>
<xsl:when test="count(/shop/selected_tags/tag) > 0">tag/<xsl:value-of select="/shop/selected_tags/tag/tag_path_name" />/</xsl:when>
<xsl:otherwise></xsl:otherwise>
</xsl:choose>
</xsl:variable>
<td width="33%" valign="top">
<div style="margin-bottom:10px;">
<a href="{/shop/path}{fullpath}{$tagpath}" style="font-weight: bold">
<xsl:value-of disable-output-escaping="yes" select="name"/>
</a> <span style="color: #aaaaaa">(<xsl:value-of select="count_all_items"/>)</span>
<xsl:if test="count(group) > 1">
<xsl:apply-templates select="group" mode="sub_group"/>
</xsl:if>
</div>
</td>
<xsl:if test="position() mod 3 = 0">
<xsl:text disable-output-escaping="yes">
</tr>
<tr>
</xsl:text>
</xsl:if>
</xsl:template>
<!-- Шаблон для подразделов -->
<xsl:template match="group" mode="sub_group">
<a href="{/shop/path}{fullpath}">
<xsl:value-of disable-output-escaping="yes" select="name"/>
</a>
<xsl:variable name="parent_id" select="@parent"/>
<!-- Ставим запятую после группы, за которой следуют еще группы из данной родителской группы -->
<xsl:if test="position() != last() and count(//group[@parent = $parent_id]) > 1">, </xsl:if>
</xsl:template>
<!-- Шаблон для товара -->
<xsl:template match="item" mode="first">
<!-- Определяем цвет фона -->
<xsl:variable name="background_color">
<xsl:choose>
<xsl:when test="(position() + 1) mod 2 > 0">#f7f7f7</xsl:when>
<xsl:otherwise>#ffffff</xsl:otherwise>
</xsl:choose>
</xsl:variable>
<div class="content_item_in_catalog">
<!-- Изображение для товара, если есть -->
<xsl:choose>
<xsl:when test="small_image!=''">
<a href="{/shop/path}{fullpath}{path}/">
<img src="/images/nophoto_small.jpg" width="169" height="88" alt="" />
</a>
</xsl:when>
<xsl:otherwise>
<a href="{/shop/path}{fullpath}{path}/">
<img src="/images/catalog/{marking_of_goods}.jpg" width="169" height="88" alt="" />
</a>
</xsl:otherwise>
</xsl:choose>
<!-- Название товара -->
<p><a href="{/shop/path}{fullpath}{path}/" class="item_title">
<xsl:value-of disable-output-escaping="yes" select="name"/>
</a><br />
<span class="code">
<xsl:value-of select="property[@xml_name = 'depo_number']/value"/>
</span></p>
<!-- Цена товара -->
<p class="price">
<xsl:choose>
<xsl:when test="price_discount != 0">
<xsl:variable name="price" select="price_discount"/>
<xsl:value-of select="format-number($price, '### ##0', 'my')"/> <xsl:value-of disable-output-escaping="yes" select="currency"/>
</xsl:when>
<xsl:otherwise>
цена договорная
</xsl:otherwise>
</xsl:choose>
<!-- Ссылку на добавление в корзины выводим, если:
type != 1 - простой тип товара или делимый (0 - простой, 2 - делимый)
type = 1 - электронный товар, при этом остаток на складе больше 0 или -1,
что означает неограниченное количество -->
<xsl:if test="type != 1 or (type = 1 and (eitem_count > 0 or eitem_count = -1))">
<input type="hidden" size="3" value="1" id="count_{@id}"/>
<a href="{/shop/path}cart/?action=add&item_id={@id}" onclick="return AddIntoCart('{/shop/path}', {@id}, document.getElementById('count_{@id}').value)">
<img alt="В корзину" title="В корзину" src="/images/cart.png" style="margin:0 0 -4px 10px" />
</a>
</xsl:if>
</p>
</div>
<!-- На строку - не более 3-х пунктов, если уже 3 выведено - начинаем новую строку -->
<xsl:if test="position() mod 3 = 0 and position() != last()">
<xsl:text disable-output-escaping="yes">
<div class="clear"></div>
</div>
<div class="content_items_line_in_catalog">
</xsl:text>
</xsl:if>
</xsl:template>
<!-- Шаблон для товара (таблица) -->
<xsl:template match="item" mode="second">
<tr>
<td width="25" align="center">
<!-- Изображение для товара, если есть -->
<xsl:choose>
<xsl:when test="small_image!=''">
</xsl:when>
<xsl:otherwise>
<a href="/images/catalog/{marking_of_goods}.jpg" class="lightbox">
<img src="/images/camera.png" width="16" height="16" alt="" style="vertical-align:middle;" />
</a>
</xsl:otherwise>
</xsl:choose>
</td>
<td align="center">
<xsl:choose>
<xsl:when test="marking_of_goods != ''">
<xsl:value-of disable-output-escaping="yes" select="marking_of_goods"/>
</xsl:when>
<xsl:otherwise>
<xsl:value-of select="property[@xml_name = 'depo_number']/value"/>
</xsl:otherwise>
</xsl:choose>
</td>
<td width="300">
<a href="{/shop/path}{fullpath}{path}/">
<xsl:value-of disable-output-escaping="yes" select="name"/>
</a>
</td>
<td align="center"><xsl:value-of select="property[@xml_name = 'model_year']/value"/></td>
<td align="center">
<div class="divide-line">
<xsl:value-of select="property[@xml_name = 'original_number']/value"/>
</div>
</td>
<!-- Цена товара -->
<td width="85" align="right" style="color:#2365b0; font-weight:bold;">
<xsl:choose>
<xsl:when test="price_discount != 0">
<xsl:variable name="price" select="price_discount"/>
<xsl:value-of select="format-number($price, '### ##0', 'my')"/> <xsl:value-of disable-output-escaping="yes" select="currency"/>
</xsl:when>
<xsl:otherwise>
звоните
</xsl:otherwise>
</xsl:choose>
</td>
<td>
<!-- Ссылку на добавление в корзины выводим, если:
type != 1 - простой тип товара или делимый (0 - простой, 2 - делимый)
type = 1 - электронный товар, при этом остаток на складе больше 0 или -1,
что означает неограниченное количество -->
<xsl:if test="(type != 1 or (type = 1 and (eitem_count > 0 or eitem_count = -1))) and property[@xml_name = 'waiting']/value != 'нет'">
<input type="hidden" size="3" value="1" id="count_{@id}"/>
<a href="{/shop/path}cart/?action=add&item_id={@id}" onclick="return AddIntoCart('{/shop/path}', {@id}, document.getElementById('count_{@id}').value)">
<img alt="В корзину" title="В корзину" src="/images/cart.png" width="16" style="margin:0 0 -4px 10px" />
</a>
</xsl:if>
</td>
<td align="center">
<xsl:choose>
<xsl:when test="property[@xml_name = 'waiting']/value = 'нет'">
<xsl:attribute name="style">color:red</xsl:attribute>
</xsl:when>
<xsl:otherwise>
<xsl:attribute name="style">color:green</xsl:attribute>
</xsl:otherwise>
</xsl:choose>
<xsl:value-of select="property[@xml_name = 'waiting']/value"/>
</td>
</tr>
</xsl:template>
<!-- Цикл для вывода строк ссылок -->
<xsl:template name="for">
<xsl:param name="items_on_page"/>
<xsl:param name="current_page"/>
<xsl:param name="pre_count_page"/>
<xsl:param name="post_count_page"/>
<xsl:param name="i" select="0"/>
<xsl:param name="count_items"/>
<xsl:param name="visible_pages"/>
<xsl:variable name="n" select="ceiling($count_items div $items_on_page)"/>
<xsl:variable name="start_page"><xsl:choose>
<xsl:when test="$current_page + 1 = $n"><xsl:value-of select="$current_page - $visible_pages + 1"/></xsl:when>
<xsl:when test="$current_page - $pre_count_page > 0"><xsl:value-of select="$current_page - $pre_count_page"/></xsl:when>
<xsl:otherwise>0</xsl:otherwise>
</xsl:choose></xsl:variable>
<xsl:if test="$i = $start_page and $current_page != 0">
<span>
← Ctrl
</span>
</xsl:if>
<xsl:if test="$i = ($current_page + $post_count_page + 1) and $n != ($current_page+1)">
<span>
Ctrl →
</span>
</xsl:if>
<xsl:if test="$count_items > $items_on_page and ($current_page + $post_count_page + 1) > $i">
<!-- Заносим в переменную $parent_group_id идентификатор текущей группы -->
<xsl:variable name="parent_group_id" select="/shop/@current_group_id"/>
<!-- Путь для тэга -->
<xsl:variable name="tag_path">
<xsl:if test="count(/shop/selected_tags/tag) = 1">tag/<xsl:value-of select="/shop/selected_tags/tag/tag_path_name"/>/</xsl:if>
</xsl:variable>
<!-- Определяем группу для формирования адреса ссылки -->
<xsl:variable name="group_link">
<xsl:choose>
<!-- Если группа не корневая (!=0) -->
<xsl:when test="$parent_group_id != 0">
<xsl:value-of select="/shop//group[@id=$parent_group_id]/fullpath"/>
</xsl:when>
<!-- Иначе если нулевой уровень - просто ссылка на страницу со списком элементов -->
<xsl:otherwise></xsl:otherwise>
</xsl:choose>
</xsl:variable>
<!-- Определяем адрес ссылки -->
<xsl:variable name="number_link">
<xsl:choose>
<!-- Если не нулевой уровень -->
<xsl:when test="$i != 0">page-<xsl:value-of select="$i + 1"/>/</xsl:when>
<!-- Иначе если нулевой уровень - просто ссылка на страницу со списком элементов -->
<xsl:otherwise></xsl:otherwise>
</xsl:choose>
</xsl:variable>
<!-- Передаем фильтр -->
<xsl:variable name="filter">
<xsl:choose>
<xsl:when test="/shop/apply_filter/node()">?action=apply_filter&producer_id=<xsl:value-of select="/shop/producer_id"/>&saller_id=<xsl:value-of select="/shop/saller_id"/>&price_from=<xsl:value-of select="/shop/price_from"/>&price_to=<xsl:value-of select="/shop/price_to"/>&on_page=<xsl:value-of select="/shop/on_page"/>
<xsl:if test="/shop/property_xml/node()">
<!-- GET для доп. свойств -->
<xsl:value-of select="/shop/property_xml"/>
</xsl:if>
</xsl:when>
<xsl:otherwise></xsl:otherwise>
</xsl:choose>
</xsl:variable>
<!-- Определяем первый символ вопрос или амперсанд -->
<xsl:variable name="first_symbol">
<xsl:choose>
<xsl:when test="$filter != ''">&</xsl:when>
<xsl:otherwise>?</xsl:otherwise>
</xsl:choose>
</xsl:variable>
<!-- Данные для стрелок сортировки -->
<xsl:variable name="arrows">
<xsl:choose>
<xsl:when test="(/shop/sort_by_field = 1) or (/shop/sort_by_field = 2)">
<xsl:choose>
<!-- Стрелка вверх -->
<xsl:when test="/shop/order_direction = 'ASC'">
<xsl:value-of select="$first_symbol"/>sort_by_field=<xsl:value-of select="/shop/sort_by_field"/>&order_direction=1</xsl:when>
<!-- Стрелка вниз -->
<xsl:otherwise>
<xsl:value-of select="$first_symbol"/>sort_by_field=<xsl:value-of select="/shop/sort_by_field"/>&order_direction=2</xsl:otherwise>
</xsl:choose>
</xsl:when>
<xsl:otherwise></xsl:otherwise>
</xsl:choose>
</xsl:variable>
<!-- Выводим ссылку на первую страницу -->
<xsl:if test="$current_page - $pre_count_page > 0 and $i = $start_page">
<span><a href="{/shop/path}{$group_link}{$tag_path}{$filter}{$arrows}" class="page_link" style="text-decoration: none;">←</a></span>
</xsl:if>
<!-- Ставим ссылку на страницу-->
<xsl:if test="$i != $current_page">
<xsl:if test="($current_page - $pre_count_page) <= $i and $i < $n">
<!-- Выводим ссылки на видимые страницы -->
<span><a href="{/shop/path}{$group_link}{$tag_path}{$number_link}{$filter}{$arrows}" class="page_link">
<xsl:value-of select="$i + 1"/>
</a></span>
</xsl:if>
<!-- Выводим ссылку на последнюю страницу -->
<xsl:if test="$i+1 >= ($current_page + $post_count_page + 1) and $n > ($current_page + 1 + $post_count_page)">
<!-- Выводим ссылку на последнюю страницу -->
<span><a href="{/shop/path}{$group_link}{$tag_path}page-{$n}/{$filter}{$arrows}" class="page_link" style="text-decoration: none;">→</a></span>
</xsl:if>
</xsl:if>
<!-- Ссылка на предыдущую страницу для Ctrl + влево -->
<xsl:if test="$current_page != 0 and $i = $current_page">
<xsl:variable name="prev_number_link">
<xsl:choose>
<!-- Если не нулевой уровень -->
<xsl:when test="($current_page - 1) != 0">page-<xsl:value-of select="$i"/>/</xsl:when>
<!-- Иначе если нулевой уровень - просто ссылка на страницу со списком элементов -->
<xsl:otherwise></xsl:otherwise>
</xsl:choose>
</xsl:variable>
<a href="{/shop/path}{$group_link}{$tag_path}{$prev_number_link}{$filter}{$arrows}" id="id_prev"></a>
</xsl:if>
<!-- Ссылка на следующую страницу для Ctrl + вправо -->
<xsl:if test="($n - 1) > $current_page and $i = $current_page">
<a href="{/shop/path}{$group_link}{$tag_path}page-{$current_page+2}/{$filter}{$arrows}" id="id_next"></a>
</xsl:if>
<!-- Не ставим ссылку на страницу-->
<xsl:if test="$i = $current_page">
<span class="cur_page">
<xsl:value-of select="$i+1"/>
</span>
</xsl:if>
<!-- Рекурсивный вызов шаблона. НЕОБХОДИМО ПЕРЕДАВАТЬ ВСЕ НЕОБХОДИМЫЕ ПАРАМЕТРЫ! -->
<xsl:call-template name="for">
<xsl:with-param name="i" select="$i + 1"/>
<xsl:with-param name="items_on_page" select="$items_on_page"/>
<xsl:with-param name="current_page" select="$current_page"/>
<xsl:with-param name="count_items" select="$count_items"/>
<xsl:with-param name="pre_count_page" select="$pre_count_page"/>
<xsl:with-param name="post_count_page" select="$post_count_page"/>
<xsl:with-param name="visible_pages" select="$visible_pages"/>
</xsl:call-template>
</xsl:if>
</xsl:template>
</xsl:stylesheet>
HostCMS, подскажите пожалуйста, есть ли возможность отключить. Может я что лишнее скинул (просто решил все что может помочь в ответе)?
А то уж больно база быстро растет, хочется как-то уменьшить нагрузку. А то при 700 посетителях в день 75%-80% суточных лимитов виртуального хостинга выбирается.
А то уж больно база быстро растет, хочется как-то уменьшить нагрузку. А то при 700 посетителях в день 75%-80% суточных лимитов виртуального хостинга выбирается.
onlinestudio,
а где же Вы отключаете то? 'xml_show_all_count_items_and_group' у Вас нет!
а где же Вы отключаете то? 'xml_show_all_count_items_and_group' у Вас нет!
HostCMS,
я пробовал добавить перед вызовом ShowShop:
$param['xml_show_all_count_items_and_groups'] = false;
Но количество групп все равно выдает, а в API я вообще для метода ShowShop не нашел xml_show_all_count_items_and_groups.
я пробовал добавить перед вызовом ShowShop:
$param['xml_show_all_count_items_and_groups'] = false;
Но количество групп все равно выдает, а в API я вообще для метода ShowShop не нашел xml_show_all_count_items_and_groups.
HostCMS, помогите пожалуйста. Вчера снова пробовал дописать $param['xml_show_all_count_items_and_groups'] = false; но я не вижу изменений.
И как будет правильно, например:
// Запрещаем передачу в XML свойств групп
$param['xml_show_group_property'] = true; - это запрещено?
$param['xml_show_group_property'] = false; - или это?
И как будет правильно, например:
// Запрещаем передачу в XML свойств групп
$param['xml_show_group_property'] = true; - это запрещено?
$param['xml_show_group_property'] = false; - или это?
onlinestudio,
версия какая?
а каким образом $param['xml_show_group_property'] = false; относится к подсчету товаров в группах???
версия какая?
а каким образом $param['xml_show_group_property'] = false; относится к подсчету товаров в группах???
HostCMS, версия 5.9.36.
$param['xml_show_group_property'] = false; // никак не относится, это я решил заодно уточнить
просто в стандартном шаблоне типовой динамической страницы прописано:
// Запрещаем передачу в XML свойств групп
$param['xml_show_group_property'] = true;
и я хотел помимо основного вопроса, уточнить про это true (это запрещено или разрешено).
$param['xml_show_group_property'] = false; // никак не относится, это я решил заодно уточнить
просто в стандартном шаблоне типовой динамической страницы прописано:
// Запрещаем передачу в XML свойств групп
$param['xml_show_group_property'] = true;
и я хотел помимо основного вопроса, уточнить про это true (это запрещено или разрешено).
onlinestudio писал(а):
это вы разрешаете, для запрета нужно передать false
// Запрещаем передачу в XML свойств групп
$param['xml_show_group_property'] = true;
$param['xml_show_group_property'] = true;
это вы разрешаете, для запрета нужно передать false
Авторизация