Skip to main content
42 votes

Fatal error: Cannot instantiate interface in Magento 2?

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 = $...
user49278's user avatar
  • 421
19 votes

Fatal error: Cannot instantiate interface in Magento 2?

I struggled with this and then found a solution that worked for me in the documentation. Be sure to add your interface as a preference (correctly) in the di.xml, and then run php bin/magento setup:di:...
Tristanisginger's user avatar
12 votes
Accepted

Magento 2 : Override core Interface and Model

Below solution worked for me. As per MIKE suggested we can't directly override magento's core interfaces. So than there's comes role of Extension Attributes. etc/extension_attributes.xml <?...
anonymous's user avatar
  • 3,752
10 votes
Accepted

How to sort by position field

You will need to add sort order to search criteria Add \Magento\Framework\Api\SortOrderBuilder $sortOrderBuilder as dependency in constructor. public function getCollection() { $...
Prachi Saxena's user avatar
10 votes

Magento 2 : Override core Interface and Model

Magento 2 Preference does not allow us to override the interfaces. Preferences are used to specify the implementation classes for the interfaces and overriding implementation classes. It does not ...
Mike's user avatar
  • 1,148
10 votes

Fatal error: Cannot instantiate interface in Magento 2?

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's user avatar
7 votes

What is IdentityInterface in Magento2

The  IdentityInterface  will  force  Model  class  to  define  the  ​getIdentities()  method which  will return a unique id for the model. You must only use this interface if your model required cache ...
AlexanderPop's user avatar
6 votes
Accepted

Uncaught Error: Cannot instantiate interface Magento\\InventoryReservationsApi\\Model\\GetReservationsQuantityInterface

If you use redis, run: redis-cli flushall or you'll need to run the following commands: Clear generated Clear var/cache Enable Magento modules: php bin/magento module:enable --all Compile DI php ...
Muhammad Hasham's user avatar
6 votes
Accepted

Magento 2 - "Property \"Slider\" does not have corresponding setter in class "Magento\\Eav\\Api\\Data\\AttributeOptionInterface\"."

To resolve this issue, We require to override mainly two interfaces and model. After overriding interfaces and model, Overrided interfaces requires binding with model using di.xml to initiate objects ...
Hitarth Pattani's user avatar
5 votes

Fatal error: Cannot instantiate interface in Magento 2?

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 ...
Mukesh Chapagain's user avatar
4 votes

Magento2 API must use fully qualified namespaces?

After a research, finally find the source in my memory, it is in official develop guide Configure services as web APIs. For SOAP and REST to work correctly, the following rules must be followed by ...
Key Shang's user avatar
  • 3,445
4 votes
Accepted

How to resolve this error in magento 2?

Use logger as following. $logger = $context->getLogger(); And remove \Psr\Log\LoggerInterface from your constructor. This is because context object already contains logger interface.
Kishan Patadia's user avatar
3 votes
Accepted

Magento2.2.5 - getting error

I guess you are using Magento\Framework\App\Action\HttpPostActionInterface in your controller? As I see, Magento 2.3.x has this interface class, but it doesn't exist in lowser version 2.2.x.
Khoa TruongDinh's user avatar
3 votes
Accepted

Magento 2 Join with ProductRepositoryInterface

I got solutions and I can able to make join using extension_attributes.xml Created new file : etc/extension_attributes.xml <?xml version="1.0"?> <config xmlns:xsi="http://www.w3.org/2001/...
Dharmesh Hariyani's user avatar
3 votes

Is it possible to override vendor/magento/module-sales/Api/Data/OrderAddressInterface.php

It's not possible to override the interfaces using the preference. Magento 2 does not allow Third-party developers to change the API Data interfaces defined in the Magento Core code. Please try to ...
Bhaumik Upadhyay's user avatar
2 votes

Fatal error: Cannot instantiate interface in Magento 2?

Please make sure module is enabled. You can verify using {{MagentoRoot}}/app/etc/config.php file. In my case module was disabled.
Pandurang Babar's user avatar
2 votes
Accepted

Magento 2 Save custom entity primary key

I will answer my own question for people seeing this post. I had to create setEntityId / getEntityId in my API interface and remove the getId / setId because it already exist in the parent class \...
Matthéo Geoffray's user avatar
2 votes
Accepted

I am overridding the default file in my module,but when i add extra method in the file my overriden is not called

You have to replace this di.xml with yours: <?xml version="1.0" ?> <config xmlns:xsi="w3.org/2001/XMLSchema-instance"; xsi:noNamespaceSchemaLocation="urn:magento:framework:ObjectM‌​anager/...
Ronak Chauhan's user avatar
2 votes
Accepted

What is the significance, or how important is Interface in Magento2

First of all, interfaces are not extended by classes, they are implemented by classes. An interface is just a set of public methods that have no body (code). An interface describes how an object (...
Marius's user avatar
  • 199k
2 votes

I am trying to override core interface in Vendor\magento\sales\Api\Data\OrderItemInterface.php

Magento\Sales\Api\Data\OrderItemInterface Is a service provider data interface which already rewritten it by Magento\Sales\Model\Order\Item, as per as Magento 2 service contact <preference ...
Amit Bera's user avatar
  • 77.7k
2 votes

How can override shipping API interface in Magento2

vendor/magento/module-quote/Api/Data/ShippingMethodInterface.php is already override magento quote model. <preference for="Magento\Quote\Api\Data\ShippingMethodInterface" type="Magento\Quote\...
Amit Bera's user avatar
  • 77.7k
2 votes

Magento 2.3.0 How to add store filter in searchCriteriaBuilder

If you want to pass multiple storeId to Filter You can use in for multi-store select. So your code looks like below : $searchCriteria = $this->searchCriteriaBuilder ->...
Himanshu's user avatar
  • 1,776
2 votes

How to override Interface of Other custom module?

Magento 2 Preference does not allow us to override the interfaces. Preferences are used to specify the implementation classes for the interfaces and overriding implementation classes. It does not ...
Supravat Mondal's user avatar
1 vote
Accepted

Create QuestionManagement class

Try following way to enable/disable. Guess, question enable/disable column name is status. <?php namespace Vendor\Module\Model; use Vendor\Module\Api\QuestionManagementInterface; use Vendor\...
Sohel Rana's user avatar
  • 36.1k
1 vote
Accepted

Magento 2.3.0 How to add store filter in searchCriteriaBuilder

Replace ->addFilter('store_id', $this->followUpEmailHelper->getStore(), 'eq') with ->addFilter('store_id', $this->followUpEmailHelper->getStore()->getId(), 'eq')
Marius's user avatar
  • 199k
1 vote
Accepted

How to override the GroupInterface by creating extension attributes in magento 2

I hope you have created two fields like custom_terms and handling_fee. Vendor\Module\Plugin\SavePlugin.php use Magento\Customer\Api\GroupRepositoryInterface; use Magento\Customer\Model\...
Kamlesh Solanki's user avatar
1 vote

Magento2 interface not found in Model class

If you have already added the dependency in di.xml, then change Test\TestThesis\Api\Data\CryptocurrencyInterface to \Test\TestThesis\Api\Data\CryptocurrencyInterface and try again.
Anshu Mishra's user avatar
  • 9,010
1 vote

I am overridding the default file in my module,but when i add extra method in the file my overriden is not called

Replace below code to di.xml file <preference for="Magento\Catalog\Model\Category" type="Silk\Helloworld\Model\Category" />
Suresh Chikani's user avatar
1 vote
Accepted

Magento2 API must use fully qualified namespaces?

Magento 2 is trying to switch to use importing and aliases, but you may understand there is no out-of-the-box tool to convert the whole Magento 2 code like that... And it's not true that Magento 2 ...
Toan Nguyen's user avatar
  • 3,069
1 vote

REST Api interface di not working. Class ItemInterface does not exist

ItemRepositoryInterface: The error message Class ItemInterface does not exist, provide the the namespace of ItemInterface in the Doc Block section. In the ItemRepositoryInterface Doc Block is very ...
Kishor Hase's user avatar

Only top scored, non community-wiki answers of a minimum length are eligible