Prestashop Webservice添加产品

时间:2014-05-06 09:24:11

标签: php prestashop prestashop-1.5

我使用Prestashop 1.5,我尝试使用Prestashop的Webservice API PHP插入产品,但它永远不会有效......

某人是否有类别或产品的插入脚本?

例如,我找到了一个类别插入脚本,但它不起作用:

<?php

require_once('./PSWebServiceLibrary.php');

define('DEBUG', true);
define('PS_SHOP_PATH', 'http://dev.*******.com/');
define('PS_WS_AUTH_KEY', '******************************');
$webService = new PrestaShopWebservice(PS_SHOP_PATH, PS_WS_AUTH_KEY, DEBUG);
$xml = $webService -> get(array('url' => PS_SHOP_PATH . '/api/categories?schema=synopsis'));

$resources = $xml -> children() -> children();
unset($resources ->id);
unset($resources ->position);
unset($resources ->date_add);
unset($resources ->date_upd);
//unset($resources ->id_parent); //if unset category will be root. If set it must have id existing parent category!
unset($resources ->level_depth);
unset($resources ->nb_products_recursive);
$resources ->id_parent = '6';
$resources ->name ->language[0][0] = 'test';
$resources ->link_rewrite->language[0][0] = 'test';
$resources ->active = 1;
$resources ->id_shop_default = 1;
$resources ->is_root_category = 0;

$opt = array('resource' => 'categories');

$opt['postXml'] = $xml -> asXML();

$xml = $webService -> add($opt);

我有错误500。

有人有解决方案吗?

提前谢谢!

0 个答案:

没有答案