Menu Close
    Hire us Request quote Reading list Switch to dark mode

    How to add extension attribute in Magento2

    Extension Attribute in Magento2

    Here we learn, how to add extension attribute in magento2. Extension attributes used to extend interface functionality.

    1. Create app/code/Webkul/DemoModule/etc/extension_attributes.xml


    2. Now clear the var/generation when you run setup:di:compile command, new getter and setter methods will be added in /var/generation/Magento/Checkout/Api/Data/ShippingInformationExtensionInterface.php

    3. Now you can set/get these attributes value by creating the instance of Magento/Checkout/Api/Data/ShippingInformationInterface.php interface.

    . . .

    Comments (4)

    Add Your Comment

  • Sreedevi
    This is really good blog. I have one question on this. Shall i use this same extension attributes for admin order.
  • Raviteja
    Hii,
    in your 3rd step you are creating the instance of Magento/Checkout/Api/Data/ShippingInformationInterface.php interface, where exactly are you creating.are you changing any vendor file or are you using custom module, i got stuck in this.
    • Praful Rajput
      @raviteja, you have to define it into your custom module.
  • Back to Top
    css.php
    Hire Us!
    Brief us about your requirements and we'll get back to you.
    Woo! Hooy!
    We have just received your message and our expert will get back to you shortly.
    Send Again
    Close