简短:
属性有很多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.
<?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
}
?>
答案 0 :(得分:1)
根据我的理解,以下解决方案可以解决您的问题: -
请复制app/design/frontend/base/default/template/em_layerednavigation/view.phtml
模板文件(em_layerednavigation文件夹)并将其放在主题中,并在第49行后面的代码后面附加: -
<?php if($this->__($_filter->getName())=='L1'&& $_filter->getItemsCount()<=1)
continue;?>
答案 1 :(得分:0)
这对我有用:
if(!$_filter->getItemsCount() || $_filter->getItemsCount()==1 && $_filter->getName()!='Category') continue;