Jump to content

Add product's warehouse position at the Backoffice order page.


juanmlg

Recommended Posts

Hello, I want to show the product's warehouse position at the backoffice order page, if it's possible inside the products table of the order. It 's possible? In wich page is the backoffice order code? Any help? I know that the warehouse position is in the database.

 

 

thanks so much!

Link to comment
Share on other sites

(Assuming PrestaShop 1.5+)

 

You will need to override the AdminOrderController templates to display the data and override the AdminOrderController to get the data to display.

 

Getting the new data feild (one possibility of many):

Override AdminOrderController::renderView to snag the warehouse data and add the 'location' data on a per-product basis. I think the foreach loop right under Warehouse::getWarehousesByProductId(...) provides access to the 3 things to get the location id_product, id_product_attribute, and id_warehouse. Use those id's to grab the data point from

WarehouseProductLocation::getProductLocation($id_product, $id_product_attribute, $id_warehouse)

and store it in the $products array. You may need to store it in a temporary array and find a way to insert it into the $products array if that array isn't keyed by product id.

 

ProTip: Don't forget to end the override with:

return AdminController::renderView();

as calling parent::renderView() will not get you the results you expect.

 

As for displaying the new data feild:

 

Copy:

admin/themes/default/template/controllers/orders/_product_line.tpl

admin/themes/default/template/controllers/orders/form.tpl

admin/themes/default/template/controllers/orders/helpers/views/view.tpl

 

to the BO template override folder

override/controllers/admin/template/orders/

 

Add the new column for 'location' field to override/controllers/admin/template/_product_line.tpl

 

Make sure that the column headers/footers in override/controllers/admin/template/orders/form.tpl and /helpers/views/view.tpl

match the updated columns in the overridden product_line.tpl file. You'll also need to get the view.tpl file to use the overridden files instead of the default files.

 

This isn't an exhaustive how-to, but it should get you pointed in the right direction.

 

Hope this helps,

 

PS: edits are in red.

Edited by Terragg (see edit history)
  • Like 1
Link to comment
Share on other sites

  • 2 weeks later...

Hello,

 

I managed to display the location field in the BO by adding the following lines to the /site/admin/themes_default / template/controllers/orders/_product_line.tpl:

 

 

 

<td align="center" class="location">

<span class="location"> {$ product ['location']} </ span>

{if} $ can_edit

<span class="location" style="display:none;">

<input name="location" class="location" value="{$product['location']|htmlentities}" size="2" />

</ span>

{/ if}

</ td>

 

 

[/ CODE]

 

but I can not display the text "location" at the top of the table, I do a lot of changes to the file form.tpl I'm in prestashop 1.5.4.0? someone a solution?

 

 

and thank you

Edited by amine.bahou (see edit history)
Link to comment
Share on other sites

Hi, I used a simple solution:

 

I override the template file in admin/themes/default/template/controllers/orders/_product_line.tpl

 

Alter the code like this from line 36 and insert the red code:

 

 

<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='Ref:'} {$product.product_reference}<br />{/if}

{if $product.product_supplier_reference}{l s='Ref Supplier:'} {$product.product_supplier_reference}<br />{/if}

{$warehouse_list[$product['id_warehouse']]['name']}

</a></td>

 

I used existing controllers variables, and you don't need modify the AdminOrderController.

I hope this can help!

Thxs

Link to comment
Share on other sites

Hi, a made another change in pfd/invoice.tlp to print the stock location in product description:

 

pdf/invoice.tlp

 

line 128:

 

<td style="text-align: left; width: 45%">(Ref. {$order_detail.product_reference}) {$order_detail.product_name} / {Warehouse::getWarehouseNameById($order_detail['id_warehouse'])}</td>

 

 

The red code was added.

 

This show the product ref. and stock location in order invoice, to be printed.

  • Like 1
Link to comment
Share on other sites

  • 1 month later...

Hi, a made another change in pfd/invoice.tlp to print the stock location in product description:

 

pdf/invoice.tlp

 

line 128:

 

<td style="text-align: left; width: 45%">(Ref. {$order_detail.product_reference}) {$order_detail.product_name} / {Warehouse::getWarehouseNameById($order_detail['id_warehouse'])}</td>

 

 

The red code was added.

 

This show the product ref. and stock location in order invoice, to be printed.

Hello!! i found really usefull your solution but I cant make the warehouse or teh product position in the wareghouse appear.. any idea on what can I change?

 

Reference is working perfect!

Link to comment
Share on other sites

  • 2 months later...
  • 4 weeks later...

Hi there :D

The item location plus qttyies. I tryed to place a like with a for each on product.warehouse_id, but i really don't know waht key to call or even where the vars of warehouse are placed.  i have like 2 month trying. Prestashop 1.5.5

 

For example:   Name warhouse - Qttyies

 

But in the Product.tpl from the front view.

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

Hi XZelot, I don't tried show this information in product.tpl.

You need to search in the correct controller for the smarty variable passed to product.tpl. I think it's in the ProductController.php (front)

If this information (warehouse) was sent to the smarty variable, is possible show this information in product.tpl.

If not, you need override the productController, and send this information to smarty variable.

 

I hope was useful.

 

Thank you!
Link to comment
Share on other sites

 

Hi XZelot, I don't tried show this information in product.tpl.
You need to search in the correct controller for the smarty variable passed to product.tpl. I think it's in the ProductController.php (front)
If this information (warehouse) was sent to the smarty variable, is possible show this information in product.tpl.
If not, you need override the productController, and send this information to smarty variable.
 
I hope was useful.
 
Thank you!

 

 

none happens on productconrtoller, i opened de admin warehouse controller but still can't do it :(

 

The thing i need to do is include an php file made by myself but i don't know how to do it, couse when i use the php go with error even using the smarty integration.

Edited by Xzelot (see edit history)
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...