0

I have added one field i.e. checksum alongwith coupon code on payment page. Now I want to get and set checksum field.

I tried,

etc/extension_attributes.xml

   <?xml version="1.0"?>
       <config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:Api/etc/extension_attributes.xsd">
          <extension_attributes for="Magento\GiftCardAccount\Api\Data\GiftCardInterface">
          <attribute code="checksum" type="Test\GiftCard\Api\Data\GiftCardInterface" />
          </extension_attributes>
    </config>

Test\GiftCard\Api\Data\GiftCardInterface

<?php

namespace Test\GiftCard\Api\Data;

interface GiftCardInterface
{
     public function getChecksum();    
     public function setChecksum($checksum);
}

But I am getting error -

      Property \"Checksum\" does not have accessor method \"getChecksum\" in class \"Magento\\GiftCardAccount\\Api\\Data\\GiftCardAccountInterface\".
0

At, Test\GiftCard\Api\Data\GiftCardInterface interface

getChecksum(),setChecksum() should have method singnature means it

Like:

<?php

namespace Test\GiftCard\Api\Data;

interface GiftCardInterface extends \Magento\Framework\Api\ExtensibleDataInterface
{
    /**
     *
     * @return string
     */ 
     public function getChecksum();   

    /**
     *
     * @param string $checksum
     * @return $this
     */ 
     public function setChecksum($checksum);
}

Here return type of getter method getChecksum is string because of field type is varchar.

After these changes, you need run di compile command properly.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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