PrestaShop create customer

老子叫甜甜 提交于 2019-12-03 15:39:25

"customer" is not an independant field but a container for all the other fields like firstname, lastname, email, etc.

The best way to create a customer is to retrieve and blank sheet and to fill it with your data: http://your-prestashop.com/api/customers?schema=blank

I ran into similar issues and here's what I found out on prestashop version 1.6.0.9:

1) As @adrien-g points out, change from define('_PS_MODE_DEV_', false); to define('_PS_MODE_DEV_', true); http://doc.prestashop.com/display/PS16/Setting+Up+Your+Local+Development+Environment#SettingUpYourLocalDevelopmentEnvironment-Displayingerrormessages

2) Next you will start seeing more meaningful errors like the one simulated with this CURL command:

$ curl -kv https://myprestashop.bitnamiapp.com/prestashop/api/customers?ws_key=secret -d '
<?xml version="1.0" encoding="UTF-8"?><customer><lastname>blue</lastname><firstname>boy</firstname><email>boy@blue.com</email></customer>'
... 
<message><![CDATA[parameter "passwd" required]]></message>
...

3) Then some experimentation like adding the passwd and prestashop tags will finally lead you down a path where you see customers successfully being created:

$ curl -kv https://myprestashop.bitnamiapp.com/prestashop/api/customers?ws_key=secret -d '
<?xml version="1.0" encoding="UTF-8"?>
  <prestashop xmlns:xlink="http://www.w3.org/1999/xlink">
    <customer><lastname>blue</lastname><firstname>boy</firstname><email>boy@blue.com</email>
      <passwd>mysecret</passwd>
    </customer>
  </prestashop>'
... 
<?xml version="1.0" encoding="UTF-8"?>
<prestashop xmlns:xlink="http://www.w3.org/1999/xlink">
<customer><id><![CDATA[3]]></id>...</customer></prestashop>
...

Worth noting:

  • using <?xml ...><prestashop></prestashop> versus xml=<?xml ...><prestashop></prestashop> doesn't make any difference in the version I played around with.
  • using <prestashop> versus <prestashop xmlns:xlink="http://www.w3.org/1999/xlink"> doesn't make any difference in the version I played around with.
标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!