如何通过价格和价格过滤器导航层隐藏排序,以便在Magento 1.9中登录用户?

magento.stackexchange https://magento.stackexchange.com/questions/108673

  •  29-09-2020
  •  | 
  •  

是否可以在“未登录的用户”页面产品列表页面上隐藏“生成acodeTagcode和Sort by Price

有帮助吗?

解决方案 2

感谢Claudiu Creanga寻求帮助,我修改了他的代码与我的主题完美地工作,我将主题Puro用于ICotheme。

  1. 通过价格隐藏排序
  2. 在模板\目录\ product \ list \ toolbar.phtml中替换此代码

                                                <ul id="sort_by" class="sort_by collapse">
                                                <?php foreach ($this->getAvailableOrders() as $_key => $_order): ?>
                                                    <li>
                                                        <a href="<?php echo $this->getOrderUrl($_key, 'asc') ?>"><?php echo $this->__($_order) ?></a>
                                                    </li>
                                                <?php endforeach; ?>
                                            </ul>
    
    .

                                                <ul id="sort_by" class="sort_by collapse">
                                            <?php foreach($this->getAvailableOrders() as $_key=>$_order): ?>
                                                <?php if(!Mage::getSingleton('customer/session')->isLoggedIn()): //not logged in, hide price ?>
                                                    <?php if(strpos($this->__($_order), "Price") === false):  ?>
                                                    <li>
                                                        <a href="<?php echo $this->getOrderUrl($_key, 'asc') ?>"><?php echo $this->__($_order) ?></a>
                                                    </li>
                                                    <?php endif; ?>
                                                <?php else: // logged in ?>
                                                    <li>
                                                        <a href="<?php echo $this->getOrderUrl($_key, 'asc') ?>"><?php echo $this->__($_order) ?></a>
                                                    </li>
    
                                                <?php endif; ?>
                                            <?php endforeach; ?>
                                            </ul>
    
    .

    1. 隐藏价格过滤器导航层
    2. 替换模板\目录\ layer \ View.phtml中的此代码

                          <dt><?php echo $this->__($_filter->getName()) ?></dt>
                      <dd><?php echo $_filter->getHtml() ?></dd>
      
      .

                      <?php if(!Mage::getSingleton('customer/session')->isLoggedIn()): //not logged in, hide price ?>
                      <?php if(strpos($this->__($_filter->getName()), "Price") === false):  ?>
                          <dt><?php echo $this->__($_filter->getName()) ?></dt>
                          <dd><?php echo $_filter->getHtml() ?></dd>
                      <?php endif; ?>
                  <?php else: // logged in ?>
                      <dt><?php echo $this->__($_filter->getName()) ?></dt>
                      <dd><?php echo $_filter->getHtml() ?></dd>
                  <?php endif; ?>
      
      .

其他提示

该过滤器很可能是template\catalog\product\list\toolbar.phtml

您感兴趣的代码是:

 <select onchange="setLocation(this.value)" title="<?php echo $this->__('Sort By') ?>">
                    <?php foreach($this->getAvailableOrders() as $_key=>$_order): ?>
                        <option value="<?php echo $this->getOrderUrl($_key, 'asc') ?>"<?php if($this->isOrderCurrent($_key)): ?> selected="selected"<?php endif; ?>>
                            <?php echo $this->__($_order) ?>
                        </option>
                    <?php endforeach; ?>
                </select>
.

所以删除它并添加这样的内容:

<select onchange="setLocation(this.value)" title="<?php echo $this->__('Sort By') ?>">
    <?php foreach($this->getAvailableOrders() as $_key=>$_order): ?>
        <?php 
            if(!Mage::getSingleton('customer/session')->isLoggedIn()): //not logged in, hide price ?>

                <?php if(strpos($this->__($_order), "Price") === false):  ?>
                    <option value="<?php echo $this->getOrderUrl($_key, 'asc') ?>"<?php if($this->isOrderCurrent($_key)): ?> selected="selected"<?php endif; ?>>
                        <?php echo $this->__($_order) ?>
                    </option>
                <?php else: // logged in ?>

                    <option value="<?php echo $this->getOrderUrl($_key, 'asc') ?>"<?php if($this->isOrderCurrent($_key)): ?> selected="selected"<?php endif; ?>>
                        <?php echo $this->__($_order) ?>
                    </option>
               <?php endif; ?>
           <?php endif; ?>

    <?php endforeach; ?>
</select>
.

*未经测试的代码

许可以下: CC-BY-SA归因
scroll top