I'm working on one module. module does read CSV file from var/import and making a call to Magmi to import.


namespace Test\Import\Controller\Adminhtml\Customimport;
class RunQuickImport extends \Magento\Backend\App\Action
public function execute()
    $csv_data =readcsv file ;
    foreach($csv_data as $row){
       $dp = Magmi_DataPumpFactory::getDataPumpInstance("productimport");
       $dp->beginImportSession("default", "xcreate");
       $item = "product field array";
       $run = $dp->ingest($item);

Question is How to include Magmi file in controller ?

I had tried using following.

require_once '/public_html/magmi/inc/magmi_defs.php';
require_once '/public_html/magmi/integration/inc/magmi_datapump.php';

but not working

  • 1
    Did you have any solution? – Sanket Makavana Dec 26 '18 at 9:50
  • 1
    yes you can add same code in top of module's registration.php file. – Abdul Kadir Dec 26 '18 at 9:51

You can include magmi file in your controller like Below:

require_once(dirname(__FILE__) . "/../../../../../magmi/inc/magmi_defs.php");
require_once(dirname(__FILE__) . "/../../../../../magmi/integration/inc/magmi_datapump.php");

Below Code use in top of module's registration.php file.

require_once BP . "/magmi/plugins/inc/magmi_datasource.php";
require_once BP . "/magmi/integration/inc/productimport_datapump.php";

In Class file.

 $dp = new \Magmi_ProductImport_DataPump();
 $dp->beginImportSession("default", 'magmi mode');

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.