Magento Forum

Calling controller action from observer fired thru cron job
 
Pierre SII
Jr. Member
 
Total Posts:  25
Joined:  2008-12-19
Nice, France
 

Hi community,

I searched into the frorum but did not find any answer to my problem.

I’d like to call a controller action from an observer fired by a cron job.

The cron job is well set (sucess status into cron job log table).

I’m trying to call the controller action by the following observer code, but nothing happen:
(app/code/local/Corp/Adminhtml/Model/Sales/Order/Observer.php)

class Corp_Adminhtml_Model_Sales_Order_Observer
{

    
public function exportToSage($observer null)
    
{
        
require_once '/var/www/magento/app/Mage.php';
        
umask(0);
        
Mage::app(); 
        
Mage::getSingleton('core/session', array('name'=>'adminhtml'));
        echo 
Mage::helper('adminhtml')->getUrl('*/sales_order_export/exportToSage');
        
Mage::app()->getResponse()->setRedirect(Mage::helper('adminhtml')->getUrl('*/sales_order_export/exportToSage')); 
        return;
    
}
}

PROBLEM: The getUtl method returns the following url : http://www.mysho.com/Observer.php/

I tried many code with no success…

The controller action works fine when calling it from a customized button added to the adminhtml sales grid screen.

Here the config.xml file of my customized Adminhtml module:
(app/code/local/Corp/Adminhtml/etc/config.xml)

<config>
    <
modules>
        <
Corp_Adminhtml>
            <
version>0.1.0</version>
        </
Corp_Adminhtml>
    </
modules>
    
        <global>
                <
models>
            <
corpadminhtml>
                 <class>
Corp_Adminhtml_Model</class>
            </
corpadminhtml>
                </
models>
                <
rewrite>
                        <
corp_adminhtml_export_exportToSage>
                              <
from><![CDATA[#^/admin/sales_order_export/exportToSage/$#]]></from>
                              
<to>/corp_admin/sales_order_export/exportToSage</to>
                       </
corp_adminhtml_export_exportToSage>
                 </
rewrite>
       </global>
    <
admin>
        <
routers>
            <
corp_adminhtml>
                <!-- 
should be set to "admin" when overloading admin stuff (?) -->
                <use>
admin</use>
                <
args>
                    <
module>Corp_Adminhtml</module>
                    <!-- 
This is used when "catching" the rewrite above -->
                    <
frontName>corp_admin</frontName>
                </
args>
            </
corp_adminhtml>
        </
routers>
    </
admin>
       <
crontab>
        <
jobs>
            <
sales_order_export_sage>
                <
schedule><cron_expr>*/* * * *</cron_expr></schedule>
                <
run><model>corpadminhtml/sales_order_observer::exportToSage</model></run>
            </
sales_order_export_sage>
        </
jobs>
    </
crontab>
</
config>

Thanks in advance for your help.

Cheers,

Pierre

 
Magento Community Magento Community
Magento Community
Magento Community
 
Pierre SII
Jr. Member
 
Total Posts:  25
Joined:  2008-12-19
Nice, France
 

no clue about this ? :(

 
Magento Community Magento Community
Magento Community
Magento Community
 
Pierre SII
Jr. Member
 
Total Posts:  25
Joined:  2008-12-19
Nice, France
 

maou…

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