How to import products to Magento 2 and set their status to Out of Stock automatically
Chances are, you import products to Magento 2 but their status doesn’t change to ‘out of stock’ if the imported quantity is 0. It may look confusing or cause issues in other processes that require this information. However, there is a way to address this issue without editing your data files or applying stock status changes manually. Below, we explain how to import products with 0 quantity to Magento 2 and set their status to ‘Out of Stock’ automatically. You will need the Improved Import & Export Magento 2 extension and a couple of minutes.
‘is_in_stock’ attribute
Initially, you had to add the ‘is_in_stock’ attribute to your product import file to inform Magento about the product status update:
- ‘is_in_stock=1’ updated product status to ‘In Stock’
- ‘is_in_stock=0’ to o updated product status to ‘Out of Stock’
It was the only way to update your products correctly if you didn’t know whether the backorder settings were enabled, allowing products to go out of stock when their quantity reaches zero. Not to mention the overall stock management functionality and its impact on your catalog.
‘Set products with qty=0 as out of stock’ feature
Now, you neither need to manually edit your data file by adding the ‘is_in_stock’ attribute nor enable the backorder settings. The Improved Import & Export extension lets you change the ‘is_in_stock’ attribute value to ‘Out of Stock’ automatically when updating the product quantity to 0. You only need to enable the ‘Set products with qty=0 as out of stock’ feature.
How to import products to Magento 2 and set their status to Out of Stock automatically
Follow these steps to import products with qty=0 to Magento 2 and set their status to ‘Out of Stock’ automatically:
- Open the Improved Import & Export extension;
- Open a new import job;
- Select ‘Products’ as your import entity;
- The ‘Set products with qty=0 as out of stock’ feature displays. Enable it.
- Configure other job settings.
- Save and run your product import job.
For instance, you have a product with qty=100 and the ‘In Stock’ status.
If you update this product using a file that contains two attributes the product’s SKU and qty=0, don’t forget to turn on the ‘Set products with qty=0 as out of stock’ feature. You will set the product quantity to 0 and set its stock status to ‘Out of Stock’ automatically. There is no need to use the ‘is_in_stock’ attribute or update the product status manually after the import procedure is completed.
Note that if the ‘Set products with qty=0 as out of stock’ feature is disabled, you will only set the new product quantity – 0. Its stock status won’t switch to ‘Out of Stock’.
In addition to automated stock status updates, the Improved Import & Export extension offers dozens of outstanding features that can dramatically improve your data transfer routine. The module supports a bunch of file formats, such as CSV, XML, JSON, XLSX, etc. It means that you no longer need to files to CSV to import them. And it is possible to use multiple file sources, such as Dropbox or Google Drive.
Furthermore, you can create cron-based schedules to import and export your data automatically. And if you deal with third-party attributes that are not supported in Magento 2, the Improved Import & Export extension provides the ability to use mapping. You no longer need to edit data files manually, because it is possible to match unsupported column names to the ones used in Magento.
Last but not least, our module lets you transfer data from Google Sheets or run API-based import and export processes in addition to traditional data transfers. Follow this link to learn more:
Get Improved Import & Export Magento 2 Extension
Also, check our Magento 2 Cookbook for more useful tips.