Skip to content

Deleted the Product image, but still the image exists in the product grid in magento 2

I have deleted the product image using following code

 $imageProcessor = $_objectManager->create('MagentoCatalogModelProductGalleryProcessor');
                $images = $product->getMediaGalleryImages();
                $productGallery = $_objectManager->create('MagentoCatalogModelResourceModelProductGallery');
                foreach($images as $child) {
                    $objectManager = MagentoFrameworkAppObjectManager::getInstance();
                    $productGallery = $objectManager->create('MagentoCatalogModelResourceModelProductGallery');
                    $productGallery->deleteGallery($child['value_id']);
                    $product->setMediaGalleryEntries([]);
                    $imageProcessor->removeImage($product, $child['file']);
                    $product->save();
                }

Image successfully deleted.

enter image description here

But due to the thumbnail image existence, it is still shown in the product grid

enter image description here

Please help how get this thumbnail image and delete

I have tried follwoing way to get thumbnail image, but no luck.

 $productData = $this->productFactory->create();
                $product = $productData->load(1884);
                print_r($product->getThumbnail());