I'm trying to add manufacturer image on topmenu module on prestashop. I'm very new to this CMS. I added this line to the code (blocktopmenu.php
) to make some tests:
<img src='.$link->getImageLink((int)$manufacturer['id_manufacturer'], 'img/m').'>
Unfortunately checking the HTML generated code, the link I obtain is the following, and it can't retrieve correctly the image I need:
<img src="abtemplates.altervista.org/1/img/m/2.jpg">
But what I need really is this:
<img src="/1/img/m/2.jpg">
My Question: Is there a way to obtain manufacturer image with getImageLink
method or similar? Thanks in advance
You can get the manufacturer image with the following code:
<img src="' . __PS_BASE_URI__ . 'img/m/' . (int) $manufacturer['id_manufacturer'] . '.jpg">
It is more elegant to assign the manufacturer ID to a Smarty variable in the hookDisplayTop
method:
$this->smarty->assign('id_manufacturer', $yourManufacturerId);
Then you can display it in blocktopmenu.tpl
:
<img src="{$img_manu_dir}{$id_manufacturer}.jpg">