我找到答案。如果要運行導入配置文件,則應在$profile->run();
之後使用此代碼:
$batchModel = Mage::getSingleton('dataflow/batch');
$batchImportModel = $batchModel->getBatchImportModel();
$adapter = $batchModel->getAdapter();
$importIds = $batchImportModel->getIdCollection();
foreach ($importIds as $importId) {
$batchImportModel->load($importId);
try {
$importData = $batchImportModel->getBatchData();
Mage::getModel($adapter)->saveRow($importData);
} catch (Exception $e) {
Mage::log("Exception : " . $e);
continue;
}
}
if (method_exists($adapter, 'getEventPrefix')) {
// Event to process rules relationships after import
Mage::dispatchEvent($adapter->getEventPrefix() . '_finish_before', array(
'adapter' => $adapter
));
// Clear affected ids for possible reuse
$adapter->clearAffectedEntityIds();
}