1

I am new to Magento2. I am developing a payment method and I am getting the message:

Fatal error: Interface 'Test\TestThesis\Model\Test\TestThesis\Api\Data\CryptocurrencyInterface' not found in C:\xampp\htdocs\magento\app\code\Test\TestThesis\Model\Cryptocurrency.php on line 9

I have added the dependency in di.xml. Is there something that I am missing and I am getting this message?

<?php

namespace Test\TestThesis\Model;


use Magento\Framework\Model\AbstractModel;


class Cryptocurrency extends AbstractModel implements Test\TestThesis\Api\Data\CryptocurrencyInterface 
{

    protected function _construct(){
        $this->_init('Test\TestThesis\Model\ResourceModel\Cryptocurrency');
    }

    public function __construct(
        \Magento\Framework\Model\Context $context,
        \Magento\Framework\Registry $registry,
        \Magento\Framework\Model\ResourceModel\AbstractResource $resource = null,
        \Magento\Framework\Data\Collection\AbstractDb $resourceCollection = null,
        array $data = []
    ) {
        parent::__construct($context, $registry, $resource, $resourceCollection, $data);
    }

    /**
     * 
     * {@inheritdoc}
     * @see CryptocurrencyInterface
     */
    public function getId(){
        return $this->getData(self::ENTITY_ID);
    }

    /**
     * 
     * @param type $id
     * @return type
     * @see CryptocurrencyInterface
     */
    public function setId($id){
        return $this->setData(self::ENTITY_ID, $id);
    }

And the interface:

<?php

namespace Test\TestThesis\Api\Data;

/**
 * Interface CryptocurrencyInterface
 *
 * @package Test\TestThesis\Api\Data 
*/
interface CryptocurrencyInterface
{

    const ENTITY_ID = 'id';
    const ORDER_ID = 'order_id';
    const AMOUNT_DEPOSIT = 'amount_deposit';
    const STATUS = 'status';

    /**
     * @return mixed
     */
    public function getId();

    /**
     * @param $id
     *
     * @return mixed
     */
    public function setId($id);
1
  • I will be working on a while on magento 2 v2.3.4. Suddenly my admin panel is not working and shows the below error. Please help Interface 'Magento\Ui\Component\Form\Element\DataType\DataTypeInterface' not found in D:\xampp7.3.31\htdocs\magento2-2.3.4\magento2-2.3.4\app\code\Magento\Ui\Component\Form\Element\DataType\AbstractDataType.php on line 16
    – Mike
    Commented Sep 15, 2022 at 11:21

2 Answers 2

1

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.

3
  • no luck... do I miss a class that should interact with the model? maybe a helper? i dont know
    – Circe
    Commented Apr 4, 2018 at 15:32
  • run setup:upgrade and flush the cache and try again. Also, share the di.xml code. Commented Apr 5, 2018 at 4:39
  • <?xml version="1.0" encoding="UTF-8"?> <config xmlns:xsi="w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:ObjectManager/etc/config.xsd"> <preference for="Test\TestThesis\Api\Data\CryptocurrencyInterface" type="Test\TestThesis\Model\Cryptocurrency" /> </config>
    – Circe
    Commented Apr 6, 2018 at 12:01
0

You have obviously mistaken in the namespace of the implemented interface (prseumably in di.xml preference node):

Fatal error: Interface 'Test\TestThesis\Model\Test\TestThesis\Api\Data\CryptocurrencyInterface' not found in C:\xampp\htdocs\magento\app\code\Test\TestThesis\Model\Cryptocurrency.php on line 9

The answer is almost ALWAYS in the Error message: the path can't be Test\TestThesis\Model\Test\TestThesis\Api...

I often did some mistakes in the namespaces so I understand how it annoys ;D

Hope this will help!

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.