Question

I am geting all dropdown attributes value and name using below code

    $product = Mage::getModel('catalog/product');  

 $attributes = Mage::getResourceModel('eav/entity_attribute_collection')
     ->setEntityTypeFilter($product->getResource()->getTypeId())
     ->addFieldToFilter('attribute_code', 'manufacturer');

 $attribute = $attributes->getFirstItem()->setEntity($product->getResource());  

 $manufacturers = $attribute->getSource()->getAllOptions(false);

 foreach ($manufacturers as $manufacturer){


     echo $manufacturer_name = $manufacturer['label'];
    echo $manufacturer_value = $manufacturer['value'];



 }

i am also now how to get product from attributes for this i code this

    $collection = Mage::getModel('catalog/product')->getCollection();

$collection->addAttributeToSelect('manufacturer');


foreach($collection as $product){
    echo "<pre>";
 print_r($product->getData());
}

But My question is that I am create brand slider using manufacturer attributes (dropdown) and i am set image from using manufacturer label.

But i want to create when click on manufacturer label(xyz) this it will display all product where set (xyz) in product list.

Was it helpful?

Solution

Try

$collection = Mage::getModel('catalog/product')->getCollection()
                   ->addAttributeToFilter('manufacturer', array('eq' => 'xyz'))
                   ->addAttributeToSelect('*'); 
Licensed under: CC-BY-SA with attribution
Not affiliated with magento.stackexchange
scroll top