1
的Prestashop 1.6.1.7 你好, 我有一个功能,如多张照片,产品名称,产品价格,接触我的网站访问者部分,他们可以表达自己的产品(二手)卖家,描述,关键字(可选)他们。 我经历的Prestashop web服务的形式提交,并在二手产品种类记录, 分类ID是994 后,我写了这个代码:的Prestashop 1.6新增产品与web服务
<?php
$shop_url = 'http://subdomain.test.com';
$secret_key = '9CQEDRKAD5IF8C9FFPP59T7AJSCPIW2Q';
$debug = true;
require_once('./PSWebServiceLibrary.php');
\t try {
\t \t $webService = new PrestaShopWebservice($shop_url, $secret_key, $debug);
\t \t $xml = $webService->get(array('url' => $shop_url.'/api/products?schema=blank'));
\t \t $resources = $xml->children()->children();
\t \t
\t \t if (!isset($_POST['btn_submit']))
\t \t {
\t \t \t $html = '<form action="" method="POST"><table border=1>';
\t \t \t foreach ($resources as $key => $resource)
\t \t \t {
\t \t \t \t $html .= '<tr><th>'.$key.'</th><td>';
\t \t \t \t $html .= '<input type="text" name="form['.$key.']" value=""/>';
\t \t \t \t $html .= '</td></tr>';
\t \t \t }
\t \t \t $html .= '<td colspan=2><input type="submit" name="btn_submit" value="btn_submit" /></td>';
\t \t \t $html .= '</table></form>';
\t \t \t echo $html;
\t \t }
\t \t else
\t \t {
\t \t \t foreach ($resources as $nodeKey => $node)
\t \t \t {
\t \t \t \t $resources->$nodeKey = $_POST['form'][$nodeKey];
\t \t \t }
\t \t \t
\t \t \t try { \t \t
\t \t \t \t $opt = array('resource' => 'products');
\t \t \t \t $opt['postXml'] = $xml->asXML();
\t \t \t \t $xml = $webService->add($opt);
\t \t \t \t echo "Successfully added."; \t \t \t
\t \t \t }
\t \t \t catch(PrestaShopWebserviceException $ex) {
\t \t \t \t echo 'Other error: <br />' . $ex->getMessage();
\t \t \t }
\t \t }
\t }
\t catch (PrestaShopWebserviceException $ex) {
\t \t echo 'Other error: <br />' . $ex->getMessage();
\t }
?>
这是add_product .php在prestashop根文件夹中。Prestashop根文件夹中的PSWebServiceLibrary.php。
为什么不能正常工作,我怎样才能总结产品名称,产品说明,产品价格等形式。
screentshot附。