17
17
use Magento \Checkout \Model \Session as CheckoutSession ;
18
18
use Psr \Log \LoggerInterface ;
19
19
use Vendic \HyvaCheckoutCreateAccount \Magewire \Checkbox ;
20
+ use Vendic \HyvaCheckoutCreateAccount \Model \Config ;
20
21
21
22
class ConvertGuestToCustomer implements ObserverInterface
22
23
{
@@ -26,7 +27,8 @@ public function __construct(
26
27
private AccountManagementInterface $ accountManagement ,
27
28
private StoreManagerInterface $ storeManager ,
28
29
private CheckoutSession $ checkoutSession ,
29
- private LoggerInterface $ logger
30
+ private LoggerInterface $ logger ,
31
+ private Config $ newAccountConfig
30
32
) {
31
33
}
32
34
@@ -56,7 +58,9 @@ public function execute(Observer $observer): void
56
58
// Ideally we should make this configurable.
57
59
->setCustomerGroupId (\Magento \Customer \Api \Data \GroupInterface::NOT_LOGGED_IN_ID );
58
60
59
- $ this ->sendPasswordResetEmail ($ customer ->getEmail ());
61
+ if ($ this ->newAccountConfig ->sendPasswordMailEnabled ()) {
62
+ $ this ->sendPasswordResetEmail ($ customer ->getEmail ());
63
+ }
60
64
}
61
65
62
66
private function createNewCustomerFromQuote (Quote $ quote ): ?\Magento \Customer \Api \Data \CustomerInterface
@@ -84,7 +88,7 @@ private function sendPasswordResetEmail(string $email): void
84
88
try {
85
89
$ this ->accountManagement ->initiatePasswordReset (
86
90
$ email ,
87
- AccountManagement:: EMAIL_RESET ,
91
+ $ this -> newAccountConfig -> getNewPasswordTemplate () ,
88
92
$ this ->storeManager ->getStore ()->getWebsiteId ()
89
93
);
90
94
} catch (Exception $ e ) {
0 commit comments