Jump to content

Override class SpecificPriceRuleCore Prestashop 1.7 to add new field


ad3r

Recommended Posts

Hi,

I would add field into class SpecificPriceRuleCore i create the file SpecificPriceRule.php in the path /override/classes/
how can we add a field in the static $definition

I see the new field on the Backoffice but I cannot save the value entered

here is my code:

class SpecificPriceRule extends SpecificPriceRuleCore
{

    public $lang_shop;
	
	SpecificPriceRule::$definition['lang_shop'] = array('type' => self::TYPE_INT, 'shop' => true, 'validate' => 'isInt');


}

I have this error please check attached file screenshot 

 

thank you.

error_specificprice.png

Link to comment
Share on other sites

Please try:

class SpecificPriceRule extends SpecificPriceRuleCore
{
    public $lang_shop;
	
	public function __construct($id = null, $id_lang = null)
    {
		self::$definition['fields']['lang_shop'] = array('type' => self::TYPE_INT, 'shop' => true, 'validate' => 'isInt');
		parent::__construct($id, $id_lang);
	}
}

 

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