Affects Version/s: None
Fix Version/s: None
Security Level: All-users
This is not really a bug, but a "proposal" to modify the behavior of the PrestaShop PUT webservice.
I am one of the developpers of the PrestaShop-OpenERP connector. In this connector, we map the objects of OpenERP with the objects of PrestaShop ; then, for these mapped objects, we map some fields of PrestaShop with some fields of OpenERP.
For example : the "customer" object in PrestaShop is mapped to the "partner" object of OpenERP.
For this mapped object :
- the field "deleted" in PrestaShop is mapped to the field "active" in prestashop (through an "inverse" function)
- the field "firstname" and "lastname" in PrestaShop is mapped to the field "name" in OpenERP (through a function)
- the field "website" in PrestaShop is mapped to the field "website" in OpenERP
But not all fields are mapped : for example, the field birthday in PrestaShop doesn't have any equivalent in OpenERP.
The current method to update a record in PrestaShop is well explained here :
With the current code of the OpenERP-PrestaShop connector, when we update a customer in OpenERP and sync it with PrestaShop, we send a PUT request on /api/customers with all the mapped fields (but the request doesn't contain the unmapped fields such as "birthday"). The mapped fields are updated in PrestaShop... but the unmapped fields are "resetted" ; so, if the customer had a birthday set in PrestaShop, it's birthday is deleted in the PrestaShop database.
To solve this issue, we have 2 solutions :
1) Modify the PrestaShop-OpenERP connector (more precisely, modify prestapyt) so that, when a record is updated in OpenERP and pushed to PrestaShop, the behavior would be the following :
- we do a GET on /api/customers/ID_in_prestashop and receive the XML of that customer with all the fields
- we parse this XML and update the PrestaShop fields that are mapped to OpenERP fields
- use this updated XML to do a PUT on /api/customers/
That would work without any modification in PrestaShop... but it's quite a heavy process !
2) Modify the behavior of the PrestaShop webservice : when PrestaShop receives a PUT with some XML content to update an existing record, the fields that are not present in the XML are NOT changed in the PrestaShop database.
That would like things easier and faster ! In fact, this is the behavior we have with the webservices of other applications such as OpenERP and Magento, so it's quite a common behavior.
Do you agree with the idea proposed in solution n°2 ?
Alexis de Lattre, for the OpenERP-PrestaShop connector team