在Prestashop上获取制造商图像

问题描述:

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

我正在尝试在prestashop上的 topmenu strong>模块上添加制造商图片。 我是这个CMS的新手。 我在代码( blocktopmenu.php code>)中添加了这一行来进行一些测试: p>

 &lt;  img src ='。$ link-&gt; getImageLink((int)$ manufacturer ['id_manufacturer'],'img / m')。'&gt; 
  code>  pre> 
 
 

不幸的是检查HTML生成的代码,我获得的链接如下,它无法正确检索我需要的图像: p>

 &lt; img src =“abtemplates.altervista  .org / 1 / img / m / 2.jpg“&gt; 
  code>  pre> 
 
 

但我真正需要的是: p>

 &lt; img src =“/ 1 / img / m / 2.jpg”&gt; 
  code>  pre> 
 
 

我的问题: strong> 有没有办法用 getImageLink code>方法或类似方法获取制造商的图像? 提前致谢 p> div>

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">