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 = $...
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:...
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
<?...
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()
{
$...
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 ...
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.
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 ...
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 ...
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 ...
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 ...
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 ...
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.
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.
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/...
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 ...
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.
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 \...
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:ObjectManager/...
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 (...
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 ...
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\...
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
->...
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 ...
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\...
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')
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\...
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.
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" />
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 ...
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 ...
Only top scored, non community-wiki answers of a minimum length are eligible
Related Tags
interface × 79magento2 × 49
api × 15
overrides × 11
model × 8
repository × 5
magento2.3 × 4
module × 4
error × 4
rest-api × 4
fatal-error × 4
extension-attributes × 3
factory × 3
magento-1.9 × 2
magento-2.1 × 2
product × 2
database × 2
admin × 2
frontend × 2
magento2.4 × 2
backend × 2
shipping-address × 2
dependency-injection × 2
save × 2
best-practice × 2