0

currently i'm facing the Problem that an extension attribute wont work as expected. On our test setup i get the Property has no accessor Error, while my local setup runs fine.

Message: Property "SaveInCompanyAddressBook" does not have accessor method "getSaveInCompanyAddressBook" in class "Magento\Quote\Api\Data\AddressInterface"

The attribute is configured in the extension_attributes.xml and after a compile all files including the necessary code are generated.

cat customer/module/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\Quote\Api\Data\AddressInterface">
        <attribute code="save_in_company_address_book" type="integer" />
    </extension_attributes>
</config>

cat generated/code/Magento/Quote/Api/Data/AddressExtensionInterface.php

<?php
namespace Magento\Quote\Api\Data;

/**
 * ExtensionInterface class for @see \Magento\Quote\Api\Data\AddressInterface
 */
interface AddressExtensionInterface extends \Magento\Framework\Api\ExtensionAttributesInterface
{
    /**
     * @return integer|null
     */
    public function getSaveInCompanyAddressBook();

    /**
     * @param integer $saveInCompanyAddressBook
     * @return $this
     */
    public function setSaveInCompanyAddressBook($saveInCompanyAddressBook);
}

cat generated/code/Magento/Quote/Api/Data/AddressExtension.php

<?php
namespace Magento\Quote\Api\Data;

/**
 * Extension class for @see \Magento\Quote\Api\Data\AddressInterface
 */
class AddressExtension extends \Magento\Framework\Api\AbstractSimpleObject implements AddressExtensionInterface
{
    /**
     * @return integer|null
     */
    public function getSaveInCompanyAddressBook()
    {
        return $this->_get('save_in_company_address_book');
    }

    /**
     * @param integer $saveInCompanyAddressBook
     * @return $this
     */
    public function setSaveInCompanyAddressBook($saveInCompanyAddressBook)
    {
        $this->setData('save_in_company_address_book', $saveInCompanyAddressBook);
        return $this;
    }
}

Both setups are using the same version of Magento 2.3.6

The interesting part: when i delete the cache unter var/cache the attribute works on time. After the creation of the cache files it stops working and i get the error again.

Maybe one has an idea that could help me solve my problem.

Thanks in advance

2
  • Please share your code?
    – Amit Bera
    Jan 12 at 5:29
  • I added the relevant parts.
    – Philipp
    Jan 12 at 7:24

0

Your Answer

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

Browse other questions tagged or ask your own question.