2

short :

Attribute have many dropdown values - v1,v2,v3,v4

IF all Products are assigned to value "v1" of an attribute , means no products are assigned to "v2,v3.v4" than that Attribute label should not visible under Layered Navigation.

Long :

we wanted to hide one attribute value in layered navigation.

many attribute codes have same attribute value.

ex: "attribute codes "a1", "a2", "a3", "a4" have attribute value "v1"

we are using following code to hide the attribute value "v1" in layered navigation.

but Attribute Label is still displaying in layered navigation.

if for attribute code : "a1" , attribute label is "L1" , values are "v1", "v2","v3"

if all products are assigned to "v1", than along with "v1" , I want to 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
}

?>
  • got to manage attribute and set Use In Layered Navigation to no – Qaisar Satti Mar 16 '16 at 9:19
  • you are right, but its going to be manual procedure right ? in future we may assign products to "v2" , "v3" & "v4". at that time we have to change "no" to "filterable with results" – Baby in Magento Mar 16 '16 at 9:25
  • also we have lot of attributes like this, so its going to take more time and we dont know which and all attributes have only "v1" values. – Baby in Magento Mar 16 '16 at 9:27
  • this is magneto procedure i say you follow that... – Qaisar Satti Mar 16 '16 at 9:38
  • okay , post your comment as answer. – Baby in Magento Mar 16 '16 at 9:40
0

got to admin panel catalog > attriute > manage attribute and set your current attribute ti Use In Layered Navigation to no

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.