我正在尝试创建一个脚本,通过Python向prestashop添加产品。在
我正在使用pretapy库;我可以读取文件,我可以为新文件获取模板,但我不能上载新文件。这就是我所拥有的:
from prestapyt import PrestaShopWebServiceError
from prestapyt import PrestaShopWebService
from prestapyt import PrestaShopWebServiceDict
DEBUG = 'true'
PS_SHOP_PATH = MYPATH
PS_WS_AUTH_KEY = MYKEY
prestashop = PrestaShopWebServiceDict(PS_SHOP_PATH, PS_WS_AUTH_KEY, DEBUG)
myproducts = prestashop.search('products');
addNewProduct(prestashop)
在哪里
^{pr2}$当运行这个脚本时,我得到以下信息:
Execute url: MYPATH/api/products / method: POST Response code: 400
Response headers:
{'status': '400', 'psws-version': '1.6.1.6', 'x-powered-by': 'PrestaShop Webservice', 'transfer-encoding': 'chunked', 'set-cookie': 'PrestaShop-a0d2999cb4d9d838ea9bbca3cf8a7a22=gv2rmNYce013aHwM2TQ7718d8sl%2BCmTtT1hO7pqS6ItiGKUPTa%2FGUwpTprJh9pihDKJbQNq4DKb0N6SYqC5nxBM4Q%2F1AFCrubceV8yPEcMo%3D000079; expires=Tue, 27-Sep-2016 21:15:16 GMT; Max-Age=1728000; path=MYPATH; domain=SOMETHING; httponly', 'access-time': '1473282916', 'connection': 'close', 'execution-time': '0.008', 'date': 'Wed, 07 Sep 2016 21:15:16 GMT', 'server': 'Apache', 'content-type': 'text/xml;charset=utf-8'}
Response body:
'PrestaShop error: 400 Bad Request. Internal error. To see this error please display the PHP errors.'
有什么想法吗?在
谢谢!在
更新: 我添加了你的建议,我得到的是:
Traceback (most recent call last):
File "Script.py", line 24, in <module>
prestashop.edit('products', 1, address_data)
File "build/bdist.macosx-10.11-intel/egg/prestapyt/prestapyt.py", line 363, in edit
File "SAME", line 516,
in edit_with_url File "SAME", line 374,
in edit_with_url File "SAME", line 196,
in _execute File "SAME", line 127,
in _check_status_code
prestapyt.prestapyt.PrestaShopWebServiceError: 'PrestaShop error: 400 Bad Request. Internal error. To see this error please display the PHP errors.'
它在这里断裂:
address_data = prestashop.get('products', 1)
address_data['active'] = '0'
prestashop.edit('products', 1, address_data) -> THIS LINE
有什么新主意吗?谢谢您!在
您应该做^ {CD1>},而不是^ {},空白模式结构是:^ {CD3}}。在
在编辑中,当您使用
edit()
函数时,不必指定产品标识,而是从地址数据字段(至少在当前版本中)中收集。但您必须再次以这种方式编辑字段:address_data['product]['active']
='0'希望这有帮助。在
相关问题 更多 >
编程相关推荐