2
  • I'm creating products using scripts.
  • Product data came from json file.
  • Problem is I'm getting error URL key for specified store already exists. ,when second product has same name but different sku.
  • So, second product url should be url-1.html if url.html is exist.

Is it a Magento bug? How can I solve that?

foreach ($files as $etiq) {
  $_product = $objectManager->create('Magento\Catalog\Model\Product');
  $_product->setName($name);
  $_product->setSku($Sku);
  $_product->setTypeId('simple');
  .
  .
  .
  .
  $_product->save();
}

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.