As the part of creating bundle product programmatically in Magento 2. I am getting below error. Even i removed var/cache and generation.

This may be a duplicate question but none of the answer is working for this issue.

Fatal error: Cannot instantiate interface Magento\Catalog\Api\Data\ProductExtensionInterface in \ObjectManager\Factory\Dynamic\Developer.php on line 73

Used below code as the reference of link

$productExtension = $objectManager->create(\Magento\Catalog\Api\Data\ProductExtensionInterface::class);
$option = $objectManager->create(\Magento\Bundle\Api\Data\OptionInterface::class);

I am using object manager for temporary/quick purpose, will convert the object manager to constructor injunction.

Any one can help me on this issue.

6 Answers 6


I think you have not mentioned the preference in your di.xml. I also faced the same issue when I was creating custom config xml file module.

I got the issue when I called this code:

$testConfig = $this->_objectManager->get('Training\Test\Model\Config\ConfigInterface');
$myNodeInfo = $testConfig->getMyNodeInfo();

Below is the sample code I have added in my di.xml, may be it may help you to get reference:

<preference for="Training\Test\Model\Config\ConfigInterface" type="Training\Test\Model\Config" />

Here I have implemented the interface in Training\Test\Model\Config class and my getMyNodeInfo() method is defined in that Model.

So based on the the preference defined in di.xml the code ->get('Training\Test\Model\Config\ConfigInterface'); will create an object of type Training\Test\Model\Config.

  • its worked for me, Dont user _objectManager
    – matinict
    Jan 10, 2021 at 9:42

I struggled with this and then found a solution that worked for me in the documention.

Be sure to add your interface as a preference (correctly) in the di.xml.

  • 2
    My problem was that I placed the di.xml in the etc/frontend folder instead of the etc root by accident, but your answer led me to find that.
    – KyleBunga
    May 2, 2019 at 17:30

You should not use the ObjectManager.

Collect your dependencies via _constructor.

In case your interface still won't be loaded, check your di.xml and validate that a preference is available.

  • @ David Lambauer Even i used constructor i am getting Cannot instantiate interface Magento\Catalog\Api\Data\ProductExtensionInterface in magento\framework\ObjectManager\Factory\Dynamic\Developer.php on line 73 Oct 13, 2016 at 10:15
  • 1
    Did you add the factory to your use statements? use Magento\Catalog\Api\Data\ProductExtensionInterfaceFactory; Oct 13, 2016 at 11:24

Please make sure module is enabled. You can verify using {{MagentoRoot}}/app/etc/config.php file. In my case module was disabled.


I tried this mentioned in another thread but it didn't solve:

redis-cli flushall

Finally, got solved by running setup:upgrade:

bin/magento setup:upgrade

# also run, if in production mode
bin/magento setup:static-content:deploy
bin/magento setup:di:compile

I have faced the similar issue i.e. cannot instantiate interface for some third party module.
The reason that I found out after debugging that the corresponding module's entry was missing from the app/etc/config.php but the module's code was present in the codebase.
After manually adding the module's entry in the app/etc/config.php file, the issue got resolved.

  • There is no such a file app/etc/config.xml in M2
    – medina
    Jun 3, 2020 at 2:41
  • @medina it's config.php, I have updated my answer. Jun 3, 2020 at 4:16

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.