Php magento自定义模块中带有请求参数的产品集合工具栏
我有一个过滤器,名为“拾音器查找器”。当我点击按钮时,通过选择打印机系列下拉列表找到我的墨盒,然后它会正确而漂亮地显示产品列表工具栏上的产品集合。但当我按名称、价格或查看列表进行排序时,会显示没有与所选产品匹配的产品。下面给出了我的自定义制造商模块的布局文件代码:Php magento自定义模块中带有请求参数的产品集合工具栏,php,codeblocks,magento-1.9,Php,Codeblocks,Magento 1.9,我有一个过滤器,名为“拾音器查找器”。当我点击按钮时,通过选择打印机系列下拉列表找到我的墨盒,然后它会正确而漂亮地显示产品列表工具栏上的产品集合。但当我按名称、价格或查看列表进行排序时,会显示没有与所选产品匹配的产品。下面给出了我的自定义制造商模块的布局文件代码: <manufacturer_index_filter> <reference name="root"> <action method="setTemplate"><temp
<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>
保护功能_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{
//返回数组'created_time'=>'created time','update_time'=>'Updated time','collection_id'=>'id','name'=>'name';
返回数组'name'=>'name','position'=>'position','price'=>'price';
}
公共职能部门{
返回'name';
}
公共函数getToolbarBlock
{
$block=$this->getLayout->createBlock'manufacturer/toolbar',microtime;
返回$block;
}
公共函数获取模式
{
返回$this->getChild'toolbar'->getCurrentMode;
}
但是当它只使用Mage::getModel'catalog/product'->getCollection而不是params运行时,它就可以使用product collection工具栏成功运行。我需要在这个工具栏中设置params。如何做到这一点。如果有人知道这一点,请尽快回复我。我在谷歌上搜索了很多。但是没有具体的结果。
谢谢尝试扩展:
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*/
问题标记为magento 1.9,您的答案似乎是针对magento 2.x的。此外,直接使用$\u GET违反了magento的最佳实践。
public function getToolbarHtml()
{
return $this->getChildHtml('toolbar');
}}`
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*/