Magento 1.9のログインユーザーの価格と価格フィルタナビゲーションレイヤーでソートを隠す方法
-
29-09-2020 - |
質問
ログオンしていないユーザーのカテゴリ製品一覧ページでSort by Price
とPrice Filter Navigation Layer
を隠すことは可能ですか?
解決 2
Claudiu Crangaを助長してくれて、私は私のテーマと完璧に働くために彼のコードを修正しました、私はアイコテメのためのテーマプロを使います。
- 価格で並べ替えを隠す
- 価格フィルタナビゲーションレイヤー
テンプレート\カタログ\製品\ 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>
.
テンプレート\ Catalog \ 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>
.
*未テストコード
所属していません magento.stackexchange