dotmailer / dotmailer-magento2-extension

The official Dotdigital for Magento2 extension
https://dotdigital.com/integrations/magento
MIT License
48 stars 64 forks source link

Provide fallback store id in OrderSaveAfter observer #596

Closed chapagain closed 1 year ago

chapagain commented 1 year ago

Fix 502 error on POST API Call

We upgraded dotdigital email module from v4.12.0 to v.4.19.3 on our Magento 2 store (Magento version 2.4.3-p2).

After the dotdigital module upgrade, the order post API call is not working. It's throwing 502 error.

curl --location --request POST 'https://mydomain.test/rest/V1/orders' \
--header 'Authorization: Bearer l5xxxxublxxxxxxxxxxigozdxxxxxjw' \
--header 'Content-Type: application/json' \
--data-raw '{
    "entity" : {
        "entity_id" : 11683,
        "increment_id" : "000011554",
        "status": "picked"
    }
}'

The $storeId was null on the REST API Call.

This PR fixes the issue.

sta1r commented 1 year ago

@chapagain Thanks for this. Yes you're right, since 4.14.0 we made a change to always use the order's store id: https://github.com/dotmailer/dotmailer-magento2-extension/commit/67c30b9af7922a34a48687bab1a2e375f0c61833#diff-7c6e256693f6d0a136df6d7a64ef525ccc08927e0cf4c74fdddf0e6cfc85fd40

A question about your suggested change though - if you're saving an order via API without specifying its store id, the default store id will be set against the order in our email_order table. Is this a concern? If you had different scopes, this could affect the sync fx by pushing an order into the wrong Dotdigital account.

sta1r commented 1 year ago

@chapagain we're preparing to merge this. Please could you change the title to 'Provide fallback store id in OrderSaveAfter observer'?