ARTICLE

Magento 2 Product CSV Import: Import Behaviors, Validation Strategy, Image Import, and Fixing Common Row Errors

Magento 2 Product CSV Import: Import Behaviors, Validation Strategy, Image Import, and Fixing Common Row Errors

Magento 2 imports products from a CSV under System > Data Transfer > Import. You choose an entity, one of three behaviors (Add/Update, Replace, Delete), a validation strategy, and separators, then Check Data and Import. Most failures come from four places: the wrong behavior, separator mismatches, image paths, and attribute values that do not exist.

The import screen looks simple, and for a ten-row file it is. The trouble starts with real catalogs: a Replace run that wipes references, a multiple value separator that splits category paths in the wrong place, images that will not attach, and error messages that name a row but not the cause. This guide explains what each setting does according to Adobe’s documentation and the import source code, and gives a fix for each common error.

The three import behaviors

The behavior decides what Magento does when a SKU in the file already exists. Adobe’s import documentation defines them as follows.

Behavior Existing SKU New SKU Columns used Main risk
Add/Update Updated; every field except sku can change Created Only the columns present Multi-value fields are merged, not replaced
Replace Existing product data is cleared and replaced Error if the SKU does not exist All columns in the file References to the old product are lost
Delete Deleted Error sku only; all other columns ignored Irreversible without a backup

Add/Update

This is the behavior for almost every job. New SKUs are created and existing ones are updated. Adobe notes that missing tax classes, categories, and SKUs referenced by the file are created automatically, which is convenient and also how a typo in a category path becomes a new, empty category.

One documented caveat catches teams repeatedly: for multi-value fields such as websites and categories, Add/Update does not remove values that are missing from the file. If a product is in three categories and your CSV lists one, it stays in all three. Add/Update cannot be used to unassign.

Replace

Adobe’s page carries a warning for Replace: existing product data is cleared and all references in the system are lost. The source code confirms how literal that is. In the catalog import model, _replaceProducts() deletes the existing product rows and then inserts the file’s rows as new products. Anything that pointed at the old product record no longer has a target.

Replace also errors when the file references a SKU that is not in the database, so it cannot be used to create products. Its legitimate use is narrow: rebuilding a known set of products from a complete file, on a catalog where you have checked what depends on those records. For day-to-day updates, do not use it.

Delete

Delete reads the sku column and ignores everything else. A file with one column is enough. A SKU that does not exist produces the error “Product with specified SKU not found”. Take a database backup first; there is no undo.

Validation strategy, allowed errors, and separators

Before anything is written, Check Data validates the file. Two settings control what happens when rows fail.

  • Validation Strategy has two options: Stop on Error and Skip error entries.
  • Allowed Errors Count defaults to 10. It is the number of errors after which the import is halted.

With Skip error entries, valid rows are imported and invalid ones are left out. That sounds helpful, but on a large file it produces a partially updated catalog and a list of row numbers to chase. For production updates, Stop on Error with a low error count is safer: fix the file and run it again clean. Skip is reasonable for a first exploratory load on staging, when you want to see every error in one pass.

Adobe also documents two rules that explain confusing results: a new product with an invalid required attribute and no default value blocks that row, and the whole file fails if every row is invalid.

Separators and the empty value constant

Setting Default What it controls
Field separator Comma Splits columns
Multiple value separator Comma Splits multiple values inside one cell, such as category paths
Empty attribute value constant __EMPTY__VALUE__ A cell containing this constant clears the attribute
Fields enclosure Off Whether values are wrapped in an enclosure character

Two points here cause a large share of broken imports.

First, the multiple value separator is a comma by default, not a pipe. The pipe has a different job: it separates multi-line entries inside complex columns such as configurable_variations and custom_options. If you export with one separator and import with another, category paths and multiselect values are split incorrectly.

Second, a blank cell does not clear a value. On import, blank cells are ignored, which is what makes partial files safe. To remove an attribute value deliberately, put the empty value constant in the cell. Check the exact spelling against the Import screen in your version before relying on it.

File size and encoding

The maximum upload size is governed by PHP settings on the server, and the Import page shows the current limit; Adobe’s documentation gives 2 MB as the default. Raise the PHP upload limits or split the file. Files should be UTF-8. Adobe’s documentation warns that a byte order mark can cause failures and that Excel can insert extra characters into the column header, so export from a spreadsheet tool carefully and check the first line in a plain text editor if the sku column is “missing”.

The CSV columns that matter

Only sku is required, and Adobe’s attribute reference limits it to 64 characters. A partial update file needs just sku plus the columns you are changing. Import cannot create new attributes; an attribute has to exist before a column can fill it. If your attribute model is getting out of hand, our guide to attribute set and EAV design for large catalogs is the place to start.

The columns that need care:

  • store_view_code: blank means the default scope. A row with a store view code writes store-level values for that product.
  • attribute_set_code and product_type: set at creation. Import will not change either on an existing product; the source has dedicated errors for both.
  • categories: full paths from the root, with a slash between levels, for example Default Category/Gear,Default Category/Gear/Bags. Paths are split by the multiple value separator.
  • product_websites: website codes separated by commas with no spaces, for example base,website2.
  • additional_attributes: code=value pairs separated by commas, for attributes that do not have their own column.
  • configurable_variations: one entry per child, with attribute pairs separated by commas and children separated by pipes, for example sku=shirt-red-xs,color=red,size=xs|sku=shirt-red-s,color=red,size=s. The child simple products must exist, so put them above the parent in the file or import them first.
  • custom_options, bundle_values, associated_skus: the same pairs-and-pipes pattern for customizable options, bundle selections, and grouped products.
  • url_key: generated from the name when blank.

Tier prices and inventory sources are not part of the product file. Tier pricing uses the separate Advanced Pricing entity, and Multi-Source Inventory quantities use the Stock Sources entity.

Leave out categories and url_key on large updates

Adobe’s import page has a specific warning for large catalogs: omit the categories and url_key columns unless you are changing them. When they are present, URL rewrites are regenerated for every row, and on big files that can time out. A price or stock-status update should carry sku and the changed columns only. We explain why that table is so expensive in Magento URL rewrites at scale.

Importing product images

Images use four columns: base_image, small_image, thumbnail_image, and additional_images, the last a comma-separated list, with additional_image_labels for alt text. There are two ways to supply the files, both covered in Adobe’s product image import guide.

Local files. Upload the images to var/import/images under the Magento root, or a subfolder of it, and put the file name or relative path in the CSV. Since 2.3.2, the Images File Directory field on the import form is appended to that base directory, and the base is used when the field is blank. This is the most common point of confusion, because older tutorials and even some examples in Adobe’s own attribute reference still show pub/media/import. On a current version, use var/import/images.

Remote URLs. Put the full URL in each image column and Magento downloads the file during import. This is slower and depends on the remote server answering every request. The source has a dedicated error for it: “Imported resource (image: %s) at row %s could not be downloaded from external resource due to timeout or access permissions”.

With the remote storage module enabled, the image directory is var/import/images under the remote storage root, not on the local disk. Our article on Magento remote storage on Amazon S3 covers that setup.

Adobe also states that importing product images does not trigger image resizing. Resized versions are generated on first request from the storefront, so the first visitor to each imported product pays for it unless you pre-generate the cache.

Indexing after an import

The import code handles indexers in one of two ways. If a related indexer is set to Update on Save, the import marks it invalid and it needs a reindex. If it is set to Update by Schedule, the import relies on the changelog tables, and cron picks up the changed products on its next run.

In practice that means a large import on a scheduled store is followed by a backlog. Products may be saved correctly and still not appear in search or category pages for some minutes. Check the indexer status and the cron queue before concluding that an import failed.

The import REST API and other routes

There is no bin/magento command for product import in core. For automation, the options are:

  • The import REST endpoints. Adobe documents POST /V1/import/csv and POST /V1/import/json. The CSV endpoint takes a base64-encoded file; the JSON endpoint takes an items array. Both accept the same choices as the admin form: entity, behavior, validationStrategy (validation-stop-on-errors or validation-skip-errors), allowedErrorCount, the separators, the empty value constant, and importImagesFileDir.
  • Scheduled Import/Export. Available only in Adobe Commerce. It reads files from the local server or a remote FTP location on a daily, weekly, or monthly schedule and sends failure emails.
  • Asynchronous bulk APIs. For system-to-system sync at volume, POST /async/bulk/V1/products queues one operation per product through the message queue. It is a different tool with different error handling; see async bulk APIs and RabbitMQ for catalog imports.

