Jump to content

Product export in XML file


Recommended Posts

Hi, thank you for such a great product :) Here is a problem. I need to export product info to .xml file. But script can not get category information (Category name, Full Category info, Category info), all other info are works sussesfully. Here is a structure of XML i want to get

<xml version='1.0' encoding='utf-8'>

//works
   <link></link> //works
//works
//works
// not working
// not working
// not working

</xml>



and there is a php code

<?php

include(dirname(__FILE__).'/config/config.inc.php');
error_reporting(1);
$xml = 'productlist.xml';

/*code from another forum member */

$p=Product::getProducts(3, 0, 0, 'id_product', 'desc', false);
$id_category =Tools::getValue('id_category');
$id_category = $product->id_category_default;
$products=Product::getProductsProperties(3, $p); 

$line='<?xml version="1.0" encoding="utf-8"?>';
$line.="\r\n";
$line.="<xml>\r\n";


foreach ($products as $row) {

$kategorie=array();
$category = new Category(intval($row['id_category_default']), intval(10));
while ($category->id <> 1) {
   $kategorie[]=$category->hideCategoryPosition($category->name);
   $category = new Category(intval($category->id_parent), intval(10));
}

$img=Product::getCover($row['id_product']);

$line.="\r\n";
$line.='         '.str_replace('&','&',$row['name']).'';
$line.="\r\n";
$line.='         <link>http://www.example.com'.$row['link'].'</link>';
$line.="\r\n";
$line.='         '.($row['price']*1).'';
$line.="\r\n";
$line.='         http://www.example.com/img/p/'.$row['id_product'].'-'.$img['id_image'].'-home.jpg';
$line.="\r\n";
$line.='         '; /* i used '.implode('>',array_reverse($kategorie)).' but didn't worked  how to get ??? */
$line.="         \r\n"; /* for example Cars -> Ford  how to get ??? */
$line.="         \r\n"; /*  how to get ???  */
$line.="\r\n";
}

$line.= "</xml>\r\n";


$h=fopen($xml,"w+");
fwrite($h,$line);
fclose($h);

echo '<html><center>XML file
updated</html>'

?>


Maybe someone can help? Thanks

Link to comment
Share on other sites

  • 4 weeks later...

hi WildeThang, yes thats true, it otputs only one category not the full tree. I need this for one of my projects. So if you can help, i would be very thankfull :) thanks Hoodgrown i will check your links ;)

Link to comment
Share on other sites

  • 1 year later...
  • 4 months later...

I've found the full path of product category. Using the same code as before:



foreach ($products as $row) {
...
$path= Tools::getFullPath(intval($row['id_category_default']), $row['name']) ;
$path=strip_tags($path);

echo ''.$path.'';
...
}



Hope this will be useful for somebody.

Link to comment
Share on other sites

  • 4 months later...
×
×
  • Create New...