StackExchange teems with interesting and useful tips related to Magento 2. This time, we’ve dug up a discussion where the author named Jackson complains about store ID-related issues that occur in Magento 2. Let’s take a look at the problem and provide several possible solutions. Jackson points to a particular script used to import data from a CSV file. However, the use of ->setStoreId(0) causes an issue – two values for the same field in the database table occur. As a result, it is necessary to delete second values to enable changes on the frontend but it often leads to the incorrect display. How to address the problem? You will find out how to fix store ID-related issues on Magento 2 import as it is portrayed in the discussion. At the same time, we provide a reliable alternative based on the Improved Import & Export. Also, you will discover other improvements associated with the module.
‘
Table of contents
The Issue
Jackson points to the script mentioned in this discussion. He imports data from a CSV file with its help. However, when the author uses ->setStoreId(0), two values for the same field in the database table occur – Store Id 0 & Store Id 1.
Therefore, you always need to delete Store Id 1 corresponding values from the corresponding database table to enable changes on the frontend. However, the data is not displayed correctly. Jackson argues that he has to delete queries for the corresponding store ID in 5-6 tables.
As for the default Magento 2 import/export solution, it relies on Store Id 0 as expected, so everything works properly.
The Solution
Sébastien Trottier offers the following way to address the problem:
$objectManager->get(‘MagentoStoreModelStoreManagerInterface’)->setCurrentStore(‘admin’); |
He insists on the necessity to use store id 0 (‘admin’) only for products before importing them.
module–catalogModelProductRepository.php:save() |
From the above snippet, Sébastien concludes that the store id is retrieved from the current store on save, but not the one specifies via Product::setStoreId():
$productDataArray[‘store_id’] = (int)$this->storeManager->getStore()->getId(); |
That’s the root of all evil.
Reliable Alternative
You can import and export products and all other entities between Magento 2 and any systems with the help of Improved Import & Export. The extension dramatically enhanced the default capabilities of the platform and delivers numerous features that are not available in other third-party data transfer tools.
Of course, it has no store ID-related issues. You seamlessly transfer data to your e-commerce store if it complies with the existing requirements. If not, you can modify it within just a few clicks due to the extensive functionality of the Improved Import & Export module. Thus, you prevent possible issues before they occur.
Besides, our tool lets you automate data transfers in several ways. Firstly, you can rely on cron-based schedules: either predefined or custom. Secondly, there is a system of triggers for real-time transfers.
If you face attribute-related issues, the Improved Import & Export extension is under your disposal too. The module lets you match third-party designations to ones used in Magento 2. You can do that automatically; applying presets – preconfigured matching schemes aimed at particular integrations. Alternatively, it is possible to do that by your own hands right in your Magento 2 admin. The same functionality covers not only attributes but also their values and several other aspects of import processes.
Of course, the Improved Import & Export module lets you transfer not only CSV but also XML, Excel, JSON, and ODS files. It knows how to unpack ZIP and TAR archives. You can rely on numerous file sources to move data. For example, our extension supports local and remote servers, cloud storage options, Google Sheets, etc. As for complex integrations, they can be based on APIs. For more information, follow this link:
Get Improved Import & Export Magento 2 Extension
Improved Import & Export FAQ
Let’s take a look at other nuances of importing and exporting data with the help of the Improved Import & Export Magento 2 extension.
How to import and export data to Magento 2 automatically?
You can import data to Magento 2 automatically on a regular basis if you use the Improved Import & Export extension. While the default import and export tools don’t support automation, unless you use Adobe Commerce, our extension utilizes a cron scheduler to automate data transfers. As a store admin, you get the ability to import and export tables between Magento 2 and external destinations automatically after specifying a schedule of updates.
How to import files with third-party attributes to Magento 2?
While Magento 2 prevents importing data files that don’t follow its requirements, you can successfully finish such transfers. If a table contains third-party attributes, you no longer need to edit it manually. The Improved Import & Export extension lets you create a mapping scheme where you match third-party attributes and values to ones used within Magento 2. As a result, any external data is easily adapted to the default Magento 2 standards. When it comes to export processes, you can also apply mapping to them, generating the output your partners require.
How to import and export data to Magento 2 via API?
The Improved Import & Export Magento 2 module provides the ability to connect your Magento 2 store with any external platform via API. It is possible to synchronize any data. You configure API connections straight in the module’s import/export jobs.
How to import and export data to Magento 2 via ODS files?
While Magento 2 works with CSV files only, the Improved Import & Export module supports a bunch of other standards. As a result, you can use ODS files to import and export data.
How to import and export data to Magento 2 via XLSX files?
While Magento 2 works with CSV files only, the Improved Import & Export module supports a bunch of other standards. As a result, you can use XLSX files to import and export data.
How to import and export data to Magento 2 via JSON files?
While Magento 2 works with CSV files only, the Improved Import & Export module supports a bunch of other standards. As a result, you can use JSON files to import and export data.
How to import data to Magento 2 via compressed files?
If your data files are compressed, use the Improved Import & Export module to transfer them to Magento 2. The extension supports ZIP and TAR archives that contain CSV, XML, ODS, JSON, or XLSX files.
How to import data to Magento 2 from Google Sheets?
No files are necessary if data is stored in Google Sheets. The Improved Import & Export extension lets you import the update right from a remote table stored on the popular website. It is only necessary to specify the address of the corresponding Google Sheets table to run the import process. Furthermore, you can use Google Sheets to export data from your e-commerce website.
How to import and export data between Magento 2 and Dropbox?
The Improved Import & Export extension enables data transfers between Magento 2 and Dropbox via CSV, JSON, XML, ODS, or XLSX files or ZIP and TAR archives.
How to import and export data between Magento 2 and Google Drive?
In addition to Google Sheets and Dropbox, the Improved Import & Export extension lets you import and export data between Magento 2 and Google Drive. Use CSV, JSON, XML, ODS, or XLSX files. You can compress them as ZIP or TAR archives.
‘