Jump to content

Integrating prestapyt to add/edit products


Recommended Posts

Hi everyone!

 

I'm trying to create a script to add products to Prestashop, using Python. I'm using prestapyt library (https://github.com/prestapyt/prestapyt).

 

My problem is that I can read products, I can get the template for a new product but I cannot UPLOAD or EDIT a new product, since it gives me a 400error - Bad request.

 

I've done the following:

 

1- I've added myself to a Webservice to get a key, with ALL permissions, I've activated it and I've activated the CGI for PHP.

2- I've asked my server provider to enable everything from their side, which they did.

 

I've created the following script:

from prestapyt import PrestaShopWebServicefrom prestapyt import PrestaShopWebServiceDict
from xml.etree import ElementTree
from pprint import pprint




DEBUG = 'true'
PS_SHOP_PATH = 'http://uk01.tmd.cloud/~craftypa/prestashop/'
PS_WS_AUTH_KEY ='something'


prestashop = PrestaShopWebServiceDict(PS_SHOP_PATH,PS_WS_AUTH_KEY)


address_data = prestashop.get('products', 1)
address_data['active'] = '0'
prestashop.edit('products', 1, address_data)
 
 
 
Even though I can run the "get" command (and I actually get that product), I cannot run this last line, getting the following error:

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 "build/bdist.macosx-10.11-intel/egg/prestapyt/prestapyt.py", line 516, in edit_with_url
  File "build/bdist.macosx-10.11-intel/egg/prestapyt/prestapyt.py", line 374, in edit_with_url
  File "build/bdist.macosx-10.11-intel/egg/prestapyt/prestapyt.py", line 196, in _execute
  File "build/bdist.macosx-10.11-intel/egg/prestapyt/prestapyt.py", 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.'
 
 
 
Any idea on how to solve this? I've been trying for a week now!
Thank you!
Carolina
 
Link to comment
Share on other sites

Guest
This topic is now closed to further replies.
×
×
  • Create New...