在PrestaShop中创建XML Datafeed导出

时间:2018-01-26 18:18:12

标签: php xml prestashop prestashop-1.6

我想将presta商店版本1.6.0.11的产品导出到XML文件,以将其上传到谷歌购物。

我在这里发现了一篇文章,展示了如何导出,但我的XML仍然是空的 - 是否有人知道可能是什么问题?我没有收到任何错误。

XML看起来像这样:

<?xml version="1.0"?>
<xml/>

存在init.php和config.inc.php文件,我尝试的代码是:

<?php
include('config/config.inc.php');
include('init.php'); 
$productObj = new Product();
$products = $productObj -> getProducts($id_lang, 0, 0, 'id_product', 'DESC' );

$xml = new SimpleXMLElement('<xml/>');
foreach($products as $product) {
    $productXml = $xml->addChild('product');
    $productXml->addChild('id', $product->id);
    $productXml->addChild('name', $product->name);
    $productXml->addChild('description', $product->description);
}
Header('Content-type: text/xml');
print($xml->asXML());

?>

有人可以帮帮我吗?

1 个答案:

答案 0 :(得分:0)

您的$ id_lang未设置-只需输入整数-您的语言ID。