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:
- Make the next changes in the Magento Import Settings tab:
- Entity Type - Products;
- Import Behavior - Add/Update:
Field separators can vary, you can find which one to use in your case in the Imported file:
- 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:
- Check you know these rules before filling in the Magento 2 import configurable products sample CSV file:
- list children products before configurable ones;
- prove the value in the ‘attribute_set_code’ column matches the name of the Attribute Set;
- enumerate all the attribute set values for each child product in the ‘additional_attributes’ column;
- fill in the set of SKU and Option in the ‘configuable_variations’ column;
- 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:
- You will get a validation result in case everything is correct:
- Click the Import button and get one more validation notification:
- 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 product 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.
Login and Registration Form