We have imported simple products into magento 2 without url_key earlier. front-end also working fine.
But we would like to generate url_keys for those products.
While saving product from magento admin end the url_key has been generating and associating to the product. but we have around 1000 products.
Tried with programmatically to save the product but not getting expected result.
<?php use Magento\Framework\App\Bootstrap; require __DIR__ . '/app/bootstrap.php'; $bootstrap = Bootstrap::create(BP, $_SERVER); $objectManager = $bootstrap->getObjectManager(); $state = $objectManager->get('Magento\Framework\App\State'); $state->setAreaCode('frontend'); $product_id = 1036; $product = $objectManager->get('Magento\Catalog\Model\Product')->load($product_id); $product->save(); echo "Product Saved Successfully ====>".$product_id;
How do we overcome this issue.? Please advise.