Created
June 30, 2017 12:20
-
-
Save graphicmist/cbd8b9f8b87d85377651ddb686ad6e68 to your computer and use it in GitHub Desktop.
Script to export Images from Magento1x
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 '/var/www/html/app/Mage.php'; | |
Mage::app(); | |
$outputDir = "/home/sslol/images"; | |
$products = Mage::getModel('catalog/product')->getCollection()->addAttributeToSelect('sku'); | |
foreach ($products as $product) { | |
$id = $product->getData('entity_id'); | |
$sku = $product->getData('sku'); | |
$images = Mage::getModel('catalog/product')->load($id)->getMediaGalleryImages(); | |
if(count($images)) { | |
echo "Processing SKU-".$sku."\n"; | |
$outputPath = $outputDir.'/'.$sku; | |
mkdir($outputPath,0777,true); | |
foreach($images as $image) { | |
$source = $image['path']; | |
$relativeFilePathArray = explode("/",$image['file']); | |
$filename = $relativeFilePathArray[count($relativeFilePathArray) - 1]; | |
$destination = $outputPath."/".$filename; | |
copy($source, $destination); | |
} | |
} | |
else { | |
echo "Skipping SKU-".$sku."\n"; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment