How to setup cron job in magento? -


i working on magento 1.7.0.2 version.

i want send csv in mails customers. should done every month using cron job in magento.

for cron job config.xml

<crontab>     <jobs>         <module_store>             <schedule><cron_expr>0,15,30,45 * * * *</cron_expr></schedule>             <run><model>clinic/observer::sendmailtoclinic</model></run>         </module_store>     </jobs> </crontab>     

observer.php

class module_store_model_observer {    public function sendmailtoclinic(varien_event_observer $observer, $content){                             $mail = new zend_mail();     $mail->settype(zend_mime::multipart_related);     $mail->setbodyhtml($html_body);     $mail->setfrom($from_email, $from_email_name);     $mail->addto($to_email, $toemailname);     $mail->setsubject($subject);     $file = $mail->createattachment(file_get_contents($file_path));     $file->type = 'text/csv';     $file->disposition = zend_mime::disposition_inline;     $file->encoding = zend_mime::encoding_base64;     $file->filename = $file_name;     $mail->send();   } } 

admin configuration cron :-

generate schedules every 15 schedule ahead 15 missed if not run within 35 history cleanup every 15 success history lifetime 10 failure history lifetime 600 

any appreciable.

if mail system working fine , still facing issue try 1 also:

replace config code this:

<crontab>     <jobs>         <clinic_cron>             <schedule><cron_expr>0,15,30,45 * * * *</cron_expr></schedule>             <run><model>clinic/observer::sendmailtoclinic</model></run>         </clinic_cron>     </jobs> </crontab>    class [packagename]_clinic_model_observer { // don't forget mention package name    public function sendmailtoclinic(varien_event_observer $observer){                              $html_body = 'this html body text';     $from_email = 'from_email@domain.com';     $from_email_name = 'sendername';     $to_email = 'to_email@domain.com';     $toemailname = 'receivername';     $subject = 'subject text here';     $file_path = 'here/is/file/path';     $file_name = 'filename.csv';      $mail = new zend_mail();     $mail->settype(zend_mime::multipart_related);     $mail->setbodyhtml($html_body);     $mail->setfrom($from_email, $from_email_name);     $mail->addto($to_email, $toemailname);     $mail->setsubject($subject);     $file = $mail->createattachment(file_get_contents($file_path));     $file->type = 'text/csv';     $file->disposition = zend_mime::disposition_inline;     $file->encoding = zend_mime::encoding_base64;     $file->filename = $file_name;     $mail->send();   } } 

search word "clinic_cron" in scheduled tasks tasks list here : system > scheduler > list view. make sure searching scheduled tasks, mean see paging ;)

hope helps! best!


Comments

Popular posts from this blog

how to proxy from https to http with lighttpd -

android - Automated my builds -

python - Flask migration error -