Cannot import a product exported with 2pack export button


Hi, I tried exporting a product from demo instance and importing it into my local instance.

Found three issues:

1 - The import fails because it tries to insert the M_Product_Acct record exported, but when creating the product on MProduct.afterSave that record is automatically created, so it throws a non-unique exception and fails - note the auto-created record ends with a different UUID than the created one, and possibly with different accounting configuration in case it was modified

2 - To overcome that I deleted the M_Product_Acct from the xml and tried again, this time the import failed because MCost was not able to find the product.
There is a problem in MCost.beforeSave if the product and the cost are created within the same transaction, because is trying to look for the product out of trx and it cannot find it, the following patch fixed this issue:

3 - But after that it raised same problem as (1) but with M_Cost table, the M_Cost table is auto-created on MProduct.beforeSave and it cannot be inserted here - same as (1) the cost has different UUID and it can end in a different cost than the intended (in this case it sounds fine as it requires an initial cost of zero)


Carlos Ruiz




Diego Ruiz
June 25, 2020, 2:55 PM

Triaged by Diego Ruiz,

Steps to reproduce:

  1. Created a test product in triage1

  2. Pack it out from the toolbar button

  3. Login as GardenAdmin in triage 0

  4. Pack in the 2Pack from step 2

Expected results:

The test product should be imported in the system

Actual result:

The system throws the following error
Could not save record - Require unique data:

Please change information.: ERROR: duplicate key value violates unique constraint "m_product_acct_pkey" Detail: Key (m_product_id, c_acctschema_id)=(1000002, 101) already exists.

Carlos Ruiz
June 26, 2020, 8:02 PM

Closing after 7 years of inactivity. The issue is not that critical as prioritized initially.

Import product maybe is better done via CSV, but if decided to use 2pack - then it must take into account to not export the records that are automatically created (like translations and accounting configuration).
BTW, this 2pack error is generic with any table that creates records on before/afterSave and those records are being imported by the 2pack.




Carlos Ruiz

Tested By



Affects versions