1

I am working with magento 1.7. I added a manufacture image in my product and i wish to display it in the categories page with the list.

1

If you've created an Image attribute in the backend for this specific image, let's say manufacturer_image you can add this attribute to the collection used on the category product list by modifying the class Mage_Catalog_Model_Layer, method prepareProductCollection on line 116.

Change

$collection
   ->addAttributeToSelect(Mage::getSingleton('catalog/config')->getProductAttributes())
   ->addMinimalPrice()
   ->addFinalPrice()
   ->addTaxPercents()
   ->addUrlRewrite($this->getCurrentCategory()->getId());

to

$collection
   ->addAttributeToSelect(Mage::getSingleton('catalog/config')->getProductAttributes())
   ->addAttributeToSelect('manufacturer_image')
   ->addMinimalPrice()
   ->addFinalPrice()
   ->addTaxPercents()
   ->addUrlRewrite($this->getCurrentCategory()->getId());

It would be better to extend the class in your own custom extension and just overwrite the part you need.

I've never used this to add a product but did it before for some other data I needed in that collection eliminating the need to load the whole Product object (Mage::getModel('catalog/product')->load(...);)

7
  • in any file can i edit that ? – Amirov Nov 21 '13 at 10:22
  • In case you don't want to extend the file from your own extension you can copy app/code/core/Mage/Catalog/Model/Layer.php to app/code/local/Mage/Catalog/Model/Layer.php and edit it there – Sander Mangel Nov 21 '13 at 10:36
  • Thanks. I have an other idea that i will applicate. If a added all manufactures image file in the image folder and i have a drop down list attribute with manufactures name. Every product are a manufacture name. I wish to display every manufacture image according manufacture name. For example, if i have Samsung as manufacture that display me the Samsung manufacture image. – Amirov Nov 22 '13 at 14:11
  • Ah well in that case add your solution as an answer and accept it :) – Sander Mangel Nov 22 '13 at 14:18
  • i need help to applicate it – Amirov Nov 22 '13 at 14:24
0

After you load the product image with the collection you can call in the list.phtml template like $_product->getManufacturerImage()

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.