z72diego Posted September 17, 2017 Share Posted September 17, 2017 (edited) Hello!! I want to make an override of a back-office file (AdminCartRulesController.php) to facilitate the process of generating discount coupons for certain products. I just want to display product reference next to the product name in the product selector of the "New discount" section (I attached an image to be more graphic). I think this is the part I need to edit: case 'products': $products = array('selected' => array(), 'unselected' => array()); $results = Db::getInstance()->executeS(' SELECT DISTINCT name, p.id_product as id FROM '._DB_PREFIX_.'product p LEFT JOIN `'._DB_PREFIX_.'product_lang` pl ON (p.`id_product` = pl.`id_product` AND pl.`id_lang` = '.(int)Context::getContext()->language->id.Shop::addSqlRestrictionOnLang('pl').') '.Shop::addSqlAssociation('product', 'p').' WHERE id_lang = '.(int)Context::getContext()->language->id.' ORDER BY name'); foreach ($results as $row) { $products[in_array($row['id'], $selected) ? 'selected' : 'unselected'][] = $row; } Context::getContext()->smarty->assign('product_rule_itemlist', $products); $choose_content = $this->createTemplate('product_rule_itemlist.tpl')->fetch(); Context::getContext()->smarty->assign('product_rule_choose_content', $choose_content); break; Edited September 19, 2017 by z72diego (see edit history) Link to comment Share on other sites More sharing options...
z72diego Posted September 17, 2017 Author Share Posted September 17, 2017 (edited) It is also a solution to show only the product reference, removing the product name. I tried with: $results = Db::getInstance()->executeS(' SELECT reference, id_product as id FROM '._DB_PREFIX_.'product ORDER BY ASC'); but no luck Edited September 19, 2017 by z72diego (see edit history) Link to comment Share on other sites More sharing options...
Scully Posted September 18, 2017 Share Posted September 18, 2017 posting pages of code makes the post rather unreadable. the field might be named "p.reference" ... p. for table alias (products). I haven't read all code. Link to comment Share on other sites More sharing options...
z72diego Posted September 19, 2017 Author Share Posted September 19, 2017 On 9/18/2017 at 8:37 PM, Scully said: posting pages of code makes the post rather unreadable. the field might be named "p.reference" ... p. for table alias (products). I haven't read all code. Thank you Scully, I apologize for that, I'll keep it in mind for the next one. Thanks for your answer, I'll test if it works! 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