Skip to main content
added 362 characters in body
Source Link
sv3n
  • 11.7k
  • 7
  • 41
  • 73

To get last finished date you can try this:

$tasks = Mage::getModel('cron/schedule')->getCollection()
    ->addFieldToSelect('finished_at')
    ->addFieldToFilter('job_code', 'orders_exportsales')
    ->addFieldToFilter('status', 'success');
$tasks->getSelect()
    ->limit(1)
    ->order('finished_at DESC');

$lastRun = $tasks->getFirstItem()->getFinishedAt();

Bug:

app/code/core/Mage/Cron/Model/Resource/Schedule/Collection.php

Mage::getModel('cron/schedule')->getCollection()
    ->orderByScheduledAt($dir)

Sort direction is always set to ASC ... to fix replace

 $this->getSelect()->order('scheduled_at', $dir);

with

$this->getSelect()->order('scheduled_at ' . $dir);

To get last finished date you can try this:

$tasks = Mage::getModel('cron/schedule')->getCollection()
    ->addFieldToSelect('finished_at')
    ->addFieldToFilter('job_code', 'orders_exportsales')
    ->addFieldToFilter('status', 'success');
$tasks->getSelect()
    ->limit(1)
    ->order('finished_at DESC');

$lastRun = $tasks->getFirstItem()->getFinishedAt();

To get last finished date you can try this:

$tasks = Mage::getModel('cron/schedule')->getCollection()
    ->addFieldToSelect('finished_at')
    ->addFieldToFilter('job_code', 'orders_exportsales')
    ->addFieldToFilter('status', 'success');
$tasks->getSelect()
    ->limit(1)
    ->order('finished_at DESC');

$lastRun = $tasks->getFirstItem()->getFinishedAt();

Bug:

app/code/core/Mage/Cron/Model/Resource/Schedule/Collection.php

Mage::getModel('cron/schedule')->getCollection()
    ->orderByScheduledAt($dir)

Sort direction is always set to ASC ... to fix replace

 $this->getSelect()->order('scheduled_at', $dir);

with

$this->getSelect()->order('scheduled_at ' . $dir);
Post Undeleted by sv3n
Post Deleted by sv3n
Post Undeleted by sv3n
Post Deleted by sv3n
Post Undeleted by sv3n
Post Deleted by sv3n
Source Link
sv3n
  • 11.7k
  • 7
  • 41
  • 73

To get last finished date you can try this:

$tasks = Mage::getModel('cron/schedule')->getCollection()
    ->addFieldToSelect('finished_at')
    ->addFieldToFilter('job_code', 'orders_exportsales')
    ->addFieldToFilter('status', 'success');
$tasks->getSelect()
    ->limit(1)
    ->order('finished_at DESC');

$lastRun = $tasks->getFirstItem()->getFinishedAt();