Rick
Rick

Reputation: 485

Magento 2: Product import does not create sub categories

I'm importing products from a CSV-file. The categories-column of the import file has a value like this:

Store Amsterdam/Lunchbox;Store Amsterdam/Lunchbox/Hot Sandwiches

I've set ";" as a Multiple value separator in the Magento 2 import settings.

Somehow Magento only adds the Store Amsterdam (root) categorie and imports 0 products (Probably because it doesn't reach the destination category).

When I create the sub categories by hand all products import correctly. But I don't want to do this for every 34 remaining stores.

In the report it says: Category "Store Amsterdam/Lunchbox" has not been created. URL key for specified store already exists.

What is going wrong here? Maybe writing permissions on category table? Different Magento user?

Upvotes: 10

Views: 1344

Answers (2)

Varma
Varma

Reputation: 95

You have to use "," instead of ":" to separate values, Can i know what version you were using right now?

ex:Store Amsterdam/Lunchbox, Store Amsterdam/Lunchbox/Hot Sandwiches

Upvotes: 0

Pallavi
Pallavi

Reputation: 347

Try to set url key in your import code this way

$_product = $this->_objectManager->create('Magento\Catalog\Model\Product');

$url = <yourcatname>.'_'.$sku;// just to make it unique
$url = strtolower($url);
$_product->setUrlKey($url); 

//now save your product
$_product->save();

This should resolve your issue! Happy customizing!

Upvotes: 1

Related Questions