Jump to content

Override and adding extra field for combination


williamespindola
 Share

Recommended Posts

Hello, I'm override a Combination class and adding an extra field for that. To do this I Create a new class on override/classes/Combination.php and create my necessary methods like this:

<?php

class Combination extends CombinationCore
{
    public $commission;

    public function __construct()
    {
        $this->addCommissionField();
    }

    public function addCommissionField()
    {
        parent::$definition['fields']['commission'] = array(
            'type' => self::TYPE_FLOAT, 
            'validate' => 'isGenericName', 
            'required' => false, 
            'size' => 10
        );
    }
}

For this time this work better. Another featured, is a field for that.

 

But when I save the combination, this field is not save on database. I debug The Object model in this point:

	public function __construct($id = null, $id_lang = null, $id_shop = null)
	{
		if (!ObjectModel::$db)
			ObjectModel::$db = Db::getInstance();

		$this->def = ObjectModel::getDefinition($this);
                // debut it
		p($this->def);
		$this->setDefinitionRetrocompatibility();

And the new field not exists on this point. Someone can help to understand? My prestashop is 1.6

Edited by williamespindola (see edit history)

Share this post


Link to post
Share on other sites

  • 2 weeks later...
  • 6 months later...

Nemo1 in this case the problem is not this. To do what I needed is necessary overrate tree classes: Combination.php, Product.php, AdminProductsController.php and a lot of methods, a very sad job. 

 

Hi Williame,

 

Can you give me the solution please..?

Share this post


Link to post
Share on other sites

  • 1 month 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
 Share

×
×
  • Create New...

Important Information

Cookies ensure the smooth running of our services. Using these, you accept the use of cookies. Learn More