Today i want to show you how to add manufacturer information field to table with product list on order specification page in your Prestashop admin panel. Modification is easy and you can achieve it without touching PrestaShop core. We will just simply modify back office template files located in admin/themes/default directory.
If you are looking for tutorial for PrestaShop 1.7 check this: Brand on list of purchased products in PrestaShop 1.7
How to add new field to product list table?
It's very simple html / smarty task. Open file adminXXXX/themes/default/template/controllers/orders/helpers/view/view.tpl where adminXXXX is your admin directory. You can find there table with fields definition, you can find it near 886 line (prestashop 1.6). it looks like:
<table class="table" id="orderProducts"> <thead> <tr> <th></th> <th><span class="title_box ">{l s='Product'}</span></th> <th> <span class="title_box ">{l s='Unit Price'}</span> <small class="text-muted">{$smarty.capture.TaxMethod}</small> </th> <th class="text-center"><span class="title_box ">{l s='Qty'}</span></th> {if $display_warehouse}<th><span class="title_box ">{l s='Warehouse'}</span></th>{/if} {if ($order->hasBeenPaid())}<th class="text-center"><span class="title_box ">{l s='Refunded'}</span></th>{/if} {if ($order->hasBeenDelivered() || $order->hasProductReturned())} <th class="text-center"><span class="title_box ">{l s='Returned'}</span></th> {/if} {if $stock_management}<th class="text-center"><span class="title_box ">{l s='Available quantity'}</span></th>{/if} <th> <span class="title_box ">{l s='Total'}</span> <small class="text-muted">{$smarty.capture.TaxMethod}</small> </th> <th style="display: none;" class="add_product_fields"></th> <th style="display: none;" class="edit_product_fields"></th> <th style="display: none;" class="standard_refund_fields"> <i class="icon-minus-sign"></i> {if ($order->hasBeenDelivered() || $order->hasBeenShipped())} {l s='Return'} {elseif ($order->hasBeenPaid())} {l s='Refund'} {else} {l s='Cancel'} {/if} </th> <th style="display:none" class="partial_refund_fields"> <span class="title_box ">{l s='Partial refund'}</span> </th> {if !$order->hasBeenDelivered()} <th></th> {/if} </tr> </thead> <tbody> {foreach from=$products item=product key=k} {* Include customized datas partial *} {include file='controllers/orders/_customized_data.tpl'} {* Include product line partial *} {include file='controllers/orders/_product_line.tpl'} {/foreach} {if $can_edit} {include file='controllers/orders/_new_product.tpl'} {/if} </tbody> </table>
we just simple have to add there new field in that way:
<th><span class="title_box">{l s='Manufacturer'}</span></th>
So, we just simple have to modify whole table code to: (I highlighted new line)
<table class="table" id="orderProducts"> <thead> <tr> <th></th> <th><span class="title_box ">{l s='Product'}</span></th> <th><span class="title_box">{l s='Manufacturer'}</span></th> <th> <span class="title_box ">{l s='Unit Price'}</span> <small class="text-muted">{$smarty.capture.TaxMethod}</small> </th> <th class="text-center"><span class="title_box ">{l s='Qty'}</span></th> {if $display_warehouse}<th><span class="title_box ">{l s='Warehouse'}</span></th>{/if} {if ($order->hasBeenPaid())}<th class="text-center"><span class="title_box ">{l s='Refunded'}</span></th>{/if} {if ($order->hasBeenDelivered() || $order->hasProductReturned())} <th class="text-center"><span class="title_box ">{l s='Returned'}</span></th> {/if} {if $stock_management}<th class="text-center"><span class="title_box ">{l s='Available quantity'}</span></th>{/if} <th> <span class="title_box ">{l s='Total'}</span> <small class="text-muted">{$smarty.capture.TaxMethod}</small> </th> <th style="display: none;" class="add_product_fields"></th> <th style="display: none;" class="edit_product_fields"></th> <th style="display: none;" class="standard_refund_fields"> <i class="icon-minus-sign"></i> {if ($order->hasBeenDelivered() || $order->hasBeenShipped())} {l s='Return'} {elseif ($order->hasBeenPaid())} {l s='Refund'} {else} {l s='Cancel'} {/if} </th> <th style="display:none" class="partial_refund_fields"> <span class="title_box ">{l s='Partial refund'}</span> </th> {if !$order->hasBeenDelivered()} <th></th> {/if} </tr> </thead> <tbody> {foreach from=$products item=product key=k} {* Include customized datas partial *} {include file='controllers/orders/_customized_data.tpl'} {* Include product line partial *} {include file='controllers/orders/_product_line.tpl'} {/foreach} {if $can_edit} {include file='controllers/orders/_new_product.tpl'} {/if} </tbody> </table>
How to display manufacturer name in new filed?
in this case we have to modify different file: adminXXXX/themes/default/template/controllers/orders/_product_line.tpl. We have there functions to display product information associated with order. So, we have to add there new <td></td> field. By default code looks like: (you can find it near line 34)
<tr class="product-line-row"> <td>{if isset($product.image) && $product.image->id}{$product.image_tag}{/if}</td> <td> <a href="index.php?controller=adminproducts&id_product={$product['product_id']}&updateproduct&token={getAdminToken tab='AdminProducts'}"> <span class="productName">{$product['product_name']}</span><br /> {if $product.product_reference}{l s='Reference number:'} {$product.product_reference}<br />{/if} {if $product.product_supplier_reference}{l s='Supplier reference:'} {$product.product_supplier_reference}{/if} </a> </td>
Right after this code add field with manufacturer information, we will use Manufacurer class function getNameById (function returns manufacturer name), code below:
<td> {Manufacturer::getnamebyid($product.id_manufacturer)} </td>
And that's all. after page refresh you should see there new field with manufacturer name. If you dont see it, make sure that you recompiled theme and cleared shop cache.