I am creating a product programmatically, trying to set the visibility with below code
$objectManager = \Magento\Framework\App\ObjectManager::getInstance(); $product = $objectManager->create('\Magento\Catalog\Model\Product'); $product->setVisibility(4); $product->save();
The above code works perfectly, but it is not working when I use like below.
The product is saving, but visibility is not set when used like above. Can anyone suggest me how to update the visibility? I am reading it from the csv file and updating.