2016-02-25 59 views
3

刪除屬性標籤下的分層導航顯示

屬性有很多dropdown values - v1,v2,v3,v4

如果所有產品都分配到一個屬性的值「V1」,意味着沒有產品被分配給除「v2,v3.v4」該屬性標籤應不低於分層導航可見....

我們想要在分層導航中隱藏一個屬性值。

許多屬性代碼具有相同的屬性值。

例如:「特徵碼"a1", "a2", "a3", "a4"有屬性值‘V1分層導航V1‘’我們使用下面的代碼隱藏屬性值

但屬性標籤是分層導航仍然顯示。

如果屬性代碼:「A1」,屬性標籤是「L1」,值"v1", "v2","v3"

如果所有產品都指定爲「V1」,比「V1」一直以來,我想hide "L1" in layered navigation.

enter image description here

<?php 
    $_helper = $this->helper('catalog/output'); 
    $_product = $this->getProduct(); 
?> 
<?php if($_additional = $this->getAdditionalData()): ?> 
    <div class="fp1"><?php $Pro_name = $_product->getName();?> 
    <h2><?php echo $this->__('Specifications Of '."$Pro_name") ?></h2><br/><br/> 


    <table class="data-table" id="product-attribute-specs-table"> 
     <col width="25%" /> 
     <col /> 
     <tbody> 
     <?php foreach ($_additional as $_data): ?> 
      <?php $_attribute = $_product->getResource()->getAttribute($_data['code']); 

      /* hide abc */ 
      if($_attribute->getFrontend()->getValue($_product) == 'v1') { 
       continue; 
      }   

      /* hide no abc*/ 
      if (!is_null($_product->getData($_attribute->getAttributeCode())) && (trim((string)$_attribute->getFrontend()->getValue($_product)) != '')) 
      { 
       if ($_data['code'] == 'gendernew'): 
       ?>    
       <tr><th colspan="3"><?php echo $this->__('') ?></th></tr> 
     <th class = "tablehead" colspan="3" > GENERAL </th> 
       <?php elseif ($_data['code'] == 'productweight'): ?> 
       <tr><th class = "tablehead" id="prod_dim" colspan="3"><p style="background: rgb(255, 255, 255) none repeat scroll 0% 0% ! important; color: rgb(255, 255, 255); width: 100%; padding-top: 10px; padding-right: 10px; padding-left: 10px; padding-bottom: 0px ! important;" class="Product_dim">Product Dimension</p><?php echo $this->__('PRODUCT DIMENSION') ?></th></tr> 
       <?php endif; ?> 
      <tr> 
       <th class="label"><?php echo $this->escapeHtml($this->__($_data['label'])) ?></th> 
       <?php 

if (($_data['code'] == 'brnad') || ($_data['code'] == 'age')||($_data['code'] == 'mobile_design')) 

{ ?> 
        <td class="data"> 
         <?php 
          $_ageValues = $_product->getAttributeText($_data['code']); 
          $count = 1; 
         ?> 
         <?php if(is_array($_ageValues)): foreach($_ageValues as $_ageValue): ?> 
         <?php if($count > 1) { echo ","; } ?> 
          <?php echo $_ageValue; ?> 
          <?php $count++; ?> 
         <?php endforeach; 
         else: echo $_product->getAttributeText($_data['code']); 
         endif; ?> 
        </td> 
       <?php } else { ?> 
        <td class="data"><?php echo $_helper->productAttribute($_product, $_product->getData($_data['code']), $_data['code']); ?></td> 
       <?php 
       } 
       ?> 
      </tr> 

      <?php    
      } 
      ?> 
     <?php endforeach; ?> 
     </tbody> 
    </table> 
    </div> 
    <script type="text/javascript">decorateTable('product-attribute-specs-table')</script> 
<?php endif;?> 

<?php 

$attribute_value = 'xyz '; 
if (strlen($attribute_value) > 0) 
{ 
    // code to display the value 
} 

?> 

回答

1

按我的理解,下面的解決辦法解決你的問題: -

請複製app/design/frontend/base/default/template/em_layerednavigation/view.phtml 模板文件(em_layerednavigation夾),然後把它放在你的主題,並添加下面的代碼行號49後: -

<?php if($this->__($_filter->getName())=='L1'&& $_filter->getItemsCount()<=1) 
    continue;?> 

enter image description here enter image description here

+0

我會盡量讓你知道這一點。 – fresher

+0

我試過這段代碼:http://pastebin.com/RZtE4vmj但它沒有爲我工作,似乎我錯過了某處,請檢查代碼。 – fresher

+0

你可以檢查[here](http://vikas.collagekingapp.com/toys.html) – fresher

0

這爲我工作:

if(!$_filter->getItemsCount() || $_filter->getItemsCount()==1 && $_filter->getName()!='Category') continue;