cancel
Showing results for 
Search instead for 
Did you mean: 

Stock Alert send frequency

Stock Alert send frequency

Hello Magento Community

I would like to run the stock alert emails every 5 minutes. It looks like it is not possible to configuration in Stores > Settings > Configuration >Catalog > Catalog > Product Alerts Run Settings

 

Is there any possibility to run the cron from shell instantly? We are currently testing the stock alerts and dont want to wait always 24 hours, until sent. 

stock_alert_settings.PNG

Thanks for your help
Stefan

5 REPLIES 5

Re: Stock Alert send frequency

Hi @silverzone ,

 

For changing the frequency of Products Stock Alert cron, you need to create a custom module with new crontab.xml

 

<group id="default">
<job name="catalog_product_alert_custom" instance="Magento\ProductAlert\Model\Observer" method="process">
<schedule>*/5 * * * *</schedule>
</job>
</group>

 

Hope it helps you!

Problem Solved! Click Kudos & Accept as Solution!

Re: Stock Alert send frequency

Hi @Nishu Jindal ,

using this getting error in cron job "No such entity with customerId = 0" . Let me know how to fix this error ?

Re: Stock Alert send frequency

Hi @balsingh  and @silverzone ,

 

In the database, can you please check the table with the name 'product_alert_stock'. Check if in the table you have any entry with customer_id = 0.

if there is any entry with customer Id = 0, try to delete the records (because Customer Id 0 Customer should not be there)

Please take a backup before modifying the database.

 

Hope this helps you!

Problem Solved! Click Kudos & Accept as Solution!

Re: Stock Alert send frequency

Hi @Nishu Jindal ,

 

Thanks It works, I wolud like to change if Products having quantity 0 and also enabled for backorders , on those products I don't want to send stock alert e-mail to customers 

 

I am using a preference but it not working :
<preference for="Magento\ProductAlert\Model\Observer" type="Vendor\Modulename\Model\Observer"/>

like this :

<?php
class Observer extends \Magento\ProductAlert\Model\Observer
{
protected function _processStock(\Magento\ProductAlert\Model\Email $email)
{

}

}

But its not working . Please let me know the solution for this.

Re: Stock Alert send frequency

Hi @balsingh,

 

I hope you have created the di.xml on below path in your module.

app/code/Vendor/Modulename/etc/di.xml

 

After creating di.xml and file you have di compile command as well.if not please run that as well.

rm -rf generated/*

php bin/magento s:d:c

 

Please add one log entry in your observer file.just to confirm whether it is working or not.

 

Hope this helps you!

Problem Solved! Click Kudos & Accept as Solution!