Skip to content

Commit

Permalink
add import kit
Browse files Browse the repository at this point in the history
  • Loading branch information
atm-jonathan committed Mar 13, 2024
1 parent 996f915 commit 5e5792d
Show file tree
Hide file tree
Showing 4 changed files with 27 additions and 1 deletion.
22 changes: 22 additions & 0 deletions htdocs/core/modules/modProduct.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -944,6 +944,28 @@ public function __construct($db)
$this->import_examplevalues_array[$r] = array('l.fk_product'=>'ref:PRODUCT_REF or id:123456', 'l.lang'=>'en_US', 'l.label'=>'Label in en_US', 'l.description'=>'Desc in en_US');
$this->import_updatekeys_array[$r] = array('l.fk_product'=>'ProductOrService', 'l.lang'=>'Language');
}

if (getDolGlobalInt('PRODUIT_SOUSPRODUITS')) {
// Import products kit
$r++;
$this->import_code[$r] = $this->rights_class . '_' . $r;
$this->import_label[$r] = "AssociatedProducts"; // Translation key
$this->import_icon[$r] = $this->picto;
$this->import_entities_array[$r] = array(); // We define here only fields that use another icon that the one defined into import_icon
$this->import_tables_array[$r] = array('pa' => MAIN_DB_PREFIX . 'product_association');
$this->import_fields_array[$r] = array('pa.fk_product_pere' => 'ParentProducts', 'pa.fk_product_fils' => 'ComposedProduct', 'pa.qty' => 'Qty', 'pa.incdec' => 'ComposedProductIncDecStock', 'pa.rang' => 'rang');

$this->import_convertvalue_array[$r] = array(
'pa.fk_product_pere' => array('rule' => 'fetchidfromref', 'classfile' => '/product/class/product.class.php', 'class' => 'Product', 'method' => 'fetch', 'element' => 'Product'),
'pa.fk_product_fils' => array('rule' => 'fetchidfromref', 'classfile' => '/product/class/product.class.php', 'class' => 'Product', 'method' => 'fetch', 'element' => 'Product')
);
$this->import_examplevalues_array[$r] = array(
'pa.fk_product_pere' => "ref:PREF123456",
'pa.fk_product_fils' => "ref:PREF123456",
'pa.qty' => "100",
'pa.incdec' => "0",
'pa.rang' => "1");
}
}


Expand Down
2 changes: 2 additions & 0 deletions htdocs/install/mysql/migration/19.0.0-20.0.0.sql
Original file line number Diff line number Diff line change
Expand Up @@ -268,3 +268,5 @@ ALTER TABLE llx_facture_fourn ADD INDEX idx_facture_fourn_tms (tms);
ALTER TABLE llx_element_element MODIFY COLUMN sourcetype VARCHAR(64) NOT NULL;
ALTER TABLE llx_element_element MODIFY COLUMN targettype VARCHAR(64) NOT NULL;
ALTER TABLE llx_c_type_contact MODIFY COLUMN element VARCHAR(64) NOT NULL;

ALTER TABLE llx_product_association ADD COLUMN import_key varchar(14) DEFAULT NULL;
Original file line number Diff line number Diff line change
Expand Up @@ -20,3 +20,4 @@
ALTER TABLE llx_product_association ADD UNIQUE INDEX uk_product_association (fk_product_pere, fk_product_fils);

ALTER TABLE llx_product_association ADD INDEX idx_product_association_fils (fk_product_fils);

3 changes: 2 additions & 1 deletion htdocs/install/mysql/tables/llx_product_association.sql
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ create table llx_product_association
fk_product_fils integer NOT NULL DEFAULT 0, -- id du sous-produit
qty double NULL,
incdec integer DEFAULT 1, -- when set to 1 changing stock of product will change stock of linked product too
rang integer DEFAULT 0
rang integer DEFAULT 0,
import_key varchar(14) DEFAULT NULL
)ENGINE=innodb;

0 comments on commit 5e5792d

Please sign in to comment.