I tried to update all product information by product id but it’s not working for me for all information. With below code “SKU” update successfully but unable to update other information like product name and other custom attribute value.
How can I update all the information about the products using PHP script?
$productFactory = $objectManager->get('MagentoCatalogModelProductFactory');
$product = $productFactory->create()->setStoreId($storeId)->load($product_id);
$product->setStatus(1);
$product->setName('test pr 123');
$product->setSku('test sku');
$product->setDescription("new product description.");
$product->setShortDescription("new short description.");
$product->save();
2
Answers
Here I’m adding a script hope this will help and solve your problem
Add your attribute which you need to update in code
If you just want to override some attribute values, you should use the addAttributeUpdate function. With that you can also update attribute values for different store views.
I use a kind of this code to update my products descriptions etc. for several stores.