Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Wrong parameter type in the 'customer_register_success' dispatch #154

Open
WaPoNe opened this issue May 24, 2024 · 0 comments
Open

Wrong parameter type in the 'customer_register_success' dispatch #154

WaPoNe opened this issue May 24, 2024 · 0 comments

Comments

@WaPoNe
Copy link

WaPoNe commented May 24, 2024

System: Magento Version: Magento Open Source ver. 2.4.5/2.4.5-p3 Vanilla
PHP Version: 8.1
Gigya Version: gigya/magento2-im: 6.0.0/6.1.0

Issue description:
Installed the extension in a Vanilla instance, it works fine.
If I create my module with a frontend observer on 'customer_register_success' event (<mage_dir>/app/code/Vendor/Module/etc/frontend/events.xml):

<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
        xsi:noNamespaceSchemaLocation="urn:magento:framework:Event/etc/events.xsd">
    <event name="customer_register_success">
        <observer name="my_customer_register_success_observer" instance="Vendor\Module\Observer\CustomerRegisterSuccess" />
    </event>
</config>

trying to get data from account controller (<mage_dir>/app/code/Vendor/Module/Observer/CustomerRegisterSuccess.php)

    public function execute(\Magento\Framework\Event\Observer $observer)
    {
        $params = $observer->getAccountController()->getRequest()->getParams();
        $customerEmail = $params['email'];
    }

I get this message error:
Undefined array key "email"

This depends from your source code that overrides Magento core class by preference Gigya/GigyaIM/etc/di.xml

    <preference for="Magento\Customer\Controller\Account\LoginPost"
                type="Gigya\GigyaIM\Controller\Raas\GigyaPost" />

and in gigyaCreateUser() function of Gigya\GigyaIM\Controller\Raas\GigyaPost class

            $this->_eventManager->dispatch(
                'customer_register_success',
                ['account_controller' => $this, 'customer' => $customer]
            );

returning account_controller with Gigya\GigyaIM\Controller\Raas\GigyaPost type (and without data) instead of Magento\Customer\Controller\Account\CreatePost type as documentated by Magento (vendor/magento/module-customer/README.md):

customer_register_success event in the \Magento\Customer\Controller\Account\CreatePost::execute method. Parameters:
- account_controller is a $this object (\Magento\Customer\Controller\Account\CreatePost class)
- customer is a customer object (\Magento\Customer\Model\Data\Customer class)

'customer_register_success' event is used in many vendor extensions.

Could you solve the problem?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant