Edgar
Edgar

Reputation: 79

How to set primary ID when create new Object Model record in PrestaShop?

I want check if ID reserved in DB, delete it and add new record with this ID.

$model = new TaxRulesGroup(2);
$model->delete();

$model->id = 2;
$model->id_tax_rules_group = 2;
$model->name = 'new name';
$model->active = 1;

$model->add();

any ideas ? Thank you.

Upvotes: 0

Views: 337

Answers (1)

Edgar
Edgar

Reputation: 79

From the ObjectModel class has attribute "force_id". I love PrestaShop. ;)

/** @var bool Enables to define an ID before adding object. */
public $force_id = false;

Upvotes: 2

Related Questions