Wie verstecke ich SORT NACH PREIS und PREISFILTER-NAVIGATIONSEBENE für nicht angemeldete Benutzer in Magento 1.9?

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

  •  29-09-2020
  •  | 
  •  

Frage

Ist es möglich, das zu verbergen? Sort by Price Und Price Filter Navigation Layer auf der Kategorie-Produktlistenseite für Benutzer, die nicht angemeldet sind?

War es hilfreich?

Lösung 2

Vielen Dank an Claudiu Creanga für die Hilfe. Ich habe seinen Code so geändert, dass er perfekt mit meinem Theme funktioniert. Ich verwende Theme Puro für Icotheme.

  1. Blenden Sie die Option „Nach Preis sortieren“ aus

Ersetzen Sie diesen Code in 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>

mit :

                                            <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. Preisfilter-Navigationsebene ausblenden

Ersetzen Sie diesen Code in template\catalog\layer\view.phtml

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

mit:

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

Andere Tipps

Dieser Filter ist höchstwahrscheinlich drin template\catalog\product\list\toolbar.phtml

Der für Sie interessante Code ist:

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

Also lösche das und füge so etwas hinzu:

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

*ungetesteter Code

Lizenziert unter: CC-BY-SA mit Zuschreibung
Nicht verbunden mit magento.stackexchange
scroll top