TLDR
- If a vendor CSV upload is the only way catalog data changes, its completion report is your audit trail. Treat it that way.
- Report outcomes people act on (created, updated, un-archived, archived, invalid) with before and after values, and derive the counts from the same lists.
- Add a change to the report only after it passes validation, and compare files against stored values, not computed getters.
- Do not cap the report at a preview. The team tried a 25-row cap and removed it four days later.
- Repeated rows in one file can create twin records before the first flush. Track new records in memory, add a unique index, and clean up existing twins with an agreed keeper rule.
If vendors update your catalog by uploading CSV files, the completion report is often the only record of what each upload changed. Treat it as an audit trail. That means four things: sort every row into an outcome your operations team recognizes, list every change instead of a preview, add a row to the report only after the change passes validation and is queued to save, and make the database refuse the duplicate records an importer can quietly create.
Our joint team worked through all four in November 2026 on a custom order and catalog platform we built for an aftermarket auto parts retailer. This post covers what changed and why, the mistake the team made and then reversed, and a checklist you can reuse on your own import jobs before they cause a problem.
How we know, and the limits
How we know: This is based on the commit and merge request history of that platform between November 19 and November 23, 2026. We built the platform and still develop it together with the retailer's in-house developer, who wrote most of these changes. The client is anonymized here. Library behavior described below was checked against the Symfony, Doctrine and MySQL documentation on the day of publishing (links at the end).
Limits: This is one import pipeline: a vendor price and availability file, processed in one pass by a Symfony app on MySQL. We did not measure time saved or errors avoided, so this post makes no claims about either. If your imports run through an iPaaS or a platform's built-in importer, the ideas still apply, but you may not control the report or the schema.
What the import does
Each vendor sends a file with four columns the platform cares about: the retailer's own part number, the vendor's part number, cost, and availability. Each vendor's column names are mapped once in the admin, so a file with a missing header is rejected before any row is touched.
The importer then reads every row. A valid row either creates a vendor part, updates its cost or availability, or brings back a part that had been archived. When the file is done, any vendor part that was not in the file gets archived. That last step matters, because the file is treated as the vendor's full list and one upload can add, change or retire many records at once.
Before November, the completion email said how many rows were valid, how many parts were updated, and how many were archived. Catalog admins could not tell which parts were new, which had changed cost, or which had come back from the archive.
Sort rows into outcomes people act on
The first change was to replace "updated" with the outcomes a catalog admin actually checks:
Created: a vendor part that did not exist before. Someone may need to confirm it maps to the right product.
Updated: cost or availability changed on an existing part.
Un-archived: a part that had dropped out of earlier files and is back. This one is easy to miss and often worth a second look, because it can put an old item back on sale.
Archived: a part that was missing from this file.
Invalid rows and errors: listed by row number with the reason, such as an invalid price or a malformed part number.
Each line in the report now shows the part, its category, the old and new cost, and the old and new availability. Unchanged values stay plain and changed values are highlighted, so an admin can scan a long section quickly. The same breakdown is written to the upload record in the admin, so the counts are visible even if the email is lost.
In code, the change was small: instead of one counter and one list, the processor fills a report with a bucket for each outcome and returns counts derived from those buckets:
$changeReport = [
'created' => [],
'updated' => [],
'unarchived' => [],
];
// ... process rows, archive parts missing from the file ...
$stats = [
'created' => count($changeReport['created']),
'updated' => count($changeReport['updated']),
'unarchived' => count($changeReport['unarchived']),
'archived' => count($archivedVendorParts),
];Deriving the counts from the lists means the summary at the top of the email can never disagree with the rows below it.
Only report a change after it passes validation
The first version of the new report added a row to the "created" or "updated" list as soon as the importer decided a change was needed. If entity validation then failed, the report still claimed the change. A report that lists changes that never happened is worse than no report at all, because the people reading it have every reason to trust it.
The fix was to choose the bucket early but add the entry only after the record passes validation and is handed to Doctrine to save:
try {
$this->entityValidatorService->validateEntity($vendorPart);
$this->em->persist($vendorPart);
} catch (\Exception $e) {
$this->logger?->error('Vendor Part create failed saying: '.$e->getMessage());
return false;
}
if ($reportBucket && $entry) {
$changeReport[$reportBucket][] = $entry;
}A unit test now feeds the processor a row that fails validation and asserts that all three lists stay empty.
Compare against stored values, not computed ones
A quieter bug came from how "available" was read. On this platform a vendor part counts as available only if its own flag is on and the vendor's ordering is not paused. That combined rule is right for the storefront. It is wrong for comparing a file to the database, because a paused vendor made every part look unavailable, so a file that repeated the stored value showed up as an availability change.
The team added a separate accessor that returns only the stored flag and used it for every file comparison and report line. If your entities have computed getters that mix in other state, check which one your import uses. Comparisons should use the raw stored value.
The mistake: shortening the report
Long uploads made the new email hard to read, so on November 19 the team added jump links to each section and capped every section at a 25-row preview with a note like "25 of N shown."
The jump links were a good idea, but the cap was not, and four days later the team removed it. The merge request said it plainly: the email is the only record of what a vendor file upload changed, and a preview hides exactly the rows nobody will think to look for. Every section now lists every row, and the jump links stay.
If your report is too long to read, that is a reason to add structure, not to drop data. Group it, sort it, add links between sections, or attach the full list as a CSV file. If the full list cannot go in an email, store it somewhere durable and link to it. Do not let the only copy be a sample.
Repeated rows created twin records
On the same day as the report work, the team fixed a related problem: some vendor files repeat the same part and vendor SKU on more than one line. The importer looked up each row in the database, did not find it, and created a new vendor part. Because the importer saves everything in one flush at the end of the file, the second line could not see the first line's new record either, so it created another one. The result was twin vendor parts with the same vendor, part, type and vendor SKU.
Symfony's UniqueEntity constraint does not catch this. Its documentation warns that it cannot handle duplicates among items that have not been persisted yet, and that it offers no protection against race conditions. It checks the database, and the twin has not reached the database yet when the second line is processed.
The fix had three layers:
Remember what this run created. The processor keeps an in-memory map of new records keyed by vendor, part, type and vendor SKU. A repeated line finds the unsaved record and updates it instead of creating a second one. The map is reset at the start of every file, so one upload cannot leak into the next.
Make the database the final guard. A unique index on those four columns means a future bug, a second process or a manual insert cannot create a twin. The entity also got a matching
UniqueEntityrule so the admin shows a clear message instead of a database error.Clean up before adding the index. The index cannot be created while twins exist, so a migration removed them first.
How the cleanup chose which twin to keep
Deleting duplicates is the risky part, because other tables point at them. Customer order lines, purchase order lines and each part's current cost pointers could all reference either twin. The migration handled it in a fixed order:
Pick one keeper per group using a window function, preferring a record that is not archived, then one that is available, then the most recently updated, then the highest id.
Re-point every foreign key from the losing twins to the keeper.
Delete the losing twins.
Create the unique index, only if it does not already exist.
The ranking step looks like this (MySQL 8):
SELECT id, vendor_id, part_id, vendor_part_type_id, vendor_part_number,
ROW_NUMBER() OVER (
PARTITION BY vendor_id, part_id, vendor_part_type_id, vendor_part_number
ORDER BY
CASE WHEN archived = 1 THEN 0 ELSE 1 END DESC,
CASE WHEN available = 1 THEN 1 ELSE 0 END DESC,
updated_at DESC,
id DESC
) AS rn
FROM vendor_partWrite the keeper rule down before you write the SQL, and get the people who own the data to agree with it. Ours favors the record most likely to be in active use. Yours might favor the oldest record if other systems store its id.
Test the report as part of the import
The report is now treated as an output of the import, so it has its own tests:
A part repeated on two lines of one file reuses the first line's unsaved record instead of creating a twin.
A row that fails validation adds nothing to the report.
A paused vendor does not turn unchanged availability into a reported change.
The rendered email lists every row in every section when a section has more than 25 entries, and empty sections still show their empty-state message.
The last test renders the real email template. That is where the truncation lived, and a processor-only test would never have caught it.
A checklist for vendor file imports
Is the completion report the only record of what changed? If so, it must be complete, durable and accurate.
Does the report use outcomes your operations team acts on (created, updated, un-archived, archived, invalid) with before and after values?
Are summary counts derived from the same lists that are shown?
Is each change recorded only after it passes validation and is queued to save?
Do comparisons use stored values, not getters that mix in other state?
Can the same key appear twice in one file, and what happens before the first flush if it does?
Is there a unique index on the natural key, and a cleanup plan with an agreed keeper rule if duplicates already exist?
Does a test render the real report, not just the processor's return value?
None of this is exotic, but it is the work that turns an import from "it ran" into something an operations team can check and trust. In our opinion it is also the part most often skipped when an import is built quickly, because nobody looks at the report until something goes wrong.
If your catalog or order data moves through vendor files or custom integrations and you want a second set of eyes on them, our custom software development team can help.
Sources
UniqueEntity constraint, Symfony documentation (accessed November 30, 2026). See the warnings on race conditions and unpersisted items.
Attributes reference: UniqueConstraint, Doctrine ORM documentation (accessed November 30, 2026).
Window function descriptions: ROW_NUMBER(), MySQL 8.4 Reference Manual (accessed November 30, 2026).
