Проблема с фильтром

#
Проблема с фильтром
Здравствуйте, на сайте вывожу фильтр, ниже код.
Каталог сделан на главной странице, списки вывелись в фильтр, цены(максимальная и минимальная) почему то не подгружаются, пытаюсь отфильтровать товары, находясь в группе http://specte.ru/monety-sssr/monety-sssr-1924-1958/
При нажатии кнопки применить в фильтре  перебрасывает на главную страницу, хотя должно фильтровать в текущей категории
http://specte.ru/?sorting=0&price_from=&price_to=&price_from_original=&price_to_original=&property_136=920&property_137=&filter=%D0%9F%D1%80%D0%B8%D0%BC%D0%B5%D0%BD%D0%B8%D1%82%D1%8C
<?
                            //фильтр
                            if (Core::moduleIsActive('shop'))
                            {
                                
                                $Shop_Controller_Show = new Shop_Controller_Show(
                                    Core_Entity::factory('Shop', 3)
                                );
                                                        
                                if (Core_Array::getGet('filter') || Core_Array::getGet('sorting'))
                                {
                                    $Shop_Controller_Show->addEntity(
                                        Core::factory('Core_Xml_Entity')
                                            ->name('filter')->value(1)
                                    );

                                    $oShop = $Shop_Controller_Show->getEntity();

                                    $sorting = intval(Core_Array::getGet('sorting'));
                                    $Shop_Controller_Show->addEntity(
                                        Core::factory('Core_Xml_Entity')
                                            ->name('sorting')->value($sorting)
                                    );
                                    $Shop_Controller_Show->addCacheSignature('sorting=' . $sorting);

                                    // Prices
                                    $price_from = intval(Core_Array::getGet('price_from'));
                                    $price_to = intval(Core_Array::getGet('price_to'));
                                    if ($price_from || $price_to || $sorting == 1 || $sorting == 2)
                                    {
                                        // Получаем список валют магазина
                                        $aShop_Currencies = Core_Entity::factory('Shop_Currency')->findAll();

                                        $query_currency_switch = 'price';
                                        foreach ($aShop_Currencies as $oShop_Currency)
                                        {
                                            // Получаем коэффициент пересчета для каждой валюты
                                            $currency_coefficient = Shop_Controller::instance()->getCurrencyCoefficientInShopCurrency(
                                                $oShop_Currency, $oShop->Shop_Currency
                                            );

                                  $query_currency_switch = "IF (`shop_items`.`shop_currency_id` = '{$oShop_Currency->id}', IF (shop_discounts.value, IF(shop_discounts.type, price * {$currency_coefficient} - shop_discounts.value, price * (100 - shop_discounts.value) * {$currency_coefficient} / 100), shop_items.price * {$currency_coefficient}), {$query_currency_switch})";
                                        }

                                        $current_date = date('Y-m-d H:i:s');
                                        $Shop_Controller_Show->shopItems()
                                            ->queryBuilder()
                                            ->select(array(Core_QueryBuilder::expression($query_currency_switch), 'absolute_price'))
                                            ->leftJoin('shop_item_discounts', 'shop_items.id', '=', 'shop_item_discounts.shop_item_id')
                                            ->leftJoin('shop_discounts', 'shop_item_discounts.shop_discount_id', '=', 'shop_discounts.id', array(
                                                array('AND (' => array('shop_discounts.end_datetime', '>=', $current_date)),
                                                array('OR' => array('shop_discounts.end_datetime', '=', '0000-00-00 00:00:00')),
                                                array('AND' => array('shop_discounts.start_datetime', '<=', $current_date)),
                                                array(')' => NULL)
                                            ))
                                            ->groupBy('shop_items.id');

                                        if ($price_from)
                                        {
                                            $Shop_Controller_Show->shopItems()->queryBuilder()->having('absolute_price', '>=', $price_from);
                                            $Shop_Controller_Show->addEntity(
                                                Core::factory('Core_Xml_Entity')
                                                    ->name('price_from')->value($price_from)
                                            );
                                            $Shop_Controller_Show->addCacheSignature('price_from=' . $price_from);
                                        }
                                        if ($price_to)
                                        {
                                            $Shop_Controller_Show->shopItems()->queryBuilder()->having('absolute_price', '<=', $price_to);
                                            $Shop_Controller_Show->addEntity(
                                                Core::factory('Core_Xml_Entity')
                                                    ->name('price_to')->value($price_to)
                                            );
                                            $Shop_Controller_Show->addCacheSignature('price_to=' . $price_to);
                                        }

                                        $Shop_Controller_Show->shopItems()->queryBuilder()
                                            ->clearOrderBy()
                                            ->orderBy('absolute_price', $sorting == 1 ? 'ASC' : 'DESC');
                                    }

                                    $sorting == 3 && $Shop_Controller_Show->shopItems()->queryBuilder()
                                        ->clearOrderBy()
                                        ->orderBy('shop_items.name', 'ASC');

                                    // Additional properties
                                    $oShop_Item_Property_List = Core_Entity::factory('Shop_Item_Property_List', 1);
                                    $aProperties = $oShop_Item_Property_List->Properties->findAll();
                                    $aTmpProperties = array();
                                    $havingCount = 0;
                                    foreach ($aProperties as $oProperty)
                                    {
                                        // Св-во может иметь несколько значений
                                        $aPropertiesValue = Core_Array::getGet('property_' . $oProperty->id);
                                        if ($aPropertiesValue)
                                        {
                                            !is_array($aPropertiesValue) && $aPropertiesValue = array($aPropertiesValue);
                                            foreach ($aPropertiesValue as $sPropertyValue)
                                            {
                                                $aTmpProperties[] = array($oProperty, strval($sPropertyValue));
                                            }
                                            $havingCount++;
                                        }
                                        elseif (!is_null(Core_Array::getGet('property_' . $oProperty->id . '_from')))
                                        {
                                            $tmpFrom = Core_Array::getGet('property_' . $oProperty->id . '_from');
                                            $tmpTo = Core_Array::getGet('property_' . $oProperty->id . '_to');

                                            !is_array($tmpFrom) && $tmpFrom = array($tmpFrom);
                                            !is_array($tmpTo) && $tmpTo = array($tmpTo);

                                            // From ... to ...
                                            foreach ($tmpFrom as $iKey => $sValue)
                                            {
                                                $to = Core_Array::get($tmpTo, $iKey);

                                                $aTmpProperties[] = array($oProperty, array(
                                                        'from' => $sValue != ''
                                                            ? ($oProperty->type == 11 ? floatval($sValue) : intval($sValue))
                                                            : '',
                                                        'to' => $to != ''
                                                            ? ($oProperty->type == 11 ? floatval($to) : intval($to))
                                                            : ''
                                                    ));
                                            }
                                            $havingCount++;
                                        }
                                    }

                                    if (count($aTmpProperties))
                                    {
                                    
                                        $aTableNames = array();

                                        $Shop_Controller_Show->shopItems()->queryBuilder()
                                            ->leftJoin('shop_item_properties', 'shop_items.shop_id', '=', 'shop_item_properties.shop_id')
                                            ->setAnd()
                                            ->open();

                                        reset($aTmpProperties);
                                        while(list(, list($oProperty, $propertyValue)) = each($aTmpProperties))
                                        {
                                            $tableName = $oProperty->createNewValue(0)->getTableName();

                                            !in_array($tableName, $aTableNames) && $aTableNames[] = $tableName;

                                            $Shop_Controller_Show->shopItems()->queryBuilder()
                                                ->where('shop_item_properties.property_id', '=', $oProperty->id);

                                            if (!is_array($propertyValue))
                                            {
                                                // Для строк фильтр LIKE %...%
                                                if ($oProperty->type == 1)
                                                {
                                                    $Shop_Controller_Show->shopItems()->queryBuilder()
                                                        ->where($tableName . '.value', 'LIKE', "%{$propertyValue}%");
                                                }
                                                else
                                                {
                                                    // Checkbox
                                                    $oProperty->type == 7 && $propertyValue != '' && $propertyValue = 1;

                                                    $bCheckUnset = $oProperty->type != 7 && $oProperty->type != 3;

                                                    $bCheckUnset && $Shop_Controller_Show->shopItems()->queryBuilder()->open();

                                                    $Shop_Controller_Show->shopItems()->queryBuilder()
                                                        ->where($tableName . '.value', '=', $propertyValue);

                                                    $bCheckUnset && $Shop_Controller_Show->shopItems()->queryBuilder()
                                                        ->setOr()
                                                        ->where($tableName . '.value', 'IS', NULL)
                                                        ->close();
                                                }

                                                $Shop_Controller_Show->shopItems()->queryBuilder()
                                                    ->setOr();

                                                $Shop_Controller_Show->addEntity(
                                                    Core::factory('Core_Xml_Entity')
                                                        ->name('property_' . $oProperty->id)->value($propertyValue)
                                                );
                                                $Shop_Controller_Show->addCacheSignature("property{$oProperty->id}={$propertyValue}");
                                            }
                                            else
                                            {
                                                $from = trim(Core_Array::get($propertyValue, 'from'));
                                                $from && $Shop_Controller_Show->shopItems()->queryBuilder()
                                                    ->open()
                                                    ->where($tableName . '.value', '>=', $from)
                                                    ->setOr()
                                                    ->where($tableName . '.value', 'IS', NULL)
                                                    ->close()
                                                    ->setAnd();

                                                $to = trim(Core_Array::get($propertyValue, 'to'));
                                                $to && $Shop_Controller_Show->shopItems()->queryBuilder()
                                                    ->open()
                                                    ->where($tableName . '.value', '<=', $to)
                                                    ->setOr()
                                                    ->where($tableName . '.value', 'IS', NULL)
                                                    ->close();

                                                $Shop_Controller_Show->shopItems()->queryBuilder()
                                                    ->setOr();

                                                $Shop_Controller_Show->addEntity(
                                                    Core::factory('Core_Xml_Entity')
                                                        ->name('property_' . $oProperty->id . '_from')->value($from)
                                                )->addEntity(
                                                    Core::factory('Core_Xml_Entity')
                                                        ->name('property_' . $oProperty->id . '_to')->value($to)
                                                );

                                                $Shop_Controller_Show
                                                    ->addCacheSignature("property{$oProperty->id}_from={$from}")
                                                    ->addCacheSignature("property{$oProperty->id}_to={$to}");
                                            }
                                        }

                                        $Shop_Controller_Show->shopItems()->queryBuilder()
                                            ->close()
                                            ->groupBy('shop_items.id')
                                            ->having(Core_Querybuilder::expression('COUNT(DISTINCT `shop_item_properties`.`property_id`)'), '=', $havingCount);

                                        foreach ($aTableNames as $tableName)
                                        {
                                            $Shop_Controller_Show->shopItems()->queryBuilder()
                                                ->leftJoin($tableName, 'shop_items.id', '=', $tableName . '.entity_id',
                                                    array(
                                                        array('AND' => array('shop_item_properties.property_id', '=', Core_QueryBuilder::expression($tableName . '.property_id')))
                                                    )
                                                );
                                        }
                                    }
                                }
                            

                                $Shop_Controller_Show
                                    ->xsl(
                                        Core_Entity::factory('Xsl')->getByName('МагазинФильтр')
                                    )
                                    ->groupsMode('none')
                                    ->group(false)
                                    ->limit(0)
                                    ->viewed(false)
                                    ->itemsProperties(true)
                                    ->show();
                            }
