Question

I SAW LOT OF POSTS ON Stackoverflow & here also , I DIDN'T get SINGLE proper answer.

Hi dudes, I have Filter option when i goto other Category->Product listing page .

I want to make it like Sort Dropdown of magento by default.

I have custom attr. as Carat for golden shop . I set its value from backend ,like 14,15 etc.

I m fetching it properly in drop down.

What should be done if i want to filter products by Carat ?

Till now my code to fetch Custom attr. & show in DDList.

    <!--Modified Code 27 Oct-->
    <?php 
        $name='carat_dropdown';
        $attributeInfo = Mage::getResourceModel('eav/entity_attribute_collection')->setCodeFilter($name)->getFirstItem();
        $attributeId = $attributeInfo->getAttributeId();                                    
        $attribute = Mage::getModel('catalog/resource_eav_attribute')->load($attributeId);
        $attributeOptions = $attribute ->getSource()->getAllOptions(false); 
    ?>

    <div class="sort-by">
        <label><?php echo $this->__('Filter By') ?></label>
        <select name="filterByCaret" >
                <option value="" >Select</option>                         
            <?php
            foreach($attributeOptions as $single){
            ?>
                <option value="<?php echo $single['value']?>" >                         
                    <?php echo $single['label']?>
                </option>          
            <?php
            }                                   
            ?>
        </select>
    </div>        
    <!--//Modified Code 27 Oct-->

DDList = Drop Down List.

Even in simple way

. Hi see, i have custom field in backend for jewellery shop Caret Value .So in drop down i will have all values i enter from backend for Carat Value like 13,14 etc. So in front end i want to show DDList ,and if i select 14 , products with Carat value 14 will be filtered &shown Thanks for help.

Was it helpful?

Solution

From the way you are discribing the functionality it sounds like you want layered navigation. In this case you should make an attribute for caret value and make it dropdown and filterable. Then set the category to anchor.

Below is some information about layered navigation

OTHER TIPS

$collection = Mage::getResourceModel('catalog/product_collection');
$collection->addAttributeToFilter('carat', 'value');

Just edit value to be the value of the attribute you are interested in.

FYI, starting your question with a row of capitals and bold lettering doesn't overly encourage people to help you...

Licensed under: CC-BY-SA with attribution
Not affiliated with magento.stackexchange
scroll top