I want to synchronise M2epro inventory with Magento 2.

Tutorial link - https://docs.m2epro.com/display/BestPractice/Programmatic+Possibilities+to+work+with+Extension

M2epro Git Location - https://github.com/m2epro/magento2-extension

Original Code -

    $this->modelFactory instanceof \Ess\M2ePro\Model\Factory
    $model = $this->modelFactory->getObject('PublicServices\Product\ObjectChange');

How can create above objects ?

Below is my code

$objectManager = \Magento\Framework\App\ObjectManager::getInstance();
//$helperFactory = $objectManager->create('\Ess\M2ePro\Helper\Factory');
$modelFactory = $objectManager->create('\Ess\M2ePro\Model\Factory');
$model = $modelFactory->create('\Ess\M2ePro\PublicServices\Product\ObjectChange');
$product = $objectManager->create('Magento\Catalog\Model\Product')->load($id);

Now here when I am trying to write tutorial code by creating object I am getting error that Uncaught Error: Call to undefined method Ess\M2ePro\Helper\Factory::create()

Can anyone please suggest how we can solve this ?

  • This is third party module issue, better report to developer and they will provide you the support. Regarding issue, search how to call a helper file and the issue will be resolved.
    – MTM
    Feb 23, 2018 at 6:01
  • I just want to know how I can create object using this code as per magento standards? please check update question.
    – Rohit
    Feb 23, 2018 at 6:02
  • Magento standards are different than your approach, create a class of your own, initiate both the helper and model classes in constructor function and create objects of both. then use those objects in your custom functions.
    – MTM
    Feb 23, 2018 at 6:06
  • I dont want to create a class, constructor for this. its just one time php script.
    – Rohit
    Feb 23, 2018 at 6:09
  • check the answer and try, if it works then vote and accept the answer.
    – MTM
    Feb 23, 2018 at 6:13

1 Answer 1


Not a preferred approach but you insist so you should replace the helper code with following:

$helperFactory = $objectManager->get('\Magento\Core\Model\Factory\Helper');
$helper = $helperFactory->get('\Ess\M2ePro\Helper\Factory');
  • Hi, this is not working. Please check $this->modelFactory instanceof \Ess\M2ePro\Model\Factory $model = $this->modelFactory->getObject('PublicServices\Product\ObjectChange'); $model->observeProduct(561); $model->applyChanges();
    – Rohit
    Feb 23, 2018 at 6:16
  • The above solution was to resolve the error you mentioned: Uncaught Error: Call to undefined method Ess\M2ePro\Helper\Factory::create()
    – MTM
    Feb 23, 2018 at 6:20
  • but it is showing error now Uncaught Error: Class 'Magento\Core\Model\Factory\Helper' not found
    – Rohit
    Feb 23, 2018 at 9:32

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.