панель инструментов для сбора продуктов с параметрами запроса в пользовательском модуле magento

введите описание изображения здесь

введите описание изображения здесь

У меня есть фильтр с именем CARTRIDGE FINDER. Когда я нажимаю кнопку, НАЙДИТЕ МОЙ КАРТРИДЖ, выбрав выпадающий список серий принтеров, тогда он правильно и красиво показывает коллекцию продуктов со списком инструментов. Но когда я сортирую по имени, цене или вижу в виде списка, он показывает, что нет товаров, соответствующих выбранному. Ниже приведен код файла макета моего пользовательского (изготовителя) модуля:

<manufacturer_index_filter>
<reference name="root">
<action method="setTemplate"><template>page/2columns-left.phtml</template></action>
</reference>
<reference name="content">
<block type="manufacturer/custom" name="printer_filter" template="manufacturer/brand_filter_result.phtml"/>
</reference>

А код блочного файла модуля (производителя) Custom.php приведен ниже: `class Bubmania_Manufacturer_Block_Custom extends Mage_Core_Block_Template
{публичная функция __construct ()
{
parent :: __ construct (); $ printer = $ this-> getRequest () -> getParams (); $ make_a_printer_op_val = $ printer [‘make_a_printer’]; $ printer_series = $ printer [‘printer_series’];
$ printer_model_no = $ printer [‘printer_model_no’];

    $collection = Mage::getModel('catalog/product')->getCollection();
$collection->addAttributeToSelect('*');
$collection->addAttributeToSort('created_at', 'desc');
$collection->addAttributeToFilter(array(
array('attribute'=>'manufacturer','eq'=>$make_a_printer_op_val),
array('attribute'=>'printerseries','eq'=>$printer_series),
array('attribute'=>'printermodelnumber','eq'=>$printer_model_no),
));
$collection->addAttributeToFilter('status', 1);$this->setCollection($collection); /* parent::__construct();

$collection = Mage::getModel('catalog/product')->getCollection();
$collection->addAttributeToSelect('*')
->addFieldToFilter('visibility', array(
Mage_Catalog_Model_Product_Visibility::VISIBILITY_BOTH,
Mage_Catalog_Model_Product_Visibility::VISIBILITY_IN_CATALOG
)); //showing just products visible in catalog or both search and catalog
$this->setCollection($collection); */}

защищенная функция _prepareLayout () {
Родитель :: _ prepareLayout ();

    //$toolbar = $this->getToolbarBlock();
$toolbar = Mage::getBlockSingleton('catalog/product_list')->getToolbarBlock();

// called prepare sortable parameters
$collection = $this->getCollection();

// use sortable parameters
if ($orders = $this->getAvailableOrders()) {
$toolbar->setAvailableOrders($orders);
}
if ($sort = $this->getSortBy()) {
$toolbar->setDefaultOrder($sort);
}
if ($dir = $this->getDefaultDirection()) {
$toolbar->setDefaultDirection($dir);
}
$toolbar->setCollection($collection);

$this->setChild('toolbar', $toolbar);
$this->getCollection()->load();
return $this;
}public function getDefaultDirection(){
return 'asc';
}

публичная функция getAvailableOrders () {
// возвращаем массив (‘create_time’ => ‘Created Time’, ‘update_time’ => ‘Обновлено время’, ‘collection_id’ => ‘ID’, ‘name’ => ‘Name’);
возвращаемый массив (‘name’ => ‘Name’, ‘position’ => ‘Position’, ‘price’ => ‘Price’);
}
публичная функция getSortBy () {
вернуть «имя»;
}
публичная функция getToolbarBlock ()
{
$ block = $ this-> getLayout () -> createBlock («производитель / панель инструментов», microtime ());
вернуть $ блок;
}
публичная функция getMode ()
{
return $ this-> getChild (‘панель инструментов’) -> getCurrentMode ();
}

public function getToolbarHtml()
{
return $this->getChildHtml('toolbar');
}}`

Но когда он работает только с Mage :: getModel (‘catalog / product’) -> getCollection (), а не params, тогда он успешно работает с панелью инструментов для сбора продуктов. Мне нужно установить параметры в этой панели инструментов. Как это сделать Если кто-то знает этот момент, пожалуйста, ответьте мне как можно скорее. Я много гуглил. Но конкретного результата нет.
Спасибо

0

Решение

Попробуйте расширить:

class CollectionFilter extends \Magento\Catalog\Model\Layer\Category\CollectionFilter
{

public function filter(
$collection,
\Magento\Catalog\Model\Category $category
) {
if(isset($_GET['your filter']))

/* your magic here*/
0

Другие решения

Других решений пока нет …