Magento 1.9의 로그인 사용자가 아닌 가격과 가격 필터 내비게이션 레이어별로 정렬 방법을 숨기는 방법?

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

  •  29-09-2020
  •  | 
  •  

문제

로 로그온하지 않은 사용자의 범주 제품 목록 페이지에서 Sort by PricePrice Filter Navigation Layer를 숨길 수 있습니까?

도움이 되었습니까?

해결책 2

Claudiu Cranga에 대한 도움을 받으려면, 나는 그의 주제에 완벽하게 일하기 위해 자신의 코드를 수정했습니다. ICotheMe의 테마 Puro를 사용합니다.

  1. 가격으로 정렬을 숨 깁니다
  2. 템플릿 \ Catalog \ 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. 숨기기

      템플릿 \ 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>
.

* 테스트되지 않은 코드

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 magento.stackexchange
scroll top