I have noticed in my backend that some products have broken image links. Thus, placeholder gets used on frontend.
I would like to get a list of products that has the placeholder as it's image on the frontend. I have written the following, but it is not working correctly:
<?php
error_reporting(E_ALL);
ini_set('display_errors', '1');
require_once('app/Mage.php');
Mage::app();
error_reporting(1);
set_time_limit(0);
ini_set('memory_limit', '2048M');
$_products = Mage::getModel('catalog/product')
->getCollection()
->addAttributeToSelect('*')
->addAttributeToFilter('visibility', 4)
->addAttributeToFilter('status', 1);
foreach($_products as $_product){
if($_product->getImageUrl()){
echo($_product->getImageUrl(). $_product->getSku()."</br>");
}
}?>
Update of new code I have tried:
<?php
error_reporting(E_ALL);
ini_set('display_errors', '1');
require_once('app/Mage.php');
Mage::app();
error_reporting(1);
set_time_limit(0);
ini_set('memory_limit', '2048M');
$_products = Mage::getModel('catalog/product')
->getCollection()
->addAttributeToSelect('*')
->addAttributeToFilter('visibility', 4)
->addAttributeToFilter('status', 1);
foreach($_products as $_product){
if (!file_exists(Mage::getModel('catalog/product_media_config') ->getMediaUrl( $_product->getImage()))) {
echo $_product->getSku(). "<br/>";
}
//echo(Mage::getModel('catalog/product_media_config') ->getMediaUrl( $_product->getImage())."</br>");
}?>
Still not doing what I need