对于Prestashop 1.6.1.7 你好, 我在我的网站访问者中有一个部分他们可以表达他们的产品(二手)具有多个照片,产品名称,产品价格,联系卖家,描述,关键字(可选)等功能。 在提交表单并记录二手产品类别后,我将通过prestashop webservice, 类别ID是994。 我写了这段代码:
<?php
$shop_url = 'http://subdomain.test.com';
$secret_key = '9CQEDRKAD5IF8C9FFPP59T7AJSCPIW2Q';
$debug = true;
require_once('./PSWebServiceLibrary.php');
try {
$webService = new PrestaShopWebservice($shop_url, $secret_key, $debug);
$xml = $webService->get(array('url' => $shop_url.'/api/products?schema=blank'));
$resources = $xml->children()->children();
if (!isset($_POST['btn_submit']))
{
$html = '<form action="" method="POST"><table border=1>';
foreach ($resources as $key => $resource)
{
$html .= '<tr><th>'.$key.'</th><td>';
$html .= '<input type="text" name="form['.$key.']" value=""/>';
$html .= '</td></tr>';
}
$html .= '<td colspan=2><input type="submit" name="btn_submit" value="btn_submit" /></td>';
$html .= '</table></form>';
echo $html;
}
else
{
foreach ($resources as $nodeKey => $node)
{
$resources->$nodeKey = $_POST['form'][$nodeKey];
}
try {
$opt = array('resource' => 'products');
$opt['postXml'] = $xml->asXML();
$xml = $webService->add($opt);
echo "Successfully added.";
}
catch(PrestaShopWebserviceException $ex) {
echo 'Other error: <br />' . $ex->getMessage();
}
}
}
catch (PrestaShopWebserviceException $ex) {
echo 'Other error: <br />' . $ex->getMessage();
}
?>
这是prestashop根文件夹中的add_product.php。 prestashop根文件夹中的PSWebServiceLibrary.php。
为什么不能正常工作,如何总结产品名称,产品描述,产品价格等形式。
screentshot附。
答案 0 :(得分:0)
您必须激活Prestashop DEBUG MODE Activate Prestashop Debug Mode。这样Prestashop将向您展示您对产品XML的确切问题。它应该是一些没有通过产品验证过程的字段,因为格式不正确或不允许。
祝你好运。