I'm trying to update product details by this code -
public function updateProducts(){
$objectManager = \Magento\Framework\App\ObjectManager::getInstance(); // instance of object manager
$product = $objectManager->create('\Magento\Catalog\Model\Product');
$product->load(3734);
$product->setStoreId(1);
$product->setSku('sku'); // Set your sku here
$product->setName('name'); // Name of Product
$product->setStatus(1); // Status on product enabled/ disabled 1/0
$product->setWeight(10); // weight of product
$product->setVisibility(4);
$product->setPrice(100); // price of product
$product->setCustomAttribute('case_back','Black');
$product->setCustomAttribute('case_material','Silver');
$product->save();
}
Some of the values are updated like Sku and Price but Name and others are not. I tried to update custom attributes also but it results same. For example - case_back updated but case_material not.
I found out that fields with Global scope are updating but Store View scope are not even though I set storeId also.
So how can I update all of the details of product?
$_product->setCustomAttribute("code", 'value');
to update the custom attributes. – Bhaumik Upadhyay Jul 25 '20 at 12:54