Get / filter all products by attribute value
Get all products related to any particular brand. Let us suppose that we are fetching the products related to ‚Apple‘ brand. The manufacturer ID of Apple = 3.
$manufacturerId = 3; $attributeCode = 'manufacturer'; $products = Mage::getModel('catalog/product')->getCollection()->addAttributeToFilter($attributeCode, $manufacturerId); // print all products print_r($products->getItems());
Hersteller anzeigen
echo $_product->getAttributeText('manufacturer');
Shop by brand, for example in the sidebar.
$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); ?>