Posting in the Magento forums has been disabled pending the implementation of a new and improved forum solution which should better serve the community.

For new questions please post at magento.stackexchange.com, the community-run support site for the Magento community. We will be providing updates on the new forum solution soon. For questions or concerns please email community@magento.com.

Magento Forum

Custom module with Cron
 
benippon-francois
Member
 
Total Posts:  51
Joined:  2009-01-15
 

Hello,

I created a module to change everyday day a discount rule, the script works when I do lanch it explicitely but I don’t succeed to “cron” it…
Here my config.xml:

<?xml version="1.0" encoding="UTF-8"?>
<config>
   <
modules>
      <
BeNippon_UpdateRules>
         <
version>0.1.0</version>
      </
BeNippon_UpdateRules>
   </
modules>
   <
crontab>
      <
jobs>
         <
updateRules_update>
            <
schedule>
               <
cron_expr>*/* * * *</cron_expr>
            </
schedule>
            <
run>
               <
model>updateRules/updater::dailyRulesUpdate</model>
            </
run>
         </
updateRules_update>
      </
jobs>
   </
crontab>
</
config>
(I now for now it’s every 5 minutes but it’s to test...)

My module is called BeNippon_UpdateRules and the method to call is BeNippon_UpdateRules_Model_Updater->dailyRulesUpdate.

Any idea please ? ^^’

Thank you smile

 
Magento Community Magento Community
Magento Community
Magento Community
 
benippon-francois
Member
 
Total Posts:  51
Joined:  2009-01-15
 

Nobody, nothing?
I think this is a pretty common and important task, so if someone knows how to do it would be nice to say, please ^^’

 
Magento Community Magento Community
Magento Community
Magento Community
 
benippon-francois
Member
 
Total Posts:  51
Joined:  2009-01-15
 

Well, sorry to wake up this thread, but I really need to cron some tasks, so if anyone had anyclue about what’s wrong in this xml, it would be wonderful…
Thank you!

 
Magento Community Magento Community
Magento Community
Magento Community
 
back2007
Member
 
Total Posts:  59
Joined:  2009-03-30
 

you can compare you code with newsletter module

<jobs>
<any_name>
<!-- each day -->
<schedule><cron_expr>1 * * * *</cron_expr></schedule>
<run><model>module/observer::methodName</model></run>
</any_name>
</jobs>

and in Observer.php

//....
    public function customerDeleted($observer)
    
{
        $subscriber 
Mage::getModel('newsletter/subscriber')
            ->
loadByEmail($observer->getEvent()->getCustomer()->getEmail());
        if(
$subscriber->getId()) {
            $subscriber
->delete();
        
}
        
return $this;
    

//...
 
Magento Community Magento Community
Magento Community
Magento Community
 
benippon-francois
Member
 
Total Posts:  51
Joined:  2009-01-15
 

Thank you!

But well, that is the point, I don’t see the difference between your extract and my code…

 
Magento Community Magento Community
Magento Community
Magento Community
 
Saggy
Sr. Member
 
Total Posts:  133
Joined:  2009-02-03
 

updateRules/updater - Is this updater or update?

 
Magento Community Magento Community
Magento Community
Magento Community
 
benippon-francois
Member
 
Total Posts:  51
Joined:  2009-01-15
 

Sorry I was not available the last week…

The module is named UpdateRules and the model class Updater. The method used is dailyRulesUpdate

public function dailyRulesUpdate()
   
{
      
//Retrieve catalog rules collection
      
$ruleCollection Mage::getModel('catalogrule/rule')->getCollection();
      
//Select the rule we care about
      
$rule $ruleCollection
         
->getItemByColumnValue('name''Preorder 5% until deadline');

      
//We need the current date to update the good value
      
$now = new Zend_Date();

      
//Seek the interesting field into the contitions
      
foreach($rule->getConditions()->getConditions() as $condition{
         
//If the field is found, change its value
         
if($condition->getData('attribute') == 'release_date'{
            $condition
->setData('value'$now->get('yyyy-MM-dd'));
         
}
      }
      $rule
->save();
   
}
 
Magento Community Magento Community
Magento Community
Magento Community
Magento Community
Magento Community
Back to top