?>
#
Re: Проблема с фильтром
Вообщем забил на этот фильтр, вывел тот что был в стандартном xsl
Работает сортировка по цене, в XML нет максимальной и минимальной цены, также списки не ограничиваются значениями тех товаров, что присутствуют на странице, выводятся вообще все значения.
Подскажите как ограничить списки значениями, которые присутствуют у элементов в текущей выборке, а также помогите определить причину почему не выбирается цена максимальная и минимальная
   <div class="shop_filter">
                  <div class="sorting">
                     <select name="sorting" onchange="$(this).parents('form:first').submit()">
                        <option>Сортировать</option>
                        <option value="1">
                        <xsl:if test="/shop/sorting = 1"><xsl:attribute name="selected">selected</xsl:attribute></xsl:if>
                           По цене (сначала дешевые)
                        </option>
                        <option value="2">
                        <xsl:if test="/shop/sorting = 2"><xsl:attribute name="selected">selected</xsl:attribute></xsl:if>
                           По цене (сначала дорогие)
                        </option>
                        <option value="3">
                        <xsl:if test="/shop/sorting = 3"><xsl:attribute name="selected">selected</xsl:attribute></xsl:if>
                           По названию
                        </option>
                     </select>
                  </div>
                  
                  <div class="priceFilter">
                     <xsl:text>Цена от: </xsl:text>
                     <input name="price_from" size="5" type="text">
                        <xsl:if test="/shop/price_from != 0">
                           <xsl:attribute name="value"><xsl:value-of select="/shop/price_from"/></xsl:attribute>
                        </xsl:if>
                     </input>
                     
                     <xsl:text>до: </xsl:text>
                     <input name="price_to" size="5" type="text">
                        <xsl:if test="/shop/price_to != 0">
                           <xsl:attribute name="value"><xsl:value-of select="/shop/price_to"/></xsl:attribute>
                        </xsl:if>
                     </input>
                  </div>
                  
                  <!-- Фильтр по дополнительным свойствам товара: -->
                  <xsl:if test="count(shop_item_properties//property[filter != 0 and (type = 0 or type = 1 or type = 3 or type = 7 or type = 11)])">
                     
                     <xsl:apply-templates select="shop_item_properties//property[filter != 0 and (type = 0 or type = 1 or type = 3 or type = 7 or type = 11)]" mode="propertyList"/>
                  </xsl:if>
                  
                  <input name="filter" class="button" value="Применить" type="submit"/>
               </div>
Авторизация