Magento 2 – Got Problems While Importing Products?

Magento 2 – Got Problems While Importing Products?

Magento 2 has come to our life for a period and brings a lot of benefits about enhanced performance and scalability as well as rich user performance compared to Magento 1. However, because this version has been improving and upgrading, Magento 2 also contains some drawbacks that cause us troubles in the setting up process, especially in the importing product process. There are some possible errors such as images do not exist, products are not displayed in the frontend after the import or products are not shown in the backend (Magento admin) after the import. Notably, a trendy one is that we cannot import a more significant number of products in Magento 2. So, what is the reason for this issue and how to overcome it? In this tutorial post, we will introduce the way to fix this problem in Magento 2.

In Magento 1, it is a truth that we have not faced with the number of products imported, but in Magento 2, you can import a limited quantity of products. Why does it happen? With our experience working with Magento 2, we found that the URL key is the most primary reason causing this drawback. Your URL keys do not include enough data, and in case you let them empty field, the function we are checking is the same URL keys because all URL keys are blank. Therefore, to solve this issue, we have to give each product different URL keys

To do this, we have to carry out the following steps:

Step 1: Prepare an import file for Magento 2

First and foremost, we need to prepare an import file for Magento 2 which has the following format: m2-import.csv

alt="magento2-import-csv-file"

– Input needed information into the mandatory fields in CSV file

– Make sure that SKUs are not repeating

– Check the correct path format for image folder

Step 2: To import a large number of products at the same time, we need to input more data for the URL key field as follows:

To have the URL key format the same as Magento, we need to write a script for products’ name

Here is one example: 

You upload file m2-import.csv to root Magento folder and create urlkey.php file then paste the following script: 

<?php
$urlArray = array();
if (($handle = fopen("m2-import.csv", "r")) !== FALSE) {
while (($data = fgetcsv($handle, 10000, ",")) !== FALSE) {    
$clean = preg_replace("/[^a-zA-Z0-9\/_|+ -]/", '', $data[8]); // 8 is the position of 
the "name" column
$clean = strtolower(trim($clean, '-'));
$clean = preg_replace("/[\/_|+ -]+/", '-', $clean);
$i = 0;
if(in_array($clean, $urlArray)){
$clean = $clean . '-1';
$urlArray[] = $clean;
}else{
$urlArray[] = $clean;
}
} 
fclose($handle);
}
foreach ($urlEnd2 as $value) {
echo  $value . '<br />';
}
print_r(array_count_values($urlEnd2));
?>

Step 3: Run URL: HTTP://[YOUR DOMAIN NAME]/urlkey.php for printing results to screen

(Eg: http://bsscommerce.com/urlkey.php) 

After that, we copy the whole printed data to URL key. When all needed information is input to CSV file, we can import as usual follow this path:  Admin->System->Import

alt="magento2-admin-import"

Remember after importing, let’s reindex data and upgrade database again for your website:

  • Reindex: php bin/Magento indexer:reindex
  • Upgrade: php bin/Magento setup:upgrade

Now enjoy your successful results!

If you find our tutorial useful, please  Like and Subscribe to our blog to get the latest knowledge for applying to your Magento site.

In case you have any further questions, please Contact us to receive the best support. Our support team who is specified in Web Development and Magento extensions will always be ready to help you every time via Skype, Livechat, and Email Support.

Write A Comment

Name