Skip to content

Instantly share code, notes, and snippets.

@vishy93
Created February 6, 2019 13:40
Show Gist options
  • Save vishy93/655bb5c19c76d28ec2e11276d804d1c9 to your computer and use it in GitHub Desktop.
Save vishy93/655bb5c19c76d28ec2e11276d804d1c9 to your computer and use it in GitHub Desktop.
Quick script to see which products has no images/ placeholders
<?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');
/*
VISIBILITY_NOT_VISIBLE = 1;
VISIBILITY_IN_CATALOG = 2;
VISIBILITY_IN_SEARCH = 3;
VISIBILITY_BOTH = 4;
*/
$_products = Mage::getModel('catalog/product')
->getCollection()
->addAttributeToSelect('*')
->addAttributeToFilter('visibility', 4)
->addAttributeToFilter('status', 1);
/*This for each tells you all the products in collection using placeholder as the image*/
/*
foreach($_products as $_product){
if(strpos($_product->getImageUrl(), '/placeholder/')){
echo(Mage::getModel('catalog/product_media_config') ->getMediaUrl( $_product->getImage())." ===> " .$_product->getSku()."</br>");
}
//echo(Mage::getModel('catalog/product_media_config') ->getMediaUrl( $_product->getImage())."</br>");
}
*/
/*This for each tells you all the products in collection missing any images whatsoever*/
foreach($_products as $_product){
$allImages = Mage::getModel('catalog/product')->load($_product->getId())->getMediaGalleryImages();
foreach($allImages as $_image){
if (!file_exists($_image->getPath())) {
echo "Product ".$_product->getSku()."<br>";
echo "Missing Images <br>";
echo $_image->getPath()."<br>";
}
}
}
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment