istox Posted December 15, 2010 Share Posted December 15, 2010 I Found this thread. But no answer of that problem. The help is needed to me to create this file with working // not working // not working 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 Also I have this working file. But language there are not seen correct when XML file is created. And I don't know how to create this one <?php$langLV = 4;include(dirname(__FILE__).'/config/config.inc.php');require_once(dirname(__FILE__).'/init.php');error_reporting(0);$p=Product::getProducts(4, 0, 0, 'id_product', 'desc', false); // number 4 is id of language in database$products=Product::getProductsProperties(4, $p); // number 4 is id of language in databaseheader("Content-Type: text/xml");echo '<?xml version="1.0" encoding="utf-8"?>';foreach ($products as $row) {$img=Product::getCover($row['id_product']);echo ''.str_replace("&", "&", $row['name']).' <link>'.$row['link'].'</link>'.($row['price']*1).'shop.com'.$shopUrl.'img/p/'.$row['id_product'].'-'.$img['id_image'].'.jpg'.str_replace("-", " ", $row['category']).'';}echo '';?> Link to comment Share on other sites More sharing options...
Recommended Posts