magento: is there a way to “run profile” with cron?

后端 未结 3 1363
陌清茗
陌清茗 2021-01-25 11:27

I have an export profile on magento 1.6 and I can run it manually (\"Run profile in popup\"), but I need it to run automatically every day. Is there a way to set up a cron job t

3条回答
  •  庸人自扰
    2021-01-25 12:08

    I used the following taken from (note: broken link, code is copied below):

    http://www.premasolutions.com/content/magento-dataflow-exportimport-form-command-line

    setCurrentStore(Mage_Core_Model_App::ADMIN_STORE_ID);
      
    $profile = Mage::getModel('dataflow/profile');
    $userModel = Mage::getModel('admin/user');
    $userModel->setUserId(0);
    Mage::getSingleton('admin/session')->setUser($userModel);
    $profile->load($profileId);
    if (!$profile->getId()) {
        Mage::getSingleton('adminhtml/session')->addError('ERROR: Incorrect profile id');
    }
      
    Mage::register('current_convert_profile', $profile);
    $profile->run();
    $recordCount = 0;
    $batchModel = Mage::getSingleton('dataflow/batch');
    echo "EXPORT COMPLETE. BATCHID: " . $batchModel->getId();
    

    It worked properly on 1.5.x (not tested yet on 1.6.x, sorry).

    If it works, it's only matter of scheduling a cron job to call the script automatically.

    Regards, Alessandro

提交回复
热议问题