cancel
Showing results for 
Search instead for 
Did you mean: 

Get manufacturers that sell a particular product

Get manufacturers that sell a particular product

I am trying to get a collection of distinct manufacturers who sell a certain product type ("backpacks"). The problem is I can either get all the manufacturers, or I can get all the products that are backpacks, but I'm having an ungodly difficult time understanding how to join these collections to get a collection of manufacturers who sell backpacks.

 

I've gone through many experiments and not one has worked.

 

A common solution I've read on many pages was the use of:

Mage::getModel('catalog/product')
->getCollection()
->addAttributeToSelect('manufacturer');

 

but `addAttributeToSelect('manufacturer')` simply does not work. My collection of products will not contain the manufacturer id or value.

 

This code gets all our manufacturers:

$attribute = Mage::getModel('eav/entity_attribute')
->loadByCode('catalog_product', 'manufacturer');

$valuesCollection = Mage::getResourceModel('eav/entity_attribute_option_collection')
->setAttributeFilter($attribute->getData('attribute_id'))
->setStoreFilter(0, false);

 

This code returns all backpack products:

$products = Mage::getModel('catalog/product')
->getCollection()
->addAttributeToFilter('attribute_set_id', '10');

 

I need help to understand either how to get only those manufacturers that sell backpack products via the attribute_option collection, or how to get distinct manufacturers from the collection of backpack products.