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?
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!
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With