1. Go to this page and download the library: Download hirale/queue library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
hirale / queue example snippets
use Hirale\Queue\Bus;
Bus::dispatch(new DrainEventsMessage(reason: 'index_events'));
use Hirale\Queue\Bus;
class Hirale_AsyncIndex_Helper_Data extends Mage_Core_Helper_Abstract
{
public function scheduleDrain(string $reason): void
{
Bus::dispatch(new Hirale_AsyncIndex_Message_DrainEventsMessage(
reason: $reason,
entity: 'catalog_product',
));
}
}
// Route this dispatch to a non-default queue.
Bus::dispatchOnQueue($message, 'full_reindex');
// Delay the first attempt by N seconds.
Bus::dispatchDelayed($message, 60);
class Hirale_AsyncIndex_Model_DrainEventsHandler
{
public function __invoke(Hirale_AsyncIndex_Message_DrainEventsMessage $message): void
{
// Do the work. Throwing reschedules per the retry policy.
Mage::getModel('hirale_asyncindex/runner')->drain($message->reason);
}
}