<?php
require_once '../app/Mage.php';
set_time_limit(1);
ini_set('memory_limit','1024M');
ini_set('max_execution_time', 3000);
Mage::app();
Mage::app()->getStore()->setId(Mage_Core_Model_App::ADMIN_STORE_ID);
// Get Product SKU using csv file
$file_handle = fopen("skus.csv", "r");
$c = 1;
while (!feof($file_handle) ) {
$line_of_text = fgetcsv($file_handle, 10000);
$productSKU = $line_of_text[0];
if($line_of_text[0]!="")
{
$sku = substr($productSKU,0,-1);
$id = Mage::getModel('catalog/product')->getIdBySku($sku);
if (false !== $id) {
//sku exists
$model = Mage::getModel('catalog/product')->loadByAttribute('sku',$sku);
$productMediaConfig = Mage::getModel('catalog/product_media_config');
if($model->getImageUrl())
{
$baseImageUrl = $productMediaConfig->getMediaUrl($model->getImage());
$smallImageUrl = $productMediaConfig->getMediaUrl($model->getSmallImage());
$thumbnailUrl = $productMediaConfig->getMediaUrl($model->getThumbnail());
$basefileName = explode("/",$model->getImage());
$smallfileName = explode("/",$model->getSmallImage());
$thumbfileName = explode("/",$model->getThumbnail());
echo $c.")baseImageUrl ".$sku."==>".$baseImageUrl;
echo "<br>";
echo $c.")smallImageUrl ".$sku."==>".$smallImageUrl;
echo "<br>";
echo $c.")thumbnailUrl ".$sku."==>".$thumbnailUrl;
$gallery_images = Mage::getModel('catalog/product')->load($model->getId())->getMediaGalleryImages();
$items = array();
foreach($gallery_images as $g_image) {
$items[] = $g_image['url'];
}
echo "<pre>";
print_r($items);
echo "</pre>";
echo "<br>";
echo "<br>";echo "<br>";*/
}
echo "<br>";
$c++;
}
else {
//sku does not exist
echo $productSKU."==>sku does not exist";
echo "<br>";
}
}
}
fclose($file_handle);
?>
Please check image for CSV format.
require_once '../app/Mage.php';
set_time_limit(1);
ini_set('memory_limit','1024M');
ini_set('max_execution_time', 3000);
Mage::app();
Mage::app()->getStore()->setId(Mage_Core_Model_App::ADMIN_STORE_ID);
// Get Product SKU using csv file
$file_handle = fopen("skus.csv", "r");
$c = 1;
while (!feof($file_handle) ) {
$line_of_text = fgetcsv($file_handle, 10000);
$productSKU = $line_of_text[0];
if($line_of_text[0]!="")
{
$sku = substr($productSKU,0,-1);
$id = Mage::getModel('catalog/product')->getIdBySku($sku);
if (false !== $id) {
//sku exists
$model = Mage::getModel('catalog/product')->loadByAttribute('sku',$sku);
$productMediaConfig = Mage::getModel('catalog/product_media_config');
if($model->getImageUrl())
{
$baseImageUrl = $productMediaConfig->getMediaUrl($model->getImage());
$smallImageUrl = $productMediaConfig->getMediaUrl($model->getSmallImage());
$thumbnailUrl = $productMediaConfig->getMediaUrl($model->getThumbnail());
$basefileName = explode("/",$model->getImage());
$smallfileName = explode("/",$model->getSmallImage());
$thumbfileName = explode("/",$model->getThumbnail());
echo $c.")baseImageUrl ".$sku."==>".$baseImageUrl;
echo "<br>";
echo $c.")smallImageUrl ".$sku."==>".$smallImageUrl;
echo "<br>";
echo $c.")thumbnailUrl ".$sku."==>".$thumbnailUrl;
$gallery_images = Mage::getModel('catalog/product')->load($model->getId())->getMediaGalleryImages();
$items = array();
foreach($gallery_images as $g_image) {
$items[] = $g_image['url'];
}
echo "<pre>";
print_r($items);
echo "</pre>";
echo "<br>";
echo "<br>";echo "<br>";*/
}
echo "<br>";
$c++;
}
else {
//sku does not exist
echo $productSKU."==>sku does not exist";
echo "<br>";
}
}
}
fclose($file_handle);
?>
Please check image for CSV format.
No comments:
Post a Comment