Magento 2 Import Configurable Products

To simply create and import configurable products without time loss follow the three clear steps.

Magento 2 import configurable products in CSV:

Step 1: Find a CSV file

¡In case you have already downloaded the sample file, skip the step! 

  • Log in to your Admin Panel and navigate to System>Import:

admin-system-import-magento

  • Make the next changes in the Magento Import Settings tab: 
  1. Entity Type - Products;
  2. Import Behavior - Add/Update:

settings-import-magento

Field separators can vary, you can find which one to use in your case in the Imported file:

separator-import-file-magento

  • Click the Download Sample File option and save the CSV file on your computer.

Step 2: Fulfill the CSV file

  • Once downloaded, open the file:

csv-file-magento-2

  • Check you know these rules before filling in the Magento 2 import configurable products sample CSV file:
  1. list children products before configurable ones;
  2. prove the value in the ‘attribute_set_code’ column matches the name of the Attribute Set;
  3. enumerate all the attribute set values for each child product in the ‘additional_attributes’ column;
  4. fill in the set of SKU and Option in the ‘configuable_variations’ column;
  5. check the correlation between the Attribute Code and the Label name in the ‘configurable_variation_labels’ column.

Step 3: Import CSV file

  • Get back to the Admin Panel>System>Import>Import Settings. In the Select File to Import field click the Choose File option, select your CSV file and click the Check Data button:

import-csv-file-magento

  • You will get a validation result in case everything is correct:

import-validation-results-magento

  • Click the Import button and get one more validation notification:

validation-import-magento

  • Go to the frontend to make sure everything works the way you needed.

Tip: If you need to quickly export configurable products from Magento 2 to a shopping engine, consider this Data Feed Manager.

How to export Magento configurable products together with associated?

Magento can export configurable products with associated simple products by using the Data Transfer Tool. For this, go to System > Data Transfer > Export. Set the Entity Type to Products and the Export File Format to CSV. In the Entity Attributes field, enter the SKU of the product you want to export and click Continue. The download will start automatically.

If you are interested in complex Import\Export solution, please, check our Import and Export extension.


How can I import a custom CSV file programmatically in Magento 2?

To import a custom CSV file programmatically in Magento 2, you can use the following code snippet:

$import = \Magento\Framework\App\ObjectManager::getInstance()->create('Magento\ImportExport\Model\Import');
$import->setData([
'entity' => 'catalog_product',
'behavior' => 'append',
'validation_strategy' => 'validation-stop-on-errors',
'allowed_error_count' => '10',
'file_path' => 'path/to/custom_csv_file.csv',
'import_images_file_dir' => 'path/to/import_images/',
'images_file_mode' => 'move',
'import_images' => 'true',
'field_separator' => ',',
'multiple_value_separator' => ',',
'store_id' => '0',
'website_id' => '0'
]);
$result = $import->importSource();

In this code, we first create an instance of the Magento\ImportExport\Model\Import class using the Object Manager. We then set the import data such as the entity type, behavior, validation strategy, file path, field separator, and other options. Finally, we call the importSource method to perform the import and store the result in the $result variable.

You can customize this code to fit your specific requirements, such as setting different import options or importing different entity types.

How can we help you?

Didn’t you find the answer to your question? We are always happy to help you out.

© 2009-2024 Amasty. All Rights Reserved.