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.


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.


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 – Krishna ijjada Oct 13 '16 at 10:15
  • 1
    Did you add the factory to your use statements? use Magento\Catalog\Api\Data\ProductExtensionInterfaceFactory; – David Lambauer Oct 13 '16 at 11:24

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

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 '19 at 17:30

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.