Jump to content

[SOLVE] Display product image in order detail - prestashop 1.6


Recommended Posts

Hello

 

I would like to show product image on order detail in Prestashop 1.6

I know i have to add the below code in order-detail.tpl, but where exactly do i place it, and do i need to do more then that? Should i also do an override or something? If yes, then what to override and where?

 

the code:

<img src="{$link->getImageLink('productimage', $product.image->id_image, 'home_default')}" />

Edited by PS newbi (see edit history)
Link to comment
Share on other sites

Your code is not right

 

you put 'productimage' but you need to put the $product->link_rewrite instead

 

You not need override because is a theme file you just need change your tpl file

 

It doesn't make a difference. I only get a image box with a question mark. 

How do i get the product image to show? Thanks

Link to comment
Share on other sites

This worked.
 
Step1 in class/order/Order.php
public function getProductsDetail()
{
return Db::getInstance(_PS_USE_SQL_SLAVE_)->ExecuteS('
SELECT *
FROM `'._DB_PREFIX_.'order_detail` od
LEFT JOIN '._DB_PREFIX_.'product p ON ( p.id_product = od.product_id)
LEFT JOIN '._DB_PREFIX_.'product_lang pl ON (pl.id_product = p.id_product)
LEFT JOIN '._DB_PREFIX_.'image i ON (i.id_product = p.id_product AND i.cover = 1)
WHERE od.`id_order` = '.(int)($this->id));
}
 
Step2 in  /controller/front/OrderDetailController.php
 
foreach($products as $key => $value) {
$objet_produit= new Product($value['product_id']);

$products[$key]['link_rewrite']= $objet_produit->link_rewrite;
$products[$key]['cover']= Product::getCover($value['product_id']);
}

or

 
$id_lang_default= Configuration::get('PS_LANG_DEFAULT');
foreach($products as $key => $value) {
$objet_produit= new Product($value['product_id']);

$products[$key]['link_rewrite']= $objet_produit->link_rewrite[$id_lang_default];
$products[$key]['cover']= Product::getCover($value['product_id']);
}
Step 3 in order-detail.tpl
 
<img src="{$link->getImageLink($product.link_rewrite, $product.cover.id_image, 'small_default')}" title="{$product.product_name|escape:'htmlall':'UTF-8'}" alt="{$product.product_name|escape:'htmlall':'UTF-8'}" />
Edited by PS newbi (see edit history)
Link to comment
Share on other sites

You need use the image id for the combination

<img src="{$link->getImageLink($product.link_rewrite, $product.cover.id_image, 'small_default')}" title="{$product.product_name|escape:'htmlall':'UTF-8'}" alt="{$product.product_name|escape:'htmlall':'UTF-8'}" />

you need get the image id and change  $product.cover.id_image

Link to comment
Share on other sites

Ok I dont sure  but is something like these

 

 

In your step2 use Product::getCombinationImages to get the combinations images then In your ps_order_detail table you have a field product_attribute_id 

 

You need do a for to compare ps_product_attribute to get the id_image to get the correct id for the image

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...