Dev_Guy Posted February 15 Share Posted February 15 I'm developing a library that is basically a wrapper for the different PS resources. The thing is that looking at the values returned by some resources I have noticed that sometimes I receive a zero value as the identifier of a resource. For example: If I call the addresses resource I receive a Json with the following form: { "address": { "id": 2, "id_customer": "2", "id_manufacturer": "0", "id_supplier": "0", "id_warehouse": "0", "id_country": "8", "id_state": "0", "alias": "Mon adresse", "company": "My Company", "lastname": "DOE", "firstname": "John", "vat_number": "", "address1": "16, Main street", "address2": "2nd floor", "postcode": "75002", "city": "Paris ", "other": "", "phone": "0102030405", "phone_mobile": "", "dni": "", "deleted": "0", "date_add": "2021-09-03 20:40:16", "date_upd": "2021-09-03 20:40:16" } } As you can see in the example, the value of id_state is "0" but when I call the states resource with the value 0, it returns a 404 NOT FOUND code. Reading the documentation, the value of id_state is isNullOrUnsignedId so I understand that if that resource does not exist it should return null instead of 0 right? My question is, how should I interpret the value 0 in this context? Additionally, it says that the value of id_state should be isNullOrUnsignedId but it actually returns a String with a numeric value. It's not a big problem but I don't understand why it's a String, in fact, the only really numeric value is the first one ("id"), the rest are Strings I don't know if I'm doing something wrong or I'm misunderstanding something Any clarification is welcome Thank you very much and sorry for the inconvenience Best Regards Link to comment Share on other sites More sharing options...
Webkul Solutions Posted May 16 Share Posted May 16 On 2/15/2025 at 7:44 PM, Dev_Guy said: I'm developing a library that is basically a wrapper for the different PS resources. The thing is that looking at the values returned by some resources I have noticed that sometimes I receive a zero value as the identifier of a resource. For example: If I call the addresses resource I receive a Json with the following form: { "address": { "id": 2, "id_customer": "2", "id_manufacturer": "0", "id_supplier": "0", "id_warehouse": "0", "id_country": "8", "id_state": "0", "alias": "Mon adresse", "company": "My Company", "lastname": "DOE", "firstname": "John", "vat_number": "", "address1": "16, Main street", "address2": "2nd floor", "postcode": "75002", "city": "Paris ", "other": "", "phone": "0102030405", "phone_mobile": "", "dni": "", "deleted": "0", "date_add": "2021-09-03 20:40:16", "date_upd": "2021-09-03 20:40:16" } } As you can see in the example, the value of id_state is "0" but when I call the states resource with the value 0, it returns a 404 NOT FOUND code. Reading the documentation, the value of id_state is isNullOrUnsignedId so I understand that if that resource does not exist it should return null instead of 0 right? My question is, how should I interpret the value 0 in this context? Additionally, it says that the value of id_state should be isNullOrUnsignedId but it actually returns a String with a numeric value. It's not a big problem but I don't understand why it's a String, in fact, the only really numeric value is the first one ("id"), the rest are Strings I don't know if I'm doing something wrong or I'm misunderstanding something Any clarification is welcome Thank you very much and sorry for the inconvenience Best Regards This is PrestaShop behaviour that every value will come as a string instead of the table primary key. To meet your requirement, you can modify the output response using the files below. For JSON: ROOT_DIR/classes/webservice/WebserviceOutputJSON.php For XML: ROOT_DIR/classes/webservice/WebserviceOutputXML.php Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now