Корзина генерирует слишком много запросов

#
Корзина генерирует слишком много запросов
Может быть кто-то сталкивался с подобной проблемой ? Корзина секунд 5-10 открывается визуально, отладочная информация такая:
Время выполнения: 3.602 с, из них

    время загрузки модулей: 0.000 с
    время генерации содержания страницы: 3.591 с
    время соединения с СУБД: 0.000 с
    время выбора БД: 0.000 с
    время выполнения запросов: 0.169 с
    время обработки XML: 0.112 с

Использовано памяти: 110.06 Мб.
Количество запросов: 1619.
Компрессия: Включено.
Кэширование: Включено.

    время записи в кэш: 0.614 с
    запросов на запись: 2984
    время чтения из кэша: 0.259 с
    запросов на чтение: 4459

Тех. поддержка сказала, что причина повышеной нагрузки в этом "Количество запросов: 1619." и надо как-то это оптимизировать, но я сколько ни смотрел в шаблон так и не понял каким образом это сделать. Может быть убрать проверки на "отложенный товар" , идентификацию пользователя и.т.д. ?  Вот XML странички:

<?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:variable name="recount" select="recount"/>
   
   <xsl:template match="/cart">
      <xsl:choose>
         <xsl:when test="(count_item=0) and (count_postpone_item=0)">
            <!-- В корзине нет ни одного элемента --><br/><br/>
            <p class="title">В корзине нет ни одного товара.</p>
            
            <p>
               <xsl:choose>
                  <xsl:when test="user_id != 0">Для оформления заказа добавьте товар в корзину.</xsl:when>
                  <xsl:when test="site_users_class_exists = 1"><!--В корзине нет ни одного товара--></xsl:when>
                  <xsl:otherwise></xsl:otherwise>
               </xsl:choose>
            </p>
         </xsl:when>
         <xsl:otherwise>
            <!-- Вывод корзины -->
            <h1>Моя корзина</h1>
            
            <p>Для оформления заказа, нажмите &#171;Оформить заказ&#187;.</p>
            
            <form action="{/cart/shop/path}cart/" name="address" method="POST">
               <!-- Если есть товары -->
               <xsl:if test="count(itemincart[flag_postpone = 0]) > 0">
                  <table cellspacing="0" cellpadding="0" border="0" class="shop_cart_table">
                     <tr>
                        <th>Товар</th>
                        <!--<td width="70">Вес</td>-->
                        <th width="70">Кол-во</th>
                        <th width="100">Цена</th>
                        <th width="100">Сумма</th>
                        <!-- <xsl:if test="/cart/shop/warehouses/node()">
                           <th width="100">Склад</th>
                        </xsl:if>
                        <th>Отложить</th> -->
                        <th>Действия</th>
                     </tr>
                     <xsl:apply-templates select="itemincart[flag_postpone = 0]"/>
                     <tr class="shop_cart_table">
                        <td>
                           <b>Итого:</b>
                        </td>
                        <td>
                           <b>
                              <xsl:value-of disable-output-escaping="yes" select="totalquantity"/>
                           </b>
                        </td>
                        <td>&#xA0;</td>
                        <td style="white-space: nowrap">
                           <xsl:value-of select="format-number(total_sum_without_discount,'### ##0', 'my')"/>&#xA0;<xsl:value-of disable-output-escaping="yes" select="shop/shop_currency/shop_currency_name"/>
                        </td>
                        
                        <!-- <xsl:if test="/cart/shop/warehouses/node()">
                           <td>&#xA0;</td>
                        </xsl:if>
                        
                        <td>&#xA0;</td> -->
                        <td>&#xA0;</td>
                     </tr>
                     <xsl:if test="total_sum_without_discount &gt; totalsum">
                        <tr class="shop_cart_table">
                           <!--<td style="border-bottom: thin dashed #DADADA">
                              &#xA0;
                           </td>-->
                           <td style="border-bottom: thin dashed #DADADA">
                              <b>Скидка:</b>
                           </td>
                           <td style="border-bottom: thin dashed #DADADA">&#xA0;</td>
                           <td style="border-bottom: thin dashed #DADADA">&#xA0;</td>
                           <td style="border-bottom: thin dashed #DADADA; white-space: nowrap; font-weight: bold">
                              <b>
                                 <xsl:value-of disable-output-escaping="yes" select="format-number(total_sum_without_discount - totalsum, '### ##0', 'my')"/>&#xA0;<xsl:value-of disable-output-escaping="yes" select="shop/shop_currency/shop_currency_name"/></b>
                           </td>
                           <xsl:if test="/cart/shop/warehouses/node()">
                              <td style="border-bottom: thin dashed #DADADA">&#xA0;</td>
                           </xsl:if>
                           <td style="border-bottom: thin dashed #DADADA">&#xA0;</td>
                           <td style="border-bottom: thin dashed #DADADA">&#xA0;</td>
                        </tr>
                        <tr class="shop_cart_table">
                           <!--<td style="border-bottom: none">
                              &#xA0;
                           </td>-->
                           <td style="border-bottom: none">
                              <b>Всего:</b>
                           </td>
                           <td style="border-bottom: none">&#xA0;</td>
                           <td style="border-bottom: none">&#xA0;</td>
                           <td style="border-bottom: none; white-space: nowrap; font-weight: bold">
                              <xsl:value-of disable-output-escaping="yes" select="format-number(totalsum, '### ##0', 'my')"/>&#xA0;<xsl:value-of disable-output-escaping="yes" select="shop/shop_currency/shop_currency_name"/>
                           </td>
                           <td style="border-bottom: none">&#xA0;</td>
                           <xsl:if test="/cart/shop/warehouses/node()">
                              <td style="border-bottom: none">&#xA0;</td>
                           </xsl:if>
                           <td style="border-bottom: none">&#xA0;</td>
                           <td style="border-bottom: none">&#xA0;</td>
                        </tr>
                     </xsl:if>
                  </table>
                  
                  <div style="clear: both; height: 20px;"></div>
               </xsl:if>
               
               <!-- Если есть отложенные товары -->
               <xsl:if test="count(itemincart[flag_postpone = 1]) &gt; 0">
                  <h2>Отложенные товары</h2>
                  <div class="gray">
                     <table cellspacing="0" cellpadding="0" border="0" class="shop_cart_table">
                        <tr>
                           <th>Товар</th>
                           <!--<td width="70">Вес</td>-->
                           <th width="70">Кол-во</th>
                           <th width="100">Цена</th>
                           <th width="100">Сумма</th>
                           <th>Отложить</th>
                           <th>Действия</th>
                        </tr>
                        <xsl:apply-templates select="itemincart[flag_postpone = 1]"/>
                        <tr class="shop_cart_table">
                           <td>
                              <b>Итого:</b>
                           </td>
                           <td>
                              <b>
                                 <xsl:value-of disable-output-escaping="yes" select="totalquantity_postpone_item"/>
                              </b>
                           </td>
                           <td>&#xA0;</td>
                           <td style="white-space: nowrap">
                              <xsl:value-of disable-output-escaping="yes" select="format-number(totalsum_postpone_item,'### ##0', 'my')"/>&#xA0;<xsl:value-of disable-output-escaping="yes" select="shop/shop_currency/shop_currency_name"/>
                           </td>
                           <td>&#xA0;</td>
                           <td>&#xA0;</td>
                        </tr>
                     </table>
                  </div>
               </xsl:if>
               
               <!-- Купон -->
               <!-- <div style="padding: 15px 0px 5px 0px;">
                  Купон:&#xA0;
                  <input name="shop_coupon_text" type="text" value="{coupon_text}" style="margin-right: 20px"/>
               </div> -->
               
               <!-- Кнопки -->
               <div class="gray_button" style="float: left;">
                  <div>
               <button name="recount" type="submit"><i></i>Пересчитать<b></b></button>
                     <!-- <input name="recount" value="Пересчитать" type="submit" /> -->
                  </div>
               </div>
               
               <xsl:choose>
                  <xsl:when test="site_users_class_exists = 1"></xsl:when>
                  <xsl:otherwise>
                     
                     <h1>Данные о заказчике</h1>
                     
                     <!-- Выводим сообщение -->
                     <xsl:if test="/cart/message/node()">
                        <div id="message">
                           <xsl:value-of disable-output-escaping="yes" select="/cart/message"/>
                        </div>
                     </xsl:if>
                     
                     <p style="color: #707070">
                     Поля, отмеченные <span class="red_star" style="position: relative; top: 6px;"> *</span>, обязательны для заполнения.
                     </p>
                     
                     <!-- В случае если отключен модуль пользователей сайта, запрашиваем информацию
                     о пользователе сайта здесь -->
                     <table cellspacing="0" cellpadding="0" border="0" class="shop_cart_table">
                        <tr>
                           <td>Фамилия:</td>
                           <td>
                              <input name="site_users_surname" type="text" value="{site_users_surname}" size="40"/>
                           </td>
                           <td class="red_star"> *</td>
                        </tr>
                        <tr>
                           <td>Имя:</td>
                           <td>
                              <input name="site_users_name" type="text" value="{site_users_name}" size="40"/>
                           </td>
                           <td class="red_star"> *</td>
                        </tr>
                        <tr>
                           <td>Отчество:</td>
                           <td>
                              <input name="site_users_patronymic" type="text" value="{site_users_patronymic}" size="40"/>
                           </td>
                        </tr>
                        <tr>
                           <td>Компания:</td>
                           <td>
                              <input name="site_users_company" type="text" value="{site_users_company}" size="40"/>
                           </td>
                        </tr>
                        <tr>
                           <td>E-mail:</td>
                           <td>
                              <input name="site_users_email" type="text" value="{site_users_email}" size="40"/>
                           </td>
                           <td class="red_star"> *</td>
                        </tr>
                        <tr>
                           <td>Телефон:</td>
                           <td>
                              <input name="site_users_phone" type="text" value="{site_users_phone}" size="40"/>
                           </td>
                        </tr>
                        <tr>
                           <td>Факс:</td>
                           <td>
                              <input name="site_users_fax" type="text" value="{site_users_fax}" size="40"/>
                           </td>
                        </tr>
                        <tr>
                           <td>Адрес:</td>
                           <td>
                              <input name="site_users_address" type="text" value="{site_users_address}" size="40"/>
                           </td>
                        </tr>
                     </table>
                     
                     <!-- Добавляем скрытое поле с указанием подшага -->
                     <input name="step_1_1a" type="hidden" value="1"/>
                  </xsl:otherwise>
               </xsl:choose>
               <!-- <xsl:if test="count(itemincart[flag_postpone = 0]) > 0 and (user_id != 0 or site_users_class_exists = 0)"> -->
                  <xsl:if test="count(itemincart[flag_postpone = 0]) > 0">
                     <div class="gray_button" style="float: right;">
                        <div>
                     <button name="step_1" type="submit"><i></i>Оформить заказ<b></b></button>
                           <!-- <input name="step_1" value="Оформить заказ" type="submit" style="font-weight: bold"/> -->
                           <xsl:if test="user_id=0"><input name="step_1_1a" type="hidden" value="1"/></xsl:if>
                        </div>
                     </div>
                  </xsl:if>
               </form>
            </xsl:otherwise>
         </xsl:choose>
         
         <div class="clear"></div>
      </xsl:template>
      
      <!-- Шаблон для товара в корзине -->
      <xsl:template match="itemincart">
         
         <!-- Получаем ID родительской группы и записываем в переменную $parent_group_id -->
         <xsl:variable name="parent_group_id" select="/shop/@current_group_id"/>
         
         <tr class="shop_cart_table">
            
            <td>
               
               <a href="{/cart/shop/path}{item/fullpath}{item/path}/">
                  <xsl:value-of disable-output-escaping="yes" select="item/name"/>
               </a>
               
               <!-- <xsl:variable name="parent_id" select="item/@group"/>
               <xsl:variable name="parent_parent_id" select="//group[@id=$parent_id]/@parent"/>
               
               (<xsl:value-of disable-output-escaping="yes" select="//group[@id=$parent_parent_id]/name"/>&#xa0;<xsl:value-of disable-output-escaping="yes" select="//group[@id=$parent_id]/name"/>) -->
               
               
               <xsl:variable name="group" select="item/@group"/>
               <div style="font-style: italic; ">
                  <xsl:apply-templates select="//group[@id = $group]" mode="reverse"/>
               </div>
               
               
               <!--=<xsl:value-of select="/cart/shop/shop_list_of_prices//shop_list_of_price[@id = shop_list_of_prices_for_item//[shop_list_of_price_for_item = price_discount]/@id]/percent" />=-->
               <!--
               <xsl:if test="item/small_image!=''">
                  <img src="{item/small_image}"/>
               </xsl:if>
               -->
               <!-- Средняя оценка товара -->
               <xsl:if test="item/comments/average_grade/node()">
                  <div style="margin: 3px 0px 0px 0px">
                     <div style="white-space: nowrap;">
                        <xsl:call-template name="show_average_grade">
                           <xsl:with-param name="grade" select="item/comments/average_grade"/>
                           <xsl:with-param name="const_grade" select="5"/>
                        </xsl:call-template>
                        <!-- <xsl:if test="not(item/comments/average_grade/node())">
                           <xsl:call-template name="show_average_grade">
                              <xsl:with-param name="grade" select="0"/>
                              <xsl:with-param name="const_grade" select="5"/>
                           </xsl:call-template>
                        </xsl:if> -->
                     </div>
                  </div>
               </xsl:if>
               
               <div style="clear: both"></div>
            </td>
            <td style="white-space: nowrap">
               <input type="text" size="3" name="{item/@id}" id="count_{item/@id}" value="{quantity}"/>
               
               <img src="/images/map_intocart.gif" width="12" height="21" border="0" usemap="#mapInToCart{item/@id}" style="margin: 0 0 -6px 1px;"/>&#xA0;<xsl:value-of select="item/mesure" disable-output-escaping="yes"/>
               
               <map name="mapInToCart{item/@id}">
                  <area shape="rect" coords="0,0,12,10"  onclick="set_count_mod('count_{item/@id}', 1);" nohref="nohref" />
                  <area shape="rect" coords="0,11,12,21" onclick="set_count_mod('count_{item/@id}', -1);" nohref="nohref" />
               </map>
               
               
            </td>
            <td style="white-space: nowrap">
               <!-- Цена -->
               <xsl:value-of disable-output-escaping="yes" select="format-number(item/price_discount, '### ##0', 'my')"/>&#xA0;<xsl:value-of select="item/currency" disable-output-escaping="yes"/></td>
            
            <td style="white-space: nowrap">
               <!-- Сумма -->
               <xsl:value-of disable-output-escaping="yes" select="format-number(item/price_discount * quantity, '### ##0', 'my')"/>&#xA0;<xsl:value-of disable-output-escaping="yes" select="item/currency"/></td>
            
            <!-- <xsl:if test="/cart/shop/warehouses/node()">
               <td width="100">
                  <xsl:choose>
                     <xsl:when test="sum(item/warehouses/warehouse) > 0">
                        <select name="warehouse{item/@id}" style="width: 50px">
                           <xsl:apply-templates select="item/warehouses/warehouse"/>
                        </select>
                     </xsl:when>
                     <xsl:otherwise>&#8212;</xsl:otherwise>
                  </xsl:choose>
               </td>
            </xsl:if> -->
            <!-- Отложенные товары -->
            <!-- <td align="center">
               <xsl:choose>
                  <xsl:when test="flag_postpone=1">
                     <input type="checkbox" name="flag_postpone{item/@id}" checked=""/>
                  </xsl:when>
                  <xsl:otherwise>
                     <input type="checkbox" name="flag_postpone{item/@id}"/>
                  </xsl:otherwise>
               </xsl:choose>
            </td> -->
            
         <td align="center"><a href="?action=delete_item&amp;item_id={item/@id}" onclick="return confirm('Вы уверены, что хотите удалить?');" title="Удалить товар из корзины" alt="Удалить товар из корзины">Удалить</a></td>
         </tr>
      </xsl:template>
      
      <xsl:template match="group" mode="reverse">
         
         <xsl:if test="@parent">
            <xsl:variable name="parent" select="@parent"/>
            <xsl:apply-templates select="//group[@id = $parent]" mode="reverseelse"/>
         </xsl:if>
         
         
      </xsl:template>
      
      
      <xsl:template match="group" mode="reverseelse">
         
         <xsl:if test="@parent">
            <xsl:variable name="parent" select="@parent"/>
            <xsl:apply-templates select="//group[@id = $parent]" mode="reverseelse"/>
         </xsl:if>
         
         <xsl:value-of disable-output-escaping="yes" select="name"/><xsl:if test="position()=1">&#xA0;</xsl:if>
         
      </xsl:template>
      
      
      <!-- Вывод рейтинга товара -->
      <xsl:template name="show_average_grade">
         <xsl:param name="grade" select="0"/>
         <xsl:param name="const_grade" select="0"/>
         
         <!-- Чтобы избежать зацикливания -->
         <xsl:variable name="current_grade" select="$grade * 1"/>
         
         <xsl:choose>
            <!-- Если число целое -->
            <xsl:when test="floor($current_grade) = $current_grade and not($const_grade &gt; ceiling($current_grade))">
               
               <xsl:if test="$current_grade - 1 &gt; 0">
                  <xsl:call-template name="show_average_grade">
                     <xsl:with-param name="grade" select="$current_grade - 1"/>
                     <xsl:with-param name="const_grade" select="$const_grade - 1"/>
                  </xsl:call-template>
               </xsl:if>
               
               <xsl:if test="$current_grade != 0">
                  <img src="/hostcmsfiles/images/stars_single.gif"/>
               </xsl:if>
            </xsl:when>
            <xsl:when test="$current_grade != 0 and not($const_grade &gt; ceiling($current_grade))">
               
               <xsl:if test="$current_grade - 0.5 &gt; 0">
                  <xsl:call-template name="show_average_grade">
                     <xsl:with-param name="grade" select="$current_grade - 0.5"/>
                     <xsl:with-param name="const_grade" select="$const_grade - 1"/>
                  </xsl:call-template>
               </xsl:if>
               
               <img src="/hostcmsfiles/images/stars_half.gif"/>
            </xsl:when>
            
            <!-- Выводим серые звездочки, пока текущая позиция не дойдет то значения, увеличенного до целого -->
            <xsl:otherwise>
               <xsl:call-template name="show_average_grade">
                  <xsl:with-param name="grade" select="$current_grade"/>
                  <xsl:with-param name="const_grade" select="$const_grade - 1"/>
               </xsl:call-template>
               <img src="/hostcmsfiles/images/stars_gray.gif"/>
            </xsl:otherwise>
         </xsl:choose>
      </xsl:template>
      
      <!-- Шаблон для вывода звездочек (оценки) -->
      <xsl:template name="for">
         <xsl:param name="i" select="0"/>
         <xsl:param name="n"/>
         
         <input type="radio" name="shop_comment_grade" value="{$i}" id="id_shop_comment_grade_{$i}">
            <xsl:if test="/shop/shop_comment_grade = $i">
               <xsl:attribute name="checked">
               </xsl:attribute>
            </xsl:if>
         </input>&#xA0;
         <label for="id_shop_comment_grade_{$i}">
            <xsl:call-template name="show_average_grade">
               <xsl:with-param name="grade" select="$i"/>
               <xsl:with-param name="const_grade" select="5"/>
            </xsl:call-template>
         </label>
         <br/>
         <xsl:if test="$n &gt; $i and $n &gt; 1">
            <xsl:call-template name="for">
               <xsl:with-param name="i" select="$i + 1"/>
               <xsl:with-param name="n" select="$n"/>
            </xsl:call-template>
         </xsl:if>
      </xsl:template>
      
      <!-- option для склада -->
      <xsl:template match="item/warehouses/warehouse">
         <!-- Если есть остаток на складе -->
         <xsl:if test=". != 0">
            <xsl:variable name="w_id" select="@id" />
            <option value="{@id}">
               <xsl:if test="../../../shop_warehouse_id = @id">
                  <xsl:attribute name="selected">selected</xsl:attribute>
               </xsl:if>
               
               <xsl:value-of select="/cart/shop/warehouses/warehouse[@id=$w_id]/shop_warehouse_name"/> (<xsl:value-of select="."/>)
            </option>
         </xsl:if>
      </xsl:template>
      
   </xsl:stylesheet>
Модератор
#
Re: Корзина генерирует слишком много запросов
а Вы разделом не ошиблись? Это про шестую версию.
#
Re: Корзина генерирует слишком много запросов
Тьфу ты, второй раз на те же грабли, совсем с компьютером не дружу
Ошибся потому что у нас 6.0.9 версия HostCMS, но видно после обновления никто не отключил Api 5-ой версии и не конвертировал шаблоны
Попробую перевести на Api 6-ой версии, воспользовавшись инструкцией из закрепленной темы в соседнем разделе. Вообще чисто теоретически перевод на api 6-ой версии может хоть чем-то помочь в этом плане ?
Модератор
#
Re: Корзина генерирует слишком много запросов
AnykeyZIP,
Может, мы рекомендуем использовать режим эмуляции только в крайних случаях, чистый API-6 намного быстрее, т.к. нет дополнительной прослойки.
Авторизация