Currently to check if a customer was registered by the observer, I am using an around plugin to check for this.
Something like this:
public function aroundExecute(ConvertGuestToCustomer $subject, callable $proceed, Observer $observer): void
{
/** @var Quote $quote */
$quote = $observer->getEvent()->getQuote();
// Should be null for guest orders
$customerIdBeforeObserver = (int)$quote->getCustomerId();
$proceed($observer);
// Will be set of the observer ran successfully
$customerIdAfterObserver = (int)$quote->getCustomerId();
if ($customerIdBeforeObserver === $customerIdAfterObserver || !$this->isCreateAccountChecked()) {
return;
}
// my custom code here
}
Would it make sense to add an event in the observer?
Like this:
public function execute(Observer $observer): void
{
// ...
if ($this->newAccountConfig->sendPasswordMailEnabled()) {
$this->sendPasswordResetEmail($customer->getEmail());
}
$this->eventManager->dispatch(
'vendic_checkout_customer_created,
[
'quote' => $quote,
'order' => $order,
'customer' => $customer
]
);
}
Currently to check if a customer was registered by the observer, I am using an around plugin to check for this.
Something like this:
Would it make sense to add an event in the observer?
Like this: