1

Using Magento-2.1.3 CE

For a purpose,have created a Customer attribute which are using at time of Customer Registration and customer edit page in frontend.

On the edit page,i got the error when i was trying to fetch data of that attribute. and i have post the issue at MSE Custom customer attribute are throwing error at Customer edit Page - Magento2

And got the answer from Khoa TruongDinh . Khoa TruongDinh was suggest me to use

$block->getCustomer()->getCustomAttribute('[Custom_Attribute]]')‌​ Or

$block->getCustomer()->getExtensionAttributes()->get[Custom_Attribute]();

At last of using $block->getCustomer()->getCustomAttribute([Custom_Attribute]]');

i get this attribute value at edit.phtml

Now question is:

  • Why we need to use
    $block->getCustomer()->getCustomAttribute('[Custom_Attribute]]')‌​ and $block->getCustomer()->getExtensionAttributes()->get[Custom_Attribute](); for getting the value of this custom attribute
  • What are different between $block->getCustomer()->getExtensionAttributes()->get[Custom_Attribute](); and $block->getCustomer()->getExtensionAttributes()->get[Custom_Attribute]();
  • Why magento use Magento\Customer\Model\Data\Customer for customer edit and register page?

Can anyone of magento SE give the answer of above questions?

1 Answer 1

1

Extension attributes are new in Magento 2.

They are used to extend functionality and often use more complex data types than custom attributes.

These attributes do not appear on the GUI.

Most likely, you’ll want to extend interfaces defined in the Api/Data directory of a Magento module

checkout EAV and extension attributes.

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.