On tuning, the import module’s default configuration sets a bunch size of 100 rows. Adobe publishes no tuning guidance for it, so treat any change as something to measure on staging, not a known win.

Common row errors and how to fix them

These messages are taken from the message templates in the catalog import model. The causes and fixes are the ones we would check first.

Error message Usual cause Fix
“Url key: ‘%s’ was already generated for an item with the SKU: ‘%s’. You need to specify the unique URL key manually” Two products with the same name, so the same generated key Add a url_key column with unique values for the affected rows
“Value for ‘%s’ attribute contains incorrect value, see acceptable values on settings specified for Admin” A select or multiselect value that is not an existing option, often a case or spacing difference Create the option first, or correct the value to match the admin label exactly
“Invalid value for Attribute Set column (set doesn’t exist?)” attribute_set_code does not match an existing set name Use the exact set name; create the set before importing
“Please make sure attribute “%s” is not empty.” A required attribute is blank on a new product Fill the column or give the attribute a default value
“Product with specified SKU not found” Delete or Replace run against a SKU that does not exist Remove the row, or use Add/Update
“Imported resource (image) does not exist in the local media storage” File is not in var/import/images, or the path or case differs Check the directory, the Images File Directory field, and exact file names
“Wrong URL/path used for attribute %s” Malformed image path or unencoded URL Use a relative path without stray characters, or a fully encoded URL
“SKU contains marginal whitespaces” Leading or trailing spaces in the sku cell Trim the column in the source file
“Product type change is not allowed” / “Attribute set change is not allowed” File tries to change type or set on an existing SKU Remove those columns from update files

Two habits prevent most of these. Export a few existing products of the same type first and use that file as your template, so column names and value formats are correct. And run Check Data on staging against a copy of production data, because validation depends on what already exists in the database.

Importing data from another platform

A CSV exported from another system is never import-ready. Column names, category structures, option values, and variant models differ. A catalog coming from Shopify, Shopware, or BigCommerce needs a mapping step that builds attributes and attribute sets first, then simple products, then configurable parents, then images. Rehearse the full sequence on staging at least once with the real file.

For catalogs that change daily, a PIM or ERP integration is usually a better source of truth than hand-edited spreadsheets. Bemeir handles catalog migrations and integrations as part of our Magento development services and Hyva development services. You can read about Bemeir or see the PIM, ERP, and feed providers among our technology partners.

FAQ

What is the difference between Add/Update and Replace in Magento 2 import?

Add/Update creates new SKUs and updates the columns you supply on existing ones, leaving everything else alone. Replace clears the existing product data and re-creates the product from the file, and Adobe warns that all references to the old product are lost. Replace also fails for SKUs that do not exist yet.

Where do I put images for a Magento 2 product import?

On Magento 2.3.2 and later, upload them to var/import/images under the Magento root, or a subfolder named in the Images File Directory field. Older guides that say pub/media/import are out of date. With remote storage enabled, the same path sits under the remote storage root. You can also use full image URLs in the CSV.

How do I clear an attribute value with a CSV import?

A blank cell is ignored, so it will not clear anything. Put the empty attribute value constant shown on the Import form in the cell. The source code default is EMPTY__VALUE. Removing a product from a category or website is different: Add/Update does not unassign multi-value fields that are missing from the file.

Why are my imported products not showing on the storefront?

If validation passed and the import completed, check indexers and cron. With indexers on Update by Schedule, imported changes wait for the next cron run. Also confirm the product is enabled, assigned to the right website in product_websites, in stock, and visible in catalog and search.

Can I run a Magento 2 product import from the command line?

Core does not include a bin/magento import command. To automate imports, use the REST endpoints POST /V1/import/csv or POST /V1/import/json, Scheduled Import/Export on Adobe Commerce, or the asynchronous bulk product API for ongoing integrations.

Let us help you get started on a project with Magento 2 Product CSV Import: Import Behaviors, Validation Strategy, Image Import, and Fixing Common Row Errors and leverage our partnership to your fullest advantage. Fill out the contact form below to get started.

more articles about ecommerce

Read on the latest with Shopify, Magento, eCommerce topics and more.