I'm trying to programatically set the "Hide from Product Page" setting on an image.
The setting can be found here: Products > Catalog > (select a product) > Images And Videos > (click on an image).
So far, the only way I've been able to change that setting, is by doing it manually.
Here's how I currently add images to my products:
$product->addImageToMediaGallery($imagePath, ['thumbnail'], false, true);
$product->save();
I thought that the last parameter which is called exclude
and described as mark image as excluded from product page view
would do the trick, but it doesn't. Regardless of if I set the value to true
or false
, the image remains visible on the product page and the checkbox is unchecked.
I've been banging my head against a wall for the better part of a day now, so any suggestions will be greatly appreciated.
Best Answer
You can simply change product image visibility using a database.
If you want disabled all product images so run the below query in the database.
If you want to enable all product images so run the below query in the database.
Thanks