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

Modul Magento ce implica Cron Jobs
 
raresp
Jr. Member
 
Total Posts:  15
Joined:  2012-07-09
 

Am modulul CronScript si namespace Pascut, deci am pus asta in config.xml:

<crontab>
<jobs>
<pascut_cronscript>
<schedule><cron_expr>*/15 * * * *</cron_expr></schedule>
<run><model>cronscript/observer::sendEmail</model></run>
</pascut_cronscript>
</jobs>
</crontab>

este corect sau gresit?

Primesc eroarea urmatoare:

exception ‘Mage_Core_Exception’ with message ‘Invalid callback: cronscript/observer::sendEmail does not exist’ in /home/zzz/public_html/magento/app/Mage.php:594 Stack trace: #0 /home/zzz/public_html/magento/app/code/core/Mage/Cron/Model/Observer.php(93): Mage::throwException(’Invalid callbac...’) #1 /home/zzz/public_html/magento/app/code/core/Mage/Core/Model/App.php(1338): Mage_Cron_Model_Observer->dispatch(Object(Varien_Event_Observer)) #2 /home/zzz/public_html/magento/app/code/core/Mage/Core/Model/App.php(1317): Mage_Core_Model_App->_callObserverMethod(Object(Mage_Cron_Model_Observer), ‘dispatch’, Object(Varien_Event_Observer)) #3 /home/zzz/public_html/magento/app/Mage.php(447): Mage_Core_Model_App->dispatchEvent(’default’, Array) #4 /home/zzz/public_html/magento/cron.php(46): Mage::dispatchEvent(’default’) #5 {main}

Am legatura urmatoare:  magento/app/code/community/Pascut/CronScript

Pascut este Namespace , iar CronScript este numele modulului.
In CronScript am asa:  Block, controllers, etc, Helper, Model si sql

In Model am Observer.php, care contine functia sendEmail :

<?php
include(BP DS '/app/design/adminhtml/default/default/template/pascut/config.php');
class 
Pascut_CronScript_Model_Observer
{
    $email 
$mail;
    public function 
sendEmail()
    
{

        
        mail
($email"Cron Script Mail""Functioneaza");
        
//}
 
        
return $this;
    
}
}
?>

in acel config.php imi definesc un email, si apelul cu include e verificat si merge sigur.
Ce poate fi gresit de nu merge cron jobul?

 
Magento Community Magento Community
Magento Community
Magento Community
 
tzyganu
Mentor
 
Avatar
Total Posts:  2205
Joined:  2009-11-18
Bucharest, Romania
 

Salut
Cum arata fisierul de config.xml al modulului tau?
Ce ai facut pare corect, cronul incearca sa ruleze dar nu gaseste modelul de rulat.

Marius.

 
Magento Community Magento Community
Magento Community
Magento Community
 
raresp
Jr. Member
 
Total Posts:  15
Joined:  2012-07-09
 

Uite aici ce am facut pana acuma.
Nu merge cron jobs.
Incerc sa salvez datele in baza de date, odata completat un formular.
Se poate direct din controller?
Respect astfel MVC?

File Attachments
CronJobs.zip  (File Size: 12KB - Downloads: 52)
 
Magento Community Magento Community
Magento Community
Magento Community
 
tzyganu
Mentor
 
Avatar
Total Posts:  2205
Joined:  2009-11-18
Bucharest, Romania
 

Daca vrei sa creezi un modul cu entitati custom cu propria tabela ai putea folosi http://www.magentocommerce.com/magento-connect/modulecreator.html:
Chiar daca e compatibil doar cu 1.3 merge in mare parte si pentru variante mai noi de Magento.
Ar trebui sa iti creeze un modul in care sa poti salva entitati custom, dupa care poti adauga tu diferite alte functionalitati.

 
Magento Community Magento Community
Magento Community
Magento Community
 
raresp
Jr. Member
 
Total Posts:  15
Joined:  2012-07-09
 

am rezolvat problema cu baza de date, se preiau si se salveaza datele din formular in baza de date
cron jobul nu functioneaza
si nu imi dau seama de ce, probabil nu dau bine calea..

<crontab>
           <
jobs>
              <
mage_sintax>
                  <
schedule><cron_expr>*/12 * * * *</cron_expr></schedule>
                  <
run><model>sintax/observer::sendEmail</model></run>
              </
mage_sintax>
           </
jobs>
        </
crontab>

Namespace este: Mage
Modulul este: Sintax
(am facut modulul dupa ceva tutorial si de aia au numele astea)

Din ce am vazut aici: http://www.magentocommerce.com/wiki/1_-_installation_and_configuration/how_to_setup_a_cron_job

ar trebui sa folosesc structura: <jobs><namespace_module>
e corect?
si la partea cu run nu sunt sigur, eu am vazut pe site-ul ala ca trebuie sa fie: <model>modul/model::metoda</model>
eu asa am facut..
te rog sa-mi spui daca e ok

 
Magento Community Magento Community
Magento Community
Magento Community
 
tzyganu
Mentor
 
Avatar
Total Posts:  2205
Joined:  2009-11-18
Bucharest, Romania
 

Pare ok ce ai facut. Nu imi dau seama care ar putea fi problema.
Poti incerca asta ca sa vezi daca nu e configurat corect cronul sau daca problema e la rularea lui.
Creaza un fisier cu continutul asta in root-ul aplicatiei. (pe acelasi nivel cu index.php). Sa denumim fisierul test.php

<?php
ini_set
('display_errors'1);
error_reporting(E_ALL);
require 
'app/Mage.php';
Mage::app();
Mage::getModel('sintax/observer')->sendEmail();
si apeleaza-l in browser. (http://mysite.com/test.php)
Daca functioneaza atunti inseamna ca nu e corect codul pentru setarea cronului.
Daca nu funcioneaza inseamna ca modelul in sine e gresit.
 
Magento Community Magento Community
Magento Community
Magento Community
 
raresp
Jr. Member
 
Total Posts:  15
Joined:  2012-07-09
 

mersi mult
aveam ceva greseala in pagina Observer.php

 
Magento Community Magento Community
Magento Community
Magento Community
Magento Community
Magento Community
Back to top