Last active
August 24, 2018 17:58
-
-
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]
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
require_once 'app/Mage.php'; | |
Mage::app(); | |
$skus = array("LIST OF SKUS HERE"); | |
foreach($skus as $item) { | |
$product = Mage::getModel('catalog/product')->loadByAttribute('sku', $item)->getId(); | |
$gallery_images = Mage::getModel('catalog/product')->load($product)->getMediaGalleryImages(); | |
foreach($gallery_images as $g_image) { | |
echo $g_image['url'] . ';'; | |
} | |
echo "<br>"; | |
} | |
?> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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