I'm trying to write a magento module for importing products from a csv file. I would like to use Magmi to achieve the import. I tried the following code but it doesn't work:
namespace My\Module\Controller\Adminhtml\Home;
require_once(dirname(__FILE__) . "/../../../../../../../lib/magmi/inc/magmi_defs.php");
require_once(dirname(__FILE__) . "/../../../../../../../lib/magmi/integration/inc/magmi_datapump.php");
class Import extends \Magento\Backend\App\Action{
public function execute()
{
// getting data from a casv file
for ($items as $item){
$dp = Magmi_DataPumpFactory::getDataPumpInstance("productimport");
$dp->beginImportSession("default", "xcreate");
$item = "product field array";
$run = $dp->ingest($item);
$dp->endImportSession();
}
}
}
I receive errors on the Magmi classes "class not found". I tried also different code but the only way a think it can works is using class file named, e.g. Datapump.php with e defined class named Datapump. But I cannot rewrite all files of magmi to make it works, so maybe I'm doing something wrong.
I hope someone of you knows how to do this.
Thanks