dotmailer / dotmailer-magento2-extension-sms

MIT License
0 stars 3 forks source link

It is possible that the account_controller will not be present in the customer_register_success event #8

Closed nans closed 12 months ago

nans commented 1 year ago

Where

    <event name="customer_register_success">
        <observer name="ddg_customer_register_success_sms" instance="Dotdigitalgroup\Sms\Observer\Customer\Register"/>
    </event>

Class: Dotdigitalgroup\Sms\Observer\Customer\Register

    public function execute(Observer $observer): void
    {
        $request = $observer->getAccountController()->getRequest()->getPost();
        $customer = $observer->getEvent()->getCustomer();
        $storeId = $customer->getStoreId();

Issue It is possible that the account_controller will not be present in the event. I recommend adding handling for such a situation, otherwise, the checkout or any other customized logic may break. For example, Amasty Single Step Checkout 3.1.3 dispatching event without account_controller variable.

sta1r commented 1 year ago

Thanks @nans. So, Amasty Single Step Checkout dispatches the customer_register_success event at checkout?

nans commented 12 months ago

Hi @sta1r, yes (relevant for version 3.1. I can’t say anything about more recent versions). I see in the Magento code there is a check for the presence of a controller: image

sta1r commented 12 months ago

Resolved in https://github.com/dotmailer/dotmailer-magento2-extension-sms/releases/tag/v2.0.1. Thanks again @nans!