如何以Magento方式实施股票过滤器? [英] How can I implement stock filter in Magento way?

查看:85
本文介绍了如何以Magento方式实施股票过滤器?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

缺货的产品可以在我的magento网站上看到.我希望在分层导航中有一个自定义过滤器,该过滤器会显示排除缺货",当客户单击它时,应该隐藏缺货产品.

Out of stock products are visible in my magento website. I want a custom filter in the layered navigation which would say "Exclude out of stock" and when customer clicks on it the out of stock products should be hidden.

(默认情况下,我在系统"->配置"->目录"->库存"下启用显示/显示缺货的产品)

(by default I enable showing/displaying out of stock products under System-> Configuration-> CATALOG-> Inventory)

即我希望客户控制他/她是否应该看到缺货"产品.

i.e. I want the customer to control whether he/she should see the "out of stock" products or not.

示例 此链接

任何人都可以帮忙吗?我希望这可以通过magento方式完成...

can anyone help please? I want this to be done in magento way...

推荐答案

这是开发工作.您需要雇用一些.

this is the development work. you need to hire some one.

基本上,您需要为产品创建属性.

basically you need to create attribute for product.

例如'exclude_out_of_stock'.

eg. 'exclude_out_of_stock'.

然后您需要在Mage/Catalog/Block/Product/List.php中进行编码

then you need to code in Mage/Catalog/Block/Product/List.php

修改function _getProductCollection()

$this->_productCollection = $layer->getProductCollection();

TO

$this->_productCollection = $layer->getProductCollection();

if ($this->getRequest()->getParam('exclude_out_of_stock',0)) {

            $oCollection = Mage::getModel('cataloginventory/stock_item')
                ->getCollection()
                ->addFieldToFilter('is_in_stock',0);

            $oProducts = array();
            foreach($oCollection as $_collection) {
                $oProducts[] = $_collection->getProductId();
            }

            if(!empty($oProducts))
                $this->_productCollection->addIdFilter($oProducts,true);
}

这篇关于如何以Magento方式实施股票过滤器?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