首页 > 解决方案 > Creating new customer from API doesn't set the Associations group id

问题描述

I am trying to create a new customer using prestashop webservice on Postman. I already update webservice to accept json format for both input&output. When i try to create a new customer, there is a row added to database but the associations group id is not added.

I get the blank resource by http://mywebsite.com/api/customers?schema=synopsis and here what i get:

{
"customer": {
    "id_default_group": "",
    "id_lang": "",
    "newsletter_date_add": "",
    "ip_registration_newsletter": "",
    "last_passwd_gen": "",
    "secure_key": "",
    "deleted": "",
    "passwd": "",
    "lastname": "",
    "firstname": "",
    "email": "",
    "id_gender": "",
    "birthday": "",
    "newsletter": "",
    "optin": "",
    "website": "",
    "company": "",
    "siret": "",
    "ape": "",
    "outstanding_allow_amount": "",
    "show_public_prices": "",
    "id_risk": "",
    "max_payment_days": "",
    "active": "",
    "note": "",
    "is_guest": "",
    "id_shop": "",
    "id_shop_group": "",
    "date_add": "",
    "date_upd": "",
    "reset_password_token": "",
    "reset_password_validity": "",
    "associations": {
        "groups": [
            {
                "id": null
            }
        ]
    }
}
}

and here is how i fill out the form:

{
"customer": {
    "id_default_group": "3",
    "id_lang": "1",
    "newsletter_date_add": "0000-00-00 00:00:00",
    "ip_registration_newsletter": "",
    "last_passwd_gen": "",
    "secure_key": "",
    "deleted": "0",
    "passwd": "20101998",
    "lastname": "sign up",
    "firstname": "test",
    "email": "asdfgh@gmail.com",
    "id_gender": "2",
    "birthday": "0000-00-00",
    "newsletter": "0",
    "optin": "0",
    "website": "",
    "company": "",
    "siret": "",
    "ape": "",
    "outstanding_allow_amount": "0.000000",
    "show_public_prices": "0",
    "id_risk": "0",
    "max_payment_days": "0",
    "active": "1",
    "note": "",
    "is_guest": "0",
    "id_shop": "1",
    "id_shop_group": "1",
    "date_add": "",
    "date_upd": "",
    "reset_password_token": "",
    "reset_password_validity": "0000-00-00 00:00:00",
    "associations": {
        "groups": [
            {
                "id": "3"
            }
        ]
    }
}
}

and here is the result:

{
"customers": [
    {
        "id": "41",
        "id_default_group": 3,
        "id_lang": "1",
        "newsletter_date_add": "0000-00-00 00:00:00",
        "ip_registration_newsletter": "",
        "last_passwd_gen": "2019-11-08 09:24:55",
        "secure_key": "c8aa63435abbd3282b22080c903091e4",
        "deleted": "0",
        "passwd": "$2y$10$mt4u0xuPadIRVsV267Ao8uTGEPU.vixzNMRAfX5P.WY2OJClpBHsW",
        "lastname": "sign up",
        "firstname": "test",
        "email": "asdfgh@gmail.com",
        "id_gender": "2",
        "birthday": "0000-00-00",
        "newsletter": "0",
        "optin": "0",
        "website": "",
        "company": "",
        "siret": "",
        "ape": "",
        "outstanding_allow_amount": "0.000000",
        "show_public_prices": "0",
        "id_risk": "0",
        "max_payment_days": "0",
        "active": "1",
        "note": "",
        "is_guest": "0",
        "id_shop": "1",
        "id_shop_group": "1",
        "date_add": "2019-11-08 15:24:55",
        "date_upd": "2019-11-08 15:24:55",
        "reset_password_token": "",
        "reset_password_validity": "0000-00-00 00:00:00"
    }
]
}

You can see that no association return.

Could anyone tell me what I was wrong? I'm quite new to prestashop. Thanks in advance

标签: web-servicesprestashop

解决方案


推荐阅读