@@ -45,32 +45,33 @@ protected function execute(InputInterface $input, OutputInterface $output): int
4545 //I think that this load in the long time can be a bottle necklace
4646 $ subscriptions = $ this ->backInStockNotificationRepository ->findBy (['notify ' => false ]);
4747 foreach ($ subscriptions as $ subscription ) {
48- try {
49- $ channel = $ subscription ->getChannel ();
50- $ productVariant = $ subscription ->getProductVariant ();
51- if ($ productVariant === null || $ channel === null ) {
52- $ this ->backInStockNotificationRepository ->remove ($ subscription );
53- $ this ->logger ->warning (
54- 'The back in stock subscription for the product does not have all the information required ' ,
55- ['subscription ' => var_export ($ subscription , true )],
56- );
48+ $ channel = $ subscription ->getChannel ();
49+ $ productVariant = $ subscription ->getProductVariant ();
50+ if ($ productVariant === null || $ channel === null ) {
51+ $ this ->backInStockNotificationRepository ->remove ($ subscription );
52+ $ this ->logger ->warning (
53+ 'The back in stock subscription for the product does not have all the information required ' ,
54+ ['subscription ' => var_export ($ subscription , true )],
55+ );
5756
58- continue ;
59- }
57+ continue ;
58+ }
6059
61- if (
62- $ this ->availabilityChecker ->isStockAvailable ($ productVariant ) &&
63- $ productVariant ->isEnabled () &&
64- $ productVariant ->getProduct ()?->isEnabled() === true
65- ) {
66- $ this ->router ->getContext ()->setHost ($ channel ->getHostname () ?? 'localhost ' );
60+ if (
61+ $ this ->availabilityChecker ->isStockAvailable ($ productVariant ) &&
62+ $ productVariant ->isEnabled () &&
63+ $ productVariant ->getProduct ()?->isEnabled() === true
64+ ) {
65+ $ this ->router ->getContext ()->setHost ($ channel ->getHostname () ?? 'localhost ' );
66+
67+ try {
6768 $ this ->sendEmail ($ subscription , $ productVariant , $ channel );
68- $ subscription ->setNotify (true );
69- $ this ->backInStockNotificationRepository ->add ($ subscription );
69+ } catch (RfcComplianceException $ e ) {
70+ $ this ->logger ->warning ('Invalid email address, continue to the next one: ' . $ e ->getMessage ());
71+ continue ;
7072 }
71- } catch (RfcComplianceException $ e ) {
72- // Invalid email address, continue to the next one
73- $ this ->logger ->warning ($ e ->getMessage ());
73+ $ subscription ->setNotify (true );
74+ $ this ->backInStockNotificationRepository ->add ($ subscription );
7475 }
7576 }
7677
0 commit comments