Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

SQL error when catalog platform import #189

Closed
tatarincev opened this issue Dec 20, 2018 · 1 comment
Closed

SQL error when catalog platform import #189

tatarincev opened this issue Dec 20, 2018 · 1 comment
Assignees

Comments

@tatarincev
Copy link
Contributor

Steps to reproduce:
1.Select any category dictionary property value for any category.
image
2. Do catalog export More/Platform Export/import/Export/ check catalog / export
3. Import resulting zip in the platform instance with empty catalog tables.
4. Got this exception
The INSERT statement conflicted with the FOREIGN KEY constraint "FK_dbo.PropertyValue_dbo.PropertyDictionaryItem_DictionaryItemId". The conflict occurred in database "VirtoCommerce3", table "dbo.PropertyDictionaryItem", column 'Id'.

Technical details:
This happens because incorrect order of inserting data into the database, caused this reference violation.
The catalog data exports with this order. Catalogs, Categories, Properties, Dictionaries, Products and imported with the same order. And there is a situation when the system tried to insert Categories with property values earlier than these dictionary properties would be inserted into the database.
https://github.com/VirtoCommerce/vc-module-catalog/blob/master/VirtoCommerce.CatalogModule.Web/ExportImport/CatalogExportImport.cs#L87

@tatarincev tatarincev added this to the Operations milestone Dec 20, 2018
tatarincev pushed a commit that referenced this issue Dec 25, 2018
* - Fixed FK violation on import by changing export order + resolving property CatalogId and CategoryId after they are created;
- PropertyEntity.Patch: CategoryId and CatalogId are filled from source entity now;
- Fixed Sonar warnings with redundant parameters and string.Format();
- Replaced "..." with "…" (single symbol alt+0133 on numpad);

* Minor code refactoring

* Cleanup
@tatarincev
Copy link
Contributor Author

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants