protected function _beforeSave()
    {
        if (!$this->getScheduledBy() && php_sapi_name() !== 'cli' && Mage::getSingleton('admin/session')->isLoggedIn()) {
            $this->setScheduledBy(Mage::getSingleton('admin/session')->getUser()->getId());
        }

        $collection = Mage::getModel('cron/schedule')/* @var $collection Mage_Cron_Model_Resource_Schedule_Collection */
            ->getCollection()
            ->addFieldToFilter('status', Aoe_Scheduler_Model_Schedule::STATUS_PENDING)
            ->addFieldToFilter('job_code', $this->getJobCode())
            ->addFieldToFilter('scheduled_at', $this->getScheduledAt());
        if ($this->getId() !== null) {
            $collection->addFieldToFilter('schedule_id', array('neq' => $this->getId()));
        }
        $count = $collection->count();
        if ($count > 0) {
            $this->_dataSaveAllowed = false; // prevents this object from being stored to database
            $this->log(sprintf('Pending schedule for "%s" at "%s" already exists %s times. Skipping.', $this->getJobCode(), $this->getScheduledAt(), $count));
        } else {
            $this->_dataSaveAllowed = true; // allow the next object to save (because it's not reset automatically)
        }
        return parent::_beforeSave();
    }
protected function _beforeSave()
    {
        if (!$this->getScheduledBy() && php_sapi_name() !== 'cli' && Mage::getSingleton('admin/session')->isLoggedIn()) {
            $this->setScheduledBy(Mage::getSingleton('admin/session')->getUser()->getId());
        }

        $collection = Mage::getModel('cron/schedule')/* @var $collection Mage_Cron_Model_Resource_Schedule_Collection */
            ->getCollection()
            ->addFieldToFilter('status', Aoe_Scheduler_Model_Schedule::STATUS_PENDING)
            ->addFieldToFilter('job_code', $this->getJobCode())
            ->addFieldToFilter('scheduled_at', $this->getScheduledAt());
        if ($this->getId() !== null) {
            $collection->addFieldToFilter('schedule_id', array('neq' => $this->getId()));
        }
        $count = $collection->count();
        if ($count > 0) {
            $this->_dataSaveAllowed = false; // prevents this object from being stored to database
            $this->log(sprintf('Pending schedule for "%s" at "%s" already exists %s times. Skipping.', $this->getJobCode(), $this->getScheduledAt(), $count));
        } else {
            $this->_dataSaveAllowed = true; // allow the next object to save (because it's not reset automatically)
        }
        return parent::_beforeSave();
    }
protected function _beforeSave ( ) { if ( ! $ this -> getScheduledBy ( ) && php_sapi_name ( ) !== 'cli' && Mage :: getSingleton ( 'admin/session' ) -> isLoggedIn ( ) ) { $ this -> setScheduledBy ( Mage :: getSingleton ( 'admin/session' ) -> getUser ( ) -> getId ( ) ) ; } $ collection = Mage :: getModel ( 'cron/schedule' ) /* @var $collection Mage_Cron_Model_Resource_Schedule_Collection */ -> getCollection ( ) -> addFieldToFilter ( 'status' , Aoe_Scheduler_Model_Schedule :: STATUS_PENDING ) -> addFieldToFilter ( 'job_code' , $ this -> getJobCode ( ) ) -> addFieldToFilter ( 'scheduled_at' , $ this -> getScheduledAt ( ) ) ; if ( $ this -> getId ( ) !== null ) { $ collection -> addFieldToFilter ( 'schedule_id' , array ( 'neq' => $ this -> getId ( ) ) ) ; } $ count = $ collection -> count ( ) ; if ( $ count > 0 ) { $ this -> _dataSaveAllowed = false ; // prevents this object from being stored to database $ this -> log ( sprintf ( 'Pending schedule for "%s" at "%s" already exists %s times. Skipping.' , $ this -> getJobCode ( ) , $ this -> getScheduledAt ( ) , $ count ) ) ; } else { $ this -> _dataSaveAllowed = true ; // allow the next object to save (because it's not reset automatically) } return parent :: _beforeSave ( ) ; }
Processing object before save data

Check if there are other schedules for the same job at the same time and skip saving in this case.

@return Mage_Core_Model_Abstract
Processing object before save data