Skip to main content
40 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
  • 401
28 votes
Accepted

What is IdentityInterface in Magento2

From what I understood, this is kind of the equivalence of the getCacheTags method of Magento 1. The getIdentities from model classes is then used in every block class referencing this model. Ok let'...
Raphael at Digital Pianism's user avatar
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 DI preference priority

All config files merged in order of module load. You can change order by add sequence in you module.xml files. For example <sequence> <module name="Magento_Search"/> <module ...
KAndy's user avatar
  • 20.9k
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

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
9 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
7 votes

What is IdentityInterface in Magento2

Judging by the class Magento\Framework\DataObject\IdentityInterface comment it is used for cache and make a unique entity ID that is used in Varnish ESI headers in vendor/magento/module-page-cache/...
Matthéo Geoffray'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

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
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
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
Accepted

Magento 2 - How to generate an Interface and a model?

Sometimes i have to create lots of api models, so I created this script Smiley Happy This one generates the model <?php $json = '{ "provider": "OMNIVA", "type": "POST_OFFICE", "name":...
Olavi Sau's user avatar
  • 355
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
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,425
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
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

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 API vs. Web Interface vs. Web API

In this particular statement, API refers to service contracts. It is different than web APIs. A service contract is a set of PHP interfaces that are defined for a module. A service contract ...
Raphael at Digital Pianism'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
  • 198k
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.6k
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.6k
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,761
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

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
  • 8,990

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