When managing large product catalogs in WooCommerce, importers often struggle with how to safely update or completely replace product attributes via CSV. In this case, the solution was to enhance a custom PIM importer by introducing a new column that allows precise control over how attributes are handled during import.
This approach provides both flexibility and data integrity for bulk product updates.
Issue Background
The existing importer behavior had several limitations:
- Attributes could be added or updated but not reliably removed
- Values like
__DELETE__,NA, orN/Adid not behave as expected - In some cases, these values were saved as literal attribute values such as “Delete”
WooCommerce also requires explicit attribute targeting, which made it difficult to fully control attribute data through partial updates.
Diagnosis
Limitations of standard delete logic
The importer supported deletion using patterns like:
attr_name1,attr_value1
Size,__DELETE__
This only works when the attribute name is provided. Without it, the importer cannot determine what to delete.
Lack of full attribute reset capability
The importer defaulted to a merge model, which preserved existing attributes and only updated provided values. There was no way to fully replace all attributes for a product.
Need for dual-mode behavior
To solve this, the importer required two modes: a safe merge mode and a full replacement mode.
Resolution Steps
Step 1: Introduce override_attributes column
A new optional CSV column was added:
override_attributes
- Y = Replace all attributes
- N or blank = Merge and update only
Step 2: Implement replace mode
When override_attributes = Y:
- All existing attributes are removed first
- Only attributes in the CSV row are applied
- Blank values remove specific attributes
- No attributes provided results in a clean slate
Step 3: Maintain merge mode
When override_attributes = N or blank:
- Existing attributes remain unchanged
- Only non-blank values are updated
- Blank values are ignored
Step 4: Improve delete handling
To properly delete attributes:
__DELETE__must be paired with a valid attribute name- If the attribute name is missing, the value is ignored
part_number,attr_name1,attr_value1
177907,Size,__DELETE__
Step 5: Add safeguards
- If
attr_nameis empty, values like__DELETE__,NA, orN/Aare ignored - Prevents accidental creation of invalid attributes
Step 6: Test and deploy
- Validated behavior in staging
- Confirmed both modes function correctly
- Deployed to production successfully
Final Outcome
- Full control over attribute behavior per product
- Clean replacement using override mode
- Safe updates using merge mode
- Reliable deletion logic without side effects
Key Takeaways
- WooCommerce imports require explicit logic for attribute deletion
- Merge-only approaches are not sufficient for complex catalogs
- Adding control columns improves flexibility and reliability
- Safeguards are essential to prevent bad data
If you need help customizing WooCommerce imports or building scalable product data workflows, our team can help.
Contact Freshy for expert WooCommerce development support.