Repository navigation
Catalog import: row-level import with dry run and per-row results - #885
Merged
Merged
Conversation
…egories, brands and collections
…ing, create defaults of the panel, picture urls
…row failure isolation - Name-only rows match by the stored name, not by the slug the name would get, so an entity whose slug was renumbered (apple-2) is found; a name shared by several entities is rejected - Specification and product attributes: a SeName already used by another attribute is rejected - Products (row API): a Sku already used by another product is rejected - A row that throws is reported rejected (FailedError) and the batch goes on; the panel's spreadsheet import still throws - Row-created products get the remaining panel defaults (MaxEnteredPrice, downloads, recurring) - Brand, categories, collections and parent category are read once per row; product attributes once per batch - Shared batch loop, ImportMode and slug lookup moved to ImportRows; dead LowStock line removed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Type: feature
Issue
Catalog import exists only as the panel's spreadsheet (XLSX) import. It is all-or-nothing from the caller's point of view: it reports nothing per row, has no dry run, silently skips what it cannot use and cannot import product attributes, specification attributes or variants. Integrations and API clients that send catalog data in batches need a row-level contract: what was created, updated or rejected, and why, before anything is written.
Solution
A row-level import contract next to the existing panel import:
IRowImport<TDto>.Import(rows, dryRun, cancellationToken)returns anImportBatchResultwith oneImportRowResultper row (Created / Updated / Rejected, id, key, errors, warnings). Dry run and the real run share one code path.ProductDto.PictureUrls(row import only) replaces Picture1..3, with a picture cap for the row API.ImportHtmlGuardrejects text fields containing HTML that the store's sanitizer would remove (only when HTML sanitization is enabled). It detects and never rewrites.IImportDataObject<T>(panel) andIRowImport<T>.Commits are split by area: categories/brands/collections → products → specification and product attributes → variants.
Breaking changes
None to public APIs. A behaviour change to note for the panel spreadsheet import of categories, brands and collections:
Rejected rows are written to the log.
Testing
dotnet test src/Tests/Grand.Business.Catalog.Tests— ExportImport tests cover every importer: created / updated / rejected rows, dry run writes nothing, unknown id in Row vs Panel mode, SeName/SKU matching, the HTML guard on and off, the time budget, attribute option merge, and variant combinations.