我试图让这个工作,但似乎找不到解决方案.我正在寻找运行ID = 3的现有数据流配置文件,并且已经配置了导入文件名.


我所做的所有研究都会导致以下代码的一些变化:
public function importProducts($profile_id = 3)
{
require_once('../app/Mage.php');
Mage::app()->setCurrentStore(Mage_Core_Model_App::ADMIN_STORE_ID);
// Instantiate a session for the "root" user.
$userModel = Mage::getModel('admin/user');
$userModel->setUserId(0);
Mage::getSingleton('admin/session')->setUser($userModel);
// Load the dataflow profile.
$profile = Mage::getModel('dataflow/profile');
$profile->load($profile_id);
if (!$profile->getId()) {
exit("Profile with id #{$profile_id} does not exist.");
}
$profile->run();
$batchModel = Mage::getSingleton('dataflow/batch');
// Reporting.
$direction = ucwords($profile->getDirection());
$success = "{$direction} with id #{$batchModel->getId()} completed succesfully.\n";
echo $success;
return true;
}
Run Code Online (Sandbox Code Playgroud)
从Magento后端运行有问题的配置文件(ID = 3)可以很好地工作,似乎无法从上面的PHP函数中触发它.
我正在寻找一种以编程方式触发"导入所有产品"数据流配置文件的方法.
我遇到的其他帖子,问题和网站却没有成功:
任何和所有的帮助将不胜感激!
谢谢!