emartech / magento2-extension

Emarsys Magento2 Extension
MIT License
11 stars 9 forks source link

Customer synchro resets existing contact data #22

Closed adamkarnowka closed 2 years ago

adamkarnowka commented 2 years ago

Hello, we've found out that in some scenarios, data loss in Emarsys is possible. Assuming that:

When registering and going through DOI process - it will generate such payload to be updated in Emarsys (taken from emarsys_events_data).

{
   "customer":{
      "id":"1209983",
      "rp_token":"aVYBTefITOMIdWGCYq6U3CmDw4Jrqnx1",
      "rp_token_created_at":"2022-04-06 12:50:30",
      "billing_address":{
         "firstname":null,
         "suffix":null,
         "middlename":null,
         "lastname":null,
         "prefix":null,
         "city":null,
         "company":null,
         "country_id":null,
         "fax":null,
         "postcode":null,
         "region":null,
         "street":null,
         "telephone":null
      },
      "shipping_address":{
         "firstname":null,
         "suffix":null,
         "middlename":null,
         "lastname":null,
         "prefix":null,
         "city":null,
         "company":null,
         "country_id":null,
         "fax":null,
         "postcode":null,
         "region":null,
         "street":null,
         "telephone":null
      },
      "website_id":1,
      "store_id":1,
      "email":"hello_emarsys@gmail.com",
      "group_id":"1",
      "is_active":"1",
      "prefix":null,
      "lastname":"Karnowka",
      "middlename":null,
      "firstname":"Adam",
      "suffix":null,
      "dob":null,
      "taxvat":null,
      "gender":null,
      "accepts_marketing":"2",
      "created_at":"2022-04-06 12:50:30",
      "updated_at":"2022-04-06 12:50:30",
      "store_code":"de_de"
   },
   "back_url":"https:\/\/www.*******.com\/de_de\/customer\/account\/index\/",
   "store":{
      "store_id":1,
      "code":"de_de",
      "website_id":1,
      "group_id":"1",
      "name":"Germany",
      "sort_order":"0",
      "is_active":"1",
      "hreflang_code":"de-DE",
      "available_currency_codes":[
         "EUR"
      ],
      "base_currency":[

      ],
      "current_currency":[

      ],
      "store_code":"de_de"
   },
   "store_id":1
}

As you can see, most of these properties are missing any information, because we don't have them during registration - as a result - data we had before in Emarsys will be overriden with empty values. image

In my opinion, if values are empty, they should not be included in payload. Only data fetched directly from customer should override data in Emarsys (for example lastname).

I can prepare PR for this change, if you decide to include this change. If not, I will create plugin in our code to change this behaviour. Please let me know.

Cheers, Adam

BlasiusVonSzerencsi commented 2 years ago

Hi,

Thanks for your request, we'll evaluate it internally and come back with an answer as soon as possible.

The request sounds completely reasonable, however, the plugin and the ecosystem around it was built with the mindset, that the Magento is the leading database (which should be replicated to Emarsys). We'll have to check what this change would affect in our existing user base and make our decision based on that.

Thanks, Balazs

adamkarnowka commented 2 years ago

Hi, thanks for your reply - I can totally understand your position and I got official information that it won't be changed, so we'll patch it on our end. I will close the issue in this case.

Kind regards Adam