Hi there I use this script to get product list to csv file but the product image path does not come right. It gives the url but not the actual image path.
It exports like this http://dev.com/media/catalog/product
the problem is $product['image']
is empty
Can you please help me about this? Thanks.
magento versiong is 8.1.0
while($pages>=$count){
// -- if this is the start, put the header in.
if($count == 0){
Mage::getModel('core/session')->setUsedPids(array());
$txt .= "Product ID,Product Name,Product Price,Product URL,Product Description,Product Image URL,Product Category\n";
}
echo 'Pages: '.$pages.' Count: '.$count.' Start: '.$start.' Limit: '.$limit.'<Br />';
$products = $this->getProductsData($limit, $start);
foreach($products as $product){
if(!in_array($product['entity_id'], Mage::getModel('core/session')->getUsedPids())){
$txt .= '"'.str_replace('"', '', $product['entity_id']).'","'.
str_replace('"', '', $product['name']).'","'.
str_replace('"', '', $product['final_price']).'","'.
str_replace('"', '', Mage::getBaseUrl().$product['url_path']).'","'.
str_replace(array('"', "\n", "\r"), '', $product['description']).'","'.
str_replace('"', '', Mage::getBaseUrl(Mage_Core_Model_Store::URL_TYPE_MEDIA).'catalog'.DS.'product'.$product['image']).'","'.
$product['category'][0]['category']['category_name'].'",'."\n";
if(!$used = Mage::getModel('core/session')->getUsedPids()){
$used = array();
}
$used[] = $product['entity_id'];
Mage::getModel('core/session')->setUsedPids($used);
}
}
if($count==0){ $start_file = true; } else { $start_file = false; }
$count++;
$start = $start+$limit;
$file = $this->toFile('csv', 'PaidOnResults', $txt, $start_file);
$txt = '';
ob_flush();
flush();
}
Mage::getBaseDir('media')
, if it doesn't work, feed it no arguments, and it'll give Magento's root directory, you'll just have to add the additional image path.