搜索页面上的 Magento 事件过滤器

标签 magento magento-1.7

我想在我的 magento 电子商务网站上实现主动过滤器。

我已经成功实现了它,但问题是,该代码仅适用于类别页面,不适用于搜索页面

这是我正在使用的代码

<?php /*Create filter dependencies*/

$_activeFilters[] = array();

$_filters = Mage::getSingleton(‘Mage_Catalog_Block_Layer_State’)->getActiveFilters();

foreach ($_filters as $_filter):?>
<?php echo $this->stripTags($_filter->getLabel()) ?><a href=”<?php echo $_filter-     >getRemoveUrl() ?>” title=”<?php echo $this->__(‘Remove This Item’) ?>”><?php echo $this->__(‘Remove This Item’) ?></a>
<?php endforeach; ?>

我在toolbar.phtml 中使用此代码。任何关于为什么它在搜索页面上不起作用的线索。任何解决方案都会有很大帮助。

谢谢

苏希尔

最佳答案

您可以使用此代码在类别列表页面或搜索结果页面上获取过滤器

   <?php
   if(Mage::registry('current_category')) {
       $_filters = Mage::getSingleton('catalog/layer')->getState()->getFilters();
   } else {
       $_filters = Mage::getSingleton('catalogsearch/layer')->getState()->getFilters();
   }
   ?>

我在toolbar.phtml中使用了这段代码,以在工具栏下方显示可移动的过滤器,就像flipkart那样。

关于搜索页面上的 Magento 事件过滤器,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/14251136/

相关文章:

产品制造商的 Magento 问题

magento - 如何在 Magento 1.9.0.1 中使用 2 个或更多类别过滤器来过滤产品

model-view-controller - 什么是 magento 报价?

forms - Magento,在网格和表单后端添加并设置一个复选框

php - 马根托。仅为分组产品创建属性

magento - Magento 中的条件布局 block 取决于是否登录?

security - 错误修补 Magento 1.7.1 Hunk #1 失败

magento - 如何使用 magento ORM 中的集合删除数据?

magento - 自定义模型集合返回 false

php - Magento:构建库存中所有可配置产品的自定义产品集合