I'm Using this below Script, but on executing my page lands to Error 503
.
Can anyone, please help me in re-saving all the product programmatically
<?php
use Magento\Framework\App\Bootstrap;
include 'app/bootstrap.php';
$bootstrap = Bootstrap::create(BP, $_SERVER);
$objectManager = $bootstrap->getObjectManager();
$state = $objectManager->get('Magento\Framework\App\State');
$state->setAreaCode('adminhtml');
$productCollectionFactory = $objectManager->get('\Magento\Catalog\Model\ResourceModel\Product\CollectionFactory');
$productcollection = $productCollectionFactory->create()
->addAttributeToSelect('*')
->load();
foreach ($productcollection as $product) {
$productId = $product->getId();
$product = $objectManager->create('Magento\Catalog\Model\Product');
$product->load($productId);
$product->save();
}
?>
Thank you.