Como ocultar SORT BY PRICE e PRICE FILTER NAVIGATION LAYER para usuário não logado no magento 1.9?

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

  •  29-09-2020
  •  | 
  •  

Pergunta

É possível esconder o Sort by Price e Price Filter Navigation Layer na página da lista de produtos da categoria para usuários que não estão conectados?

Foi útil?

Solução 2

Obrigado pela ajuda do Claudiu Creanga, modifiquei o código dele para funcionar perfeitamente com o meu tema, uso o tema puro para o icotheme.

  1. ocultar a classificação por preço

Substitua este código em template\catalog\product\list oolbar.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>

com :

                                            <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. Ocultar camada de navegação do filtro de preços

Substitua este código em template\catalog\layer\view.phtml

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

com:

                <?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; ?>

Outras dicas

Esse filtro provavelmente está em template\catalog\product\list\toolbar.phtml

O código que lhe interessa é:

 <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>

então exclua isso e adicione algo assim:

<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>

*código não testado

Licenciado em: CC-BY-SA com atribuição
Não afiliado a magento.stackexchange
scroll top