Jump to content

Override AdminCartRulesController.php


Recommended Posts

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

 

Captura.jpg

 

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 by z72diego (see edit history)
Link to comment
Share on other sites

  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

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