2016-02-25 246 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;