【问题标题】:Remove attribute from layered filter based on parent category从基于父类别的分层过滤器中删除属性
【发布时间】:2014-06-12 15:56:56
【问题描述】:

在我的 magento 网站上,每个产品都属于两个父类别。基本上,每个产品都在“按产品购物”和“按设备购物”中,当然还有子类别。例如,平板电脑的外壳将显示在按设备购物 > iPad 以及按产品购物 > 平板电脑外壳中。

每个产品还有一个“兼容性”和“产品类型”属性。在“按设备购物”下购物时,我想从目录页面的分层过滤器中删除“兼容性”过滤器,并在“按产品购物”下购物时删除“产品类型”过滤器

有什么建议吗?

【问题讨论】:

    标签: magento filter catalog


    【解决方案1】:

    把代码放在catalog/layer/view.phtml的layer.phtml开头

    $yes=0;
    if(Mage::registry('current_catgeory')){
        if(Mage::registry('current_catgeory')->getParentId()==$catid):
        $yes=1
        endif;
    }
    

    然后过滤显示位置添加

    <?php foreach ($_filters as $_filter): ?>
                    <?php if($_filter->getItemsCount()): ?>
                        <dt><?php echo $this->__($_filter->getName()) ?></dt>
                        <dd><?php echo $_filter->getHtml() ?></dd>
                    <?php endif; ?>
                    <?php endforeach; ?>
    

    改变

    <?php foreach ($_filters as $_filter): ?>
            if($yes==1 &&  $_filter->getName()==$Attributelabel){
                //hide
                }
                else{
                    <?php if($_filter->getItemsCount()): ?>
                        <dt><?php echo $this->__($_filter->getName()) ?></dt>
                        <dd><?php echo $_filter->getHtml() ?></dd>
                    <?php endif; ?>
            }
                    <?php endforeach; ?>
    

    【讨论】:

    • 我收到以下错误:Parse error: syntax error, unexpected 'endif' (T_ENDIF) in C:\xampp\htdocs\iHomeCases\site1\app\design\frontend\default\ihome\template\catalog\layer\view.phtml on line 37
    • 我不确定这是否通知了你,再次链接你的名字。
    猜你喜欢
    • 2023-04-04
    • 1970-01-01
    • 2023-03-26
    • 2022-01-03
    • 2014-07-02
    • 1970-01-01
    • 1970-01-01
    • 2019-10-14
    • 1970-01-01
    相关资源
    最近更新 更多