Magento – Magento2 interface not found in Model class

errorinterfacemagento2modelpayment-methods

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);

Best Answer

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.

Related Topic