Magento: select manufacturer / brand from the database

I have this code from Mukesh Chapagain: link here

$_product = Mage::getModel('catalog/product')->load(PRODUCT_ID);
$manufacturerName = $_product->getAttributeText('manufacturer');
$manufacturerId = $_product->getManufacturer();

This does not seem to take the manufacturers away, although I have them as attributes. Is this due to the manufacturer field being a drop down menu?

any help in getting the manufacturer attribute would be appreciated

+1
source share
2 answers

To get all manufacturers

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

foreach ( $attribute->getSource()->getAllOptions(true, true) as $option){
     $attributeArray[$option['value']] = $option['label'];
     }  

foreach($attributeArray as $key=>$val){
echo $val;

}

Get products from manufacturers

    $collection = Mage::getModel('catalog/product')->getCollection();
    $collection->addAttributeToSelect('manufacturer');
    $collection->addFieldToFilter(array(
        array('attribute' => 'manufacturer', 'eq' =>$designer_id),
    ));

Get selected manufacturer for products

 $_productCollection=$this->getLoadedProductCollection();
 foreach ($_productCollection as $_product):
  echo $_product->getAttributeText('manufacturer');
 endforeach;
+7
source

Honestly, I can’t say what is wrong with this code.

- - . , -, , , , .

. . manufacturer_text.

$products = Mage::getResourceModel('catalog/product_collection');
Knectar_Select_Product_Values::enhanceProducts($products, 'manufacturer');

foreach ($products as $product) {
    echo $product->getManufacturerText(), '<br>';
}
0

All Articles