$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);
you can test code snippet like above with a php shell as provided in Magento PHP Developer's Guide (p.58)
![](https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjlYrZxUHicj26pHOAPoIorG3JqEqQG-ScsIQanXNiUzeY_CPK0FeVnCPzVJatqmMZToKF0eUWaRbWjE8hK5mpY2oEeDL-irCAm8u6WCsCEdwCWClge9Mm0G1CjwLYJcgun8NkRhWiTJdsS/s1600/magento_php_developers_guide.jpeg)
the result looks similar to this:
magento > print_r($manufacturers);
Array
(
[0] => Array
(
[value] => 6
[label] => Manfucturer A
)
[1] => Array
(
[value] => 20
[label] => Manfucturer B
)
[2] => Array
(
[value] => 21
[label] => Manfucturer C
)
[3] => Array
(
[value] => 27
[label] => Manfucturer D
)
)
magento >
No comments:
Post a Comment