Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mokanfar/d2e8145aa30770832e580d89ff96f848 to your computer and use it in GitHub Desktop.
Save mokanfar/d2e8145aa30770832e580d89ff96f848 to your computer and use it in GitHub Desktop.
get all images associated with an array of product sku's programatically in Magento [first one is base/main image]
<?php
ini_set('display_errors','on');
require_once 'app/Mage.php';
Mage::app();
$skus = array(LIST_OF_SKUS_HERE);
foreach($skus as $item) {
$product_id = Mage::getModel('catalog/product')->loadByAttribute('sku', $item)->getId();
$product = Mage::getModel('catalog/product')->load($product_id);
$baseImageUrl = Mage::getModel('catalog/product_media_config')->getMediaUrl($product->getImage());
echo "wget --directory-prefix=\"" . $item . "\" " . $baseImageUrl . "<br>";
}
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment