通过 Web 服务将产品添加到 PrestaShop 1.5 [英] Add product to PrestaShop 1.5 via Web Service

查看:69
本文介绍了通过 Web 服务将产品添加到 PrestaShop 1.5的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我尝试通过网络服务添加产品,但收到以下错误代码:

I try to add a product via web service and I receive bellow error code:

RETURN HTTP BODY
<?xml version="1.0" encoding="UTF-8"?>
<prestashop xmlns:xlink="http://www.w3.org/1999/xlink">
<errors>
<error>
<message><![CDATA[Internal error. To see this error please display the PHP errors.]]></message>
</error>
</errors>
</prestashop>

我搜索了 2 天,但什么也没找到.请任何人都可以帮助我吗?我的代码如下.

I am searching 2 days but nothing. Please can anyone help me? My Code is below.

define('DEBUG', true);
define('_PS_DEBUG_SQL_', true);
define('PS_SHOP_PATH', 'http://mywebsiteinlocalhost.gr/dev...shop/trunk/src/');
define('PS_WS_AUTH_KEY', 'CBYB5G5UVRA7FCN7JK2WZ625DFWG8SK3');
require_once ('./PSWebServiceLibrary.php');
$webService = new PrestaShopWebservice(PS_SHOP_PATH, PS_WS_AUTH_KEY, DEBUG);
$opt = array('resource' => 'products');
$xml = $webService->get(array('url' => PS_SHOP_PATH.'/api/products?schema=synopsis'));
$resources = $xml->children()->children();

unset($resources->position_in_category);
unset($resources->manufacturer_name);

$resources->price = '1000';
$resources->active = '1';
$resources->quantity = '50';
$resources->link_rewrite = 'blabla';
$resources->name->language[0][0] = 'blabla';
$resources->description->language[0][0] = '<p>blabla</p>';
$resources->description_short->language[0][0] = 'blabla';
$resources->associations = '';

$opt = array('resource' => 'products');
$opt['postXml'] = $xml->asXML();
$xml = $webService->add($opt); 

推荐答案

资源 Product 对 Prestashop 非常重要.我已经快速检查了模式概要"(.../api/products/?schema=synopsis).有 12 个字段标记为必填 true!在您的示例中,例如缺少默认的父类别!这就是它不起作用的原因之一!

The resource Product is kind of very important for Prestashop. I have checked quickly the schema 'synopsis' (.../api/products/?schema=synopsis). There are 12 fields marked as required true! In you example, the default parent category is missing for example! That is one of the reason why it didn't work!

这篇关于通过 Web 服务将产品添加到 PrestaShop 1.5的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