|
dolibarr 25.0.0-alpha
|
Class of triggered functions that reconcile imported variants with the business logic of the screen. More...


Public Member Functions | |
| __construct ($db) | |
| Constructor. | |
| runTrigger ($action, $object, User $user, Translate $langs, Conf $conf) | |
| Function called when a Dolibarr business event is done. | |
Public Member Functions inherited from DolibarrTriggers | |
| __construct (DoliDB $db) | |
| Constructor. | |
| getName () | |
| Returns the name of the trigger file. | |
| getDesc () | |
| Returns the description of trigger file. | |
| getVersion () | |
| Returns the version of the trigger file. | |
| setErrorsFromObject ($object) | |
| setErrorsFromObject | |
Public Attributes | |
| const | VARIANTS_TABLES |
| Tables of the module that need a business reconciliation after an import. | |
Private Member Functions | |
| refuseBulkModeOnVariants ($object, Translate $langs) | |
| Refuse the fast_bulk mode on the tables of the module. | |
| countCombinations ($fkproductparent=0, $fkproductchild=0, $fkproductparentnot=0) | |
| Count the combinations matching the given products, in the current entity. | |
| reconcileCombination ($rowid, User $user, Translate $langs) | |
| Check the consistency of an imported combination and propagate it to the child product. | |
| reconcileValuePair ($rowid, User $user, Translate $langs) | |
| Reconcile a variant from one of its attribute/value links. | |
| reconcilePriceLevel ($rowid, User $user, Translate $langs) | |
| Propagate an imported price level to the child product. | |
Class of triggered functions that reconcile imported variants with the business logic of the screen.
The import engine only runs raw SQL: it writes a row of llx_product_attribute_combination without creating nor refreshing the child product. This trigger calls back ProductCombination\createProductCombination(), the very method used by the screen (variants/combinations.php) and by the REST API (api_products.class.php), so that an imported variant is identical to a variant entered on screen.
It never rolls back: it runs inside the transaction of the import and DoliDB\rollback() only decrements the counter when the transaction is nested. Returning a negative value is the only way to have imports/import.php roll the whole import back.
Limitation: the screen refuses two combinations of the same parent carrying the same set of attribute values, this trigger cannot. The value set of an imported variant is spread over several lines of the file and the engine offers no end of import event in strict_line mode, so a set read here is only a partial set and comparing it would reject legitimate variants (a parent declined by colour alone and by colour plus size shares a partial set). Only the weaker invariant that can be decided on a single line is enforced: a child product belongs to exactly one combination.
Definition at line 47 of file interface_50_modVariants_VariantsImport.class.php.
| InterfaceVariantsImport::__construct | ( | $db | ) |
Constructor.
Definition at line 65 of file interface_50_modVariants_VariantsImport.class.php.
References description, name, and version.
|
private |
Count the combinations matching the given products, in the current entity.
A parameter left to 0 is not part of the filter.
| int | $fkproductparent | Parent product to match |
| int | $fkproductchild | Child product to match |
| int | $fkproductparentnot | Parent product to exclude |
Definition at line 170 of file interface_50_modVariants_VariantsImport.class.php.
References dol_syslog().
Referenced by reconcileCombination().
Check the consistency of an imported combination and propagate it to the child product.
Definition at line 204 of file interface_50_modVariants_VariantsImport.class.php.
References countCombinations(), and dol_syslog().
Referenced by runTrigger().
Propagate an imported price level to the child product.
Definition at line 451 of file interface_50_modVariants_VariantsImport.class.php.
References dol_syslog(), and getDolGlobalInt().
Referenced by runTrigger().
Reconcile a variant from one of its attribute/value links.
The value set is only complete once the last line of the variant has been read, so this runs once per line and converges. Every pass is idempotent.
| int | $rowid | Row id of the attribute/value link |
| User | $user | Object user |
| Translate | $langs | Object langs |
Definition at line 327 of file interface_50_modVariants_VariantsImport.class.php.
References dol_syslog(), getDolGlobalInt(), and getDolGlobalString().
Referenced by runTrigger().
|
private |
Refuse the fast_bulk mode on the tables of the module.
In fast_bulk mode no per line trigger is emitted, so nothing would ever create the link with the child product nor propagate the prices: the import would leave combinations that are invisible on the product card.
| CommonObject | stdClass | $object | Object carrying bulk_stats |
| Translate | $langs | Object langs |
Definition at line 144 of file interface_50_modVariants_VariantsImport.class.php.
References $object, and dol_syslog().
Referenced by runTrigger().
Function called when a Dolibarr business event is done.
| string | $action | Event action code |
| CommonObject | stdClass | $object | Object, a business object prototype or a stdClass when it comes from the import engine |
| User | $user | Object user |
| Translate | $langs | Object langs |
| Conf | $conf | Object conf |
Reimplemented from DolibarrTriggers.
Definition at line 87 of file interface_50_modVariants_VariantsImport.class.php.
References $object, dol_syslog(), isModEnabled(), reconcileCombination(), reconcilePriceLevel(), reconcileValuePair(), and refuseBulkModeOnVariants().