ipaelo Posted July 18, 2016 Share Posted July 18, 2016 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?. Link to comment Share on other sites More sharing options...
ventura Posted July 18, 2016 Share Posted July 18, 2016 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. Link to comment Share on other sites More sharing options...
ipaelo Posted July 19, 2016 Author Share Posted July 19, 2016 OMG!!! I was soooo closed. $category = new Category($productObj->id_category_default, Configuration::get('PS_LANG_DEFAULT')); I don´t know how to do this. THANK YOU SOOOOO MUCH Link to comment Share on other sites More sharing options...
aguiu Posted July 16, 2017 Share Posted July 16, 2017 i use prestashop 1.6.1.4 and default bootstrap theme. Where i can find the form.tpl? How i can override it? Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now