我正在搜索教程或文档,其中解释了Prestashop (v1.5.6.0)的use服务用法。我想简单地添加或编辑(更新)o产品。没有关于使用prestashop的api的教程.你能帮帮我吗?
例如,我想添加对象a:
define('PS_SHOP_PATH', 'http://localhost/myshop'); // Root path of your PrestaShop store
define('PS_WS_AUTH_KEY', '****'); // Auth key (Get it in your Back Office)
require_once('api/PSWebServiceLibrary.php');
$webService = new PrestaShopWebservice(PS_SHOP_PATH, PS_WS_AUTH_KEY, DEBUG);
$opt = array('resource' => 'products');现在,我如何为一个新对象设置我的值?在本例中,您只能插入所需的值。你能帮我吗?
那么更新呢?
请不要链接我的Prestashop文档,我已经读过了,我请求您的帮助。感谢并为我糟糕的英语道歉。
发布于 2013-11-15 22:24:42
以下是官方文档的link。你会在那里找到你需要的所有信息。
基本上,您需要创建一个XML来表示您想要放置的对象。
假设你想创建一个新的类别。
首先,您需要获取模式:
$xml = $webService->get(array('url' => PS_SHOP_PATH.'/api/categories?schema=blank'));大概是这样的:
<prestashop>
<category>
</category>
</prestashop>然后,您必须设置xml的内容($resources)
$resources = $xml->children()->children();
$resources->active = true;
$resources->..........
etc.最后,
try
{
$opt = array('resource' => 'categories');
$opt['postXml'] = $xml->asXML();
$xml = $webService->add($opt);
}
catch (PrestaShopWebserviceException $e)
{
echo 'Something went wrong: '.$e->getMessage();
}https://stackoverflow.com/questions/19958462
复制相似问题