Jump to content

Override and adding extra field for combination


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)
Link to comment
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..?

Link to comment
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
×
×
  • Create New...