prestashop 订单发票中显示产品图片

prestashop  1.5.x 默认后台订单发票中是不显示产品图片。下面几步轻松显示产品图片。
1.打开classes/order/OrderInvoice.php

查找到public function getProducts 这个方法大约在130行

在这个方法里面找到

1
$customized_datas = Product::getAllCustomizedDatas($order->id_cart);

在其下方添加代码

1
2
global $cookie;
$link=new Link();

查找到

1
$this->setProductCustomizedDatas($row, $customized_datas);

在其下方添加代码

1
2
3
4
$product = new Product($row['id_product']);
$imageUrl=  $link->getImageLink($product->link_rewrite[$cookie->id_lang], $row['image']->id, 'small_default');
$tempArray= explode("/img/",$imageUrl);
$row['image_path']=_PS_ROOT_DIR_."/img/".$tempArray[1];

2.打开pdf/invoice.tpl

找到

<td style=”text-align: left; background-color: #4D4D4D; color: #FFF; padding-left: 10px; font-weight: bold; width: {if !$tax_excluded_display}25%{else}35%{/if}”>{l s=’Product / Reference’ pdf=’true’}</td>

在其下方添加代码

<td style=”background-color: #4D4D4D; color: #FFF; text-align: right; font-weight: bold; width: 10%”>{l s=’Image’ pdf=’true’}</td>

查找代码

<td style=”text-align: left; width: {if !$tax_excluded_display}25%{else}35%{/if}”>{$order_detail.product_name}</td>

在下方添加代码

<td style=”text-align: left; width:10%”><img src=”{$order_detail.image_path}” /></td>

然后你再去查看网站后台订单的的发票,弹出的pdf文件产品列表里多出了产品图片一列