Posting in the Magento forums has been disabled pending the implementation of a new and improved forum solution which should better serve the community.

For new questions please post at magento.stackexchange.com, the community-run support site for the Magento community. We will be providing updates on the new forum solution soon. For questions or concerns please email community@magento.com.

Magento Forum

How to create a manufacturer drop-down selector
 
Stefan Pantiru
Jr. Member
 
Total Posts:  11
Joined:  2008-05-08
 

Hello all,

I need to create a simple manufacturer drop-down so the user can see all products belonging to that manufacturer.

However I could not find any API documentation anywhere and trying to reverse engineer existing modules is time consuming…

Esentially I need to create a block and set it in the left side column which is easy, but what is the API function for getting all the manufacturers and then all the products with a specific manufacturer

If someone could just point me to the relevant functions, I could work it out from there - or where’s the documentation for basic things like getting products parent categories or attributes etc.

Thank you!
Edit: Now really!!

If you are in… say… app/design/frontend/default/default/template/catalog/product/smtg.phtml how do you get all manufacturers?

I spent over three hours with no luck trying to find this out!

 
Magento Community Magento Community
Magento Community
Magento Community
 
Stefan Pantiru
Jr. Member
 
Total Posts:  11
Joined:  2008-05-08
 

After four or five hours, I finally got close… I got the manufacturers list like this:

$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);

print_r($manufacturers);

Quite an adventure this was!

If this code can be optimized in any way, please let me know.

Thanks

 
Magento Community Magento Community
Magento Community
Magento Community
Magento Community
Magento Community
Back to top