Jump to content

Add Category before product name when add a product in a backoffice order


ipaelo

Recommended Posts

Hi all,

 

I am trying to add the category name before the product´s name when someone want to make an order at the backoffice.

 

The problem is that I don´t know how to get the category in the admin.

 

$.each(res.products, function() {
products_found += '<option '+(this.combinations.length > 0 ? 'rel="'+this.qty_in_stock+'"' : '')+' value="'+this.id_product+'">'+this.name+(this.combinations.length == 0 ? ' - '+this.formatted_price : '')+'</option>';
 
This is the code that show in a dropdown the products found at admin/themes/default/template/controllers/orders/form.tpl

 

 

Can anybody help me, please?.

post-226912-0-71929500-1468847499_thumb.jpg

Link to comment
Share on other sites

Override the function

ajaxProcessSearchProducts()

In the file

controllers\admin\AdminOrdersController.php

below this

  $productObj = new Product((int)$product['id_product'], false, (int)$this->context->language->id);

add

$category = new Category($productObj->id_category_default, Configuration::get('PS_LANG_DEFAULT'));
$product['product_category'] =  $category->name;

Then in

\admin123\themes\default\template\controllers\orders\form.tpl

 // add this part

 

products_found += '<option '+(this.combinations.length > 0 ? 'rel="'+this.qty_in_stock+'"' : '')+' value="'+this.id_product+'">'+this.product_category+' - '+this.name+(this.combinations.length == 0 ? ' - '+this.formatted_price : '')+' - '+this.formatted_price+'</option>';

 

 

 

 

Saludos.

FJvzk01.png

Link to comment
Share on other sites

  • 11 months later...

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