I have a cronjob that imports product data. This can take up to 40 minutes. Is there a way to notify the admin user who is logged in?

I don't want the admin users to manually edit products during the import.

The notification messages require a page refresh or new login, so they are not suitable.

The admin user should be able to navigate around the admin area or leave the configuration area of the module and still be notified.

1 Answer 1


I did same thing in my one of site. Created Custom table and add one record in table when cron job is start(in top of cron) with status 0

and in end of cron code added code for update status 1 or delete that record from table.

now add one observer



<?xml version="1.0"?>
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:Event/etc/events.xsd">
    <event name="controller_action_postdispatch">
        <observer name="message_display_observer" instance="Vendor\Module\Observer\CustomMessage" />




namespace Magebees\Finder\Observer;

class CustomMessageimplements \Magento\Framework\Event\ObserverInterface

   protected $messageManager;
   protected $_responseFactory;
   protected $_url;

    public function __construct(\Magento\Framework\Message\ManagerInterface $messageManager,
    \Magento\Framework\App\ResponseFactory $responseFactory,
    \Magento\Framework\UrlInterface $url,
    \Magento\Framework\App\ResourceConnection $resource
       $this->messageManager = $messageManager;
       $this->_responseFactory = $responseFactory;
       $this->_url = $url;
       $this->connection = $resource->getConnection();


   public function execute(\Magento\Framework\Event\Observer $observer)
      $objectManager =  \Magento\Framework\App\ObjectManager::getInstance();        
      $request = $objectManager->get('\Magento\Framework\App\Request\Http');
      if($request->getFullActionName() != 'adminhtml_auth_login'){
            $finderToImport = $this->connection->fetchAll('SELECT * FROM digital_finder_import 
                                        WHERE status =  0 ');

            $finderToImportCount = count($finderToImport);
            if($finderToImportCount > 0){
                $message = "Records are being updated, it may take time to update all.";
            /*$cartUrl = $this->_url->getUrl();

it will show message in every pages in admin. so, admin can understand cron is running. when cron complete message will no longer visible :)

I hope it helps you :)

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.