6

I'm using this code to get magento manufacturers' label in current category page. (show brands for just current category not all the brands)

$manufacturers   = array();
$filterBlockName = 'catalog/layer_filter_attribute';
$category        = Mage::registry('current_category');
$layer           = Mage::getSingleton('catalog/layer');
$layer->setCurrentCategory($category);
$attributes = $layer->getFilterableAttributes();
foreach ($attributes as $attribute) {
    if ($attribute->getAttributeCode() == 'manufacturer') {
        $result = Mage::app()->getLayout()->createBlock($filterBlockName)->setLayer($layer)->setAttributeModel($attribute)->init();
        foreach ($result->getItems() as $option) {
            $manufacturers[$option->getValue()] = $option->getLabel();
        }
    }
}

I've added above code in a custom phtml file and add an custom cms block to category page pointing to this phtml file.

Actually it works fine in category pages. All I need is to get manufacturer IMAGE instead of the their LABEL.

Please help me what to do. Thanks

  • 1
    You can do var_dump($option) and check for image path in the data and then can store it to your variable – Neha Raval Mar 12 '17 at 9:59
  • 1
    Thanks Neha for your answer. Unfortunately there is no image or image path in data after using var_dump($option). $option elements are : 'label', 'value', 'count', '_hasDataChanges', '_origData', '_idFieldName', '_isDeleted', '_oldFieldMap' and '_syncFieldMap' – Armi_Raz Mar 12 '17 at 11:04
  • Where and how do you store the images for the manufacurers' logos? – Yiorgos Moschovitis Mar 26 '17 at 23:46
  • 1
    $manufacturname = $option->getLabel(); $path = Mage::getBaseDir('media').'/'.$manufacturname.'png(or the extenstion format you used for image); – Nihar S Apr 24 '17 at 16:33
  • 4
    Are you using a third party module to associate images with manufacturers? – Tim Cieplowski Apr 28 '17 at 14:10
1

Best way to implement it to create Custom module.

  1. Create Custom Module for Admin area.
  2. Fields should be Manufacturer (Populate the dropdown from Manufacturer Attribute Value, Put browse button for uploading logo for that manufacturer".
  3. Show Manufacturer name and logo in admin grid for your reference.
  4. Now in your code, fetch the logo using manufacturer_id from custom module.

I guess it will solve your issue.

0

1.First you have to add an attribute in the admin side which contains the image path. 2.Then you can you can use that attribute to load the image in the category page.

  • 1
    His code looks like he wants to display ALL manufacturer images from a category (layered nav with images) – sv3n May 12 '17 at 7:10

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.