magento cron in backend configuration

后端 未结 3 866
無奈伤痛
無奈伤痛 2020-12-13 21:33

So I know how to setup a cron using the config.xml crontab stuff:


    
        
            

        
3条回答
  •  情歌与酒
    2020-12-13 22:31

    A proof of concept. Modify to your needs:

    getGroupId();
    
            $cronStringPath = 'crontab/jobs/company_export_send_' . $groupId . '/schedule/cron_expr';
            $cronModelPath = 'crontab/jobs/company_export_send_' . $groupId . '/run/model';
    
            $value = $this->getData('groups/' . $groupId . '/fields/cron_setting/value');
    
            Mage::getModel('core/config_data')
            ->load($cronStringPath, 'path')
                ->setValue($value)
                ->setPath($cronStringPath)
                ->save();
            Mage::getModel('core/config_data')
                ->load($cronModelPath, 'path')
                ->setValue((string) Mage::getConfig()->getNode($cronModelPath))
                ->setPath($cronModelPath)
                ->save();           
    
        }
    }
    

    and the config.xml:

    
    
    
        
            
                0.1.0
            
        
        
            
                
                    Company_Export_Model
                
            
            
                
                    Company_Export_Helper
                
            
            
                
                    
                        Company_Export
                    
                    
                        core_setup
                    
                
                
                    
                        core_write
                    
                
                
                    
                        core_read
                    
                
            
        
         
             
                 
                     
                         
                             
                                 
                                     
                                         
                                             
                                                Order Export Configuration 
                                             
                                         
                                     
                                 
                             
                         
                     
                 
             
        
        
                            
                
                    company_export/observer::exportOrderData
                
            
        
    
    

    and system.xml:

    
    
    
        
            
                
                99999
            
        
        
            
                
                feedsconfig
                text
                10000
                1
                0
                0
                
                    
                        
                        text
                        2
                        1
                        0
                        0
                        
                             
                                
                                text
                                company_export/config_cron
                                40
                                Use Crontab Format (Eg. "*/5 * * * *" for every 5 minutes)
                                1
                                0
                                0
                            
                        
                    
                
            
        
    
    

提交回复
热议问题