How to display and save extension attributes on Magento 2 Admin create order pageHow do I create a simple 'Hello World' module in Magento?Magento: Add Tab to Admin Order Details PageMagento - Quote/order product item attribute based on user inputMagento - How to create new admin pageMagento: Display custom product attribute in admin Items ordered blockcustom attribute displaying but is not saving in magento 2 admin customer creation formMagento 2 custom address attribute not loading in address book in checkout pageMagento 2 - At Checkout page, the City Id is displaying in Shipping Address not the City Name

How to write triplets in 4/4 time without using a 3 on top of the notes all the time

Why did this happen to Thanos's ships at the end of "Avengers: Endgame"?

Is it insecure to have an ansible user with passwordless sudo?

On the feasibility of space battleships

Is there any practical application for performing a double Fourier transform? ...or an inverse Fourier transform on a time-domain input?

Sleeping solo in a double sleeping bag

What is the appropriate benchmark for a Long/Short VIX futures strategy?

What is the hex versus octal timeline?

Brexit and backstop: would changes require unanimous approval by all EU countries? Does Ireland hold a veto?

Why does my house heat up, even when it's cool outside?

In the MCU, why does Mjölnir retain its enchantments after Ragnarok?

In what ways can a Non-paladin access Paladin spells?

Most practical knots for hitching a line to an object while keeping the bitter end as tight as possible, without sag?

System to validate run time complexity requirements

How would one country purchase another?

How do I make distance between concentric circles equal?

Defense against attacks using dictionaries

How to dismiss intrusive questions from a colleague with whom I don't work?

How much code would a codegolf golf if a codegolf could golf code?

How is "sein" conjugated in this sub-sentence?

Avoiding racist tropes in fantasy

How to compare two different formulations of a problem?

Church Booleans

Why is my Earth simulation slower than the reality?



How to display and save extension attributes on Magento 2 Admin create order page


How do I create a simple 'Hello World' module in Magento?Magento: Add Tab to Admin Order Details PageMagento - Quote/order product item attribute based on user inputMagento - How to create new admin pageMagento: Display custom product attribute in admin Items ordered blockcustom attribute displaying but is not saving in magento 2 admin customer creation formMagento 2 custom address attribute not loading in address book in checkout pageMagento 2 - At Checkout page, the City Id is displaying in Shipping Address not the City Name






.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty margin-bottom:0;








0















I have created extension attributes to order for rest API services in Magento 2. Also, I'm able to display the attributes on the order grid.



How can I display the same attributes on admin create order form and save it?



Can any one please suggest a best approach?



Thanks in advance



Here is my extension_attributes.xml file



<?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="MagentoCheckoutApiDataShippingInformationInterface">
<attribute code="delivery_day_slot" type="string"/>
</extension_attributes>

<extension_attributes for="MagentoSalesApiDataOrderInterface">
<attribute code="delivery_day_slot" type="string"/>
</extension_attributes>
</config>


And, I'm saving the data using plugin



<type name="MagentoCheckoutModelShippingInformationManagement">
<plugin name="NM_save_delivery_slot_in_quote" type="<Namespace><ModuleName>PluginCheckoutModelShippingInformationManagement" sortOrder="1"/>
</type>


NamespaceModuleNamePluginCheckoutModelShippingInformationManagement



namespace <Namespace><ModuleName>PluginCheckoutModel;

class ShippingInformationManagement

protected $quoteRepository;

public function __construct(
MagentoQuoteModelQuoteRepository $quoteRepository,
MagentoCheckoutApiDataShippingInformationExtensionFactory $shpExtensionFactory,
PsrLogLoggerInterface $logger
)
$this->quoteRepository = $quoteRepository;
$this->shpExtensionFactory = $shpExtensionFactory;
$this->logger = $logger;


/**
* @param MagentoCheckoutModelShippingInformationManagement $subject
* @param $cartId
* @param MagentoCheckoutApiDataShippingInformationInterface $addressInformation
*/
public function beforeSaveAddressInformation(
MagentoCheckoutModelShippingInformationManagement $subject,
$cartId,
MagentoCheckoutApiDataShippingInformationInterface $addressInformation
)

$extensionAttributes = $addressInformation->getExtensionAttributes();
$shipExtension = $extensionAttributes ? $extensionAttributes : $this->shpExtensionFactory->create();

$payload = file_get_contents("php://input");
$attr = json_decode($payload, true);
if(isset($attr["extension_attributes"]))
$deliveryDaySlot = $attr["extension_attributes"]["delivery_day_slot"];

$addressInformation->setDeliveryDaySlot($deliveryDaySlot);
$quote = $this->quoteRepository->getActive($cartId);
$quote->setDeliveryDaySlot($deliveryDaySlot);



return;











share|improve this question






























    0















    I have created extension attributes to order for rest API services in Magento 2. Also, I'm able to display the attributes on the order grid.



    How can I display the same attributes on admin create order form and save it?



    Can any one please suggest a best approach?



    Thanks in advance



    Here is my extension_attributes.xml file



    <?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="MagentoCheckoutApiDataShippingInformationInterface">
    <attribute code="delivery_day_slot" type="string"/>
    </extension_attributes>

    <extension_attributes for="MagentoSalesApiDataOrderInterface">
    <attribute code="delivery_day_slot" type="string"/>
    </extension_attributes>
    </config>


    And, I'm saving the data using plugin



    <type name="MagentoCheckoutModelShippingInformationManagement">
    <plugin name="NM_save_delivery_slot_in_quote" type="<Namespace><ModuleName>PluginCheckoutModelShippingInformationManagement" sortOrder="1"/>
    </type>


    NamespaceModuleNamePluginCheckoutModelShippingInformationManagement



    namespace <Namespace><ModuleName>PluginCheckoutModel;

    class ShippingInformationManagement

    protected $quoteRepository;

    public function __construct(
    MagentoQuoteModelQuoteRepository $quoteRepository,
    MagentoCheckoutApiDataShippingInformationExtensionFactory $shpExtensionFactory,
    PsrLogLoggerInterface $logger
    )
    $this->quoteRepository = $quoteRepository;
    $this->shpExtensionFactory = $shpExtensionFactory;
    $this->logger = $logger;


    /**
    * @param MagentoCheckoutModelShippingInformationManagement $subject
    * @param $cartId
    * @param MagentoCheckoutApiDataShippingInformationInterface $addressInformation
    */
    public function beforeSaveAddressInformation(
    MagentoCheckoutModelShippingInformationManagement $subject,
    $cartId,
    MagentoCheckoutApiDataShippingInformationInterface $addressInformation
    )

    $extensionAttributes = $addressInformation->getExtensionAttributes();
    $shipExtension = $extensionAttributes ? $extensionAttributes : $this->shpExtensionFactory->create();

    $payload = file_get_contents("php://input");
    $attr = json_decode($payload, true);
    if(isset($attr["extension_attributes"]))
    $deliveryDaySlot = $attr["extension_attributes"]["delivery_day_slot"];

    $addressInformation->setDeliveryDaySlot($deliveryDaySlot);
    $quote = $this->quoteRepository->getActive($cartId);
    $quote->setDeliveryDaySlot($deliveryDaySlot);



    return;











    share|improve this question


























      0












      0








      0








      I have created extension attributes to order for rest API services in Magento 2. Also, I'm able to display the attributes on the order grid.



      How can I display the same attributes on admin create order form and save it?



      Can any one please suggest a best approach?



      Thanks in advance



      Here is my extension_attributes.xml file



      <?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="MagentoCheckoutApiDataShippingInformationInterface">
      <attribute code="delivery_day_slot" type="string"/>
      </extension_attributes>

      <extension_attributes for="MagentoSalesApiDataOrderInterface">
      <attribute code="delivery_day_slot" type="string"/>
      </extension_attributes>
      </config>


      And, I'm saving the data using plugin



      <type name="MagentoCheckoutModelShippingInformationManagement">
      <plugin name="NM_save_delivery_slot_in_quote" type="<Namespace><ModuleName>PluginCheckoutModelShippingInformationManagement" sortOrder="1"/>
      </type>


      NamespaceModuleNamePluginCheckoutModelShippingInformationManagement



      namespace <Namespace><ModuleName>PluginCheckoutModel;

      class ShippingInformationManagement

      protected $quoteRepository;

      public function __construct(
      MagentoQuoteModelQuoteRepository $quoteRepository,
      MagentoCheckoutApiDataShippingInformationExtensionFactory $shpExtensionFactory,
      PsrLogLoggerInterface $logger
      )
      $this->quoteRepository = $quoteRepository;
      $this->shpExtensionFactory = $shpExtensionFactory;
      $this->logger = $logger;


      /**
      * @param MagentoCheckoutModelShippingInformationManagement $subject
      * @param $cartId
      * @param MagentoCheckoutApiDataShippingInformationInterface $addressInformation
      */
      public function beforeSaveAddressInformation(
      MagentoCheckoutModelShippingInformationManagement $subject,
      $cartId,
      MagentoCheckoutApiDataShippingInformationInterface $addressInformation
      )

      $extensionAttributes = $addressInformation->getExtensionAttributes();
      $shipExtension = $extensionAttributes ? $extensionAttributes : $this->shpExtensionFactory->create();

      $payload = file_get_contents("php://input");
      $attr = json_decode($payload, true);
      if(isset($attr["extension_attributes"]))
      $deliveryDaySlot = $attr["extension_attributes"]["delivery_day_slot"];

      $addressInformation->setDeliveryDaySlot($deliveryDaySlot);
      $quote = $this->quoteRepository->getActive($cartId);
      $quote->setDeliveryDaySlot($deliveryDaySlot);



      return;











      share|improve this question














      I have created extension attributes to order for rest API services in Magento 2. Also, I'm able to display the attributes on the order grid.



      How can I display the same attributes on admin create order form and save it?



      Can any one please suggest a best approach?



      Thanks in advance



      Here is my extension_attributes.xml file



      <?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="MagentoCheckoutApiDataShippingInformationInterface">
      <attribute code="delivery_day_slot" type="string"/>
      </extension_attributes>

      <extension_attributes for="MagentoSalesApiDataOrderInterface">
      <attribute code="delivery_day_slot" type="string"/>
      </extension_attributes>
      </config>


      And, I'm saving the data using plugin



      <type name="MagentoCheckoutModelShippingInformationManagement">
      <plugin name="NM_save_delivery_slot_in_quote" type="<Namespace><ModuleName>PluginCheckoutModelShippingInformationManagement" sortOrder="1"/>
      </type>


      NamespaceModuleNamePluginCheckoutModelShippingInformationManagement



      namespace <Namespace><ModuleName>PluginCheckoutModel;

      class ShippingInformationManagement

      protected $quoteRepository;

      public function __construct(
      MagentoQuoteModelQuoteRepository $quoteRepository,
      MagentoCheckoutApiDataShippingInformationExtensionFactory $shpExtensionFactory,
      PsrLogLoggerInterface $logger
      )
      $this->quoteRepository = $quoteRepository;
      $this->shpExtensionFactory = $shpExtensionFactory;
      $this->logger = $logger;


      /**
      * @param MagentoCheckoutModelShippingInformationManagement $subject
      * @param $cartId
      * @param MagentoCheckoutApiDataShippingInformationInterface $addressInformation
      */
      public function beforeSaveAddressInformation(
      MagentoCheckoutModelShippingInformationManagement $subject,
      $cartId,
      MagentoCheckoutApiDataShippingInformationInterface $addressInformation
      )

      $extensionAttributes = $addressInformation->getExtensionAttributes();
      $shipExtension = $extensionAttributes ? $extensionAttributes : $this->shpExtensionFactory->create();

      $payload = file_get_contents("php://input");
      $attr = json_decode($payload, true);
      if(isset($attr["extension_attributes"]))
      $deliveryDaySlot = $attr["extension_attributes"]["delivery_day_slot"];

      $addressInformation->setDeliveryDaySlot($deliveryDaySlot);
      $quote = $this->quoteRepository->getActive($cartId);
      $quote->setDeliveryDaySlot($deliveryDaySlot);



      return;








      php magento2 adminhtml






      share|improve this question













      share|improve this question











      share|improve this question




      share|improve this question










      asked Mar 27 at 16:06









      Bhargava RamaBhargava Rama

      13 bronze badges




      13 bronze badges

























          0






          active

          oldest

          votes










          Your Answer






          StackExchange.ifUsing("editor", function ()
          StackExchange.using("externalEditor", function ()
          StackExchange.using("snippets", function ()
          StackExchange.snippets.init();
          );
          );
          , "code-snippets");

          StackExchange.ready(function()
          var channelOptions =
          tags: "".split(" "),
          id: "1"
          ;
          initTagRenderer("".split(" "), "".split(" "), channelOptions);

          StackExchange.using("externalEditor", function()
          // Have to fire editor after snippets, if snippets enabled
          if (StackExchange.settings.snippets.snippetsEnabled)
          StackExchange.using("snippets", function()
          createEditor();
          );

          else
          createEditor();

          );

          function createEditor()
          StackExchange.prepareEditor(
          heartbeatType: 'answer',
          autoActivateHeartbeat: false,
          convertImagesToLinks: true,
          noModals: true,
          showLowRepImageUploadWarning: true,
          reputationToPostImages: 10,
          bindNavPrevention: true,
          postfix: "",
          imageUploader:
          brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
          contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
          allowUrls: true
          ,
          onDemand: true,
          discardSelector: ".discard-answer"
          ,immediatelyShowMarkdownHelp:true
          );



          );













          draft saved

          draft discarded


















          StackExchange.ready(
          function ()
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55381724%2fhow-to-display-and-save-extension-attributes-on-magento-2-admin-create-order-pag%23new-answer', 'question_page');

          );

          Post as a guest















          Required, but never shown

























          0






          active

          oldest

          votes








          0






          active

          oldest

          votes









          active

          oldest

          votes






          active

          oldest

          votes




          Is this question similar to what you get asked at work? Learn more about asking and sharing private information with your coworkers using Stack Overflow for Teams.







          Is this question similar to what you get asked at work? Learn more about asking and sharing private information with your coworkers using Stack Overflow for Teams.



















          draft saved

          draft discarded
















































          Thanks for contributing an answer to Stack Overflow!


          • Please be sure to answer the question. Provide details and share your research!

          But avoid


          • Asking for help, clarification, or responding to other answers.

          • Making statements based on opinion; back them up with references or personal experience.

          To learn more, see our tips on writing great answers.




          draft saved


          draft discarded














          StackExchange.ready(
          function ()
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55381724%2fhow-to-display-and-save-extension-attributes-on-magento-2-admin-create-order-pag%23new-answer', 'question_page');

          );

          Post as a guest















          Required, but never shown





















































          Required, but never shown














          Required, but never shown












          Required, but never shown







          Required, but never shown

































          Required, but never shown














          Required, but never shown












          Required, but never shown







          Required, but never shown







          Popular posts from this blog

          Kamusi Yaliyomo Aina za kamusi | Muundo wa kamusi | Faida za kamusi | Dhima ya picha katika kamusi | Marejeo | Tazama pia | Viungo vya nje | UrambazajiKuhusu kamusiGo-SwahiliWiki-KamusiKamusi ya Kiswahili na Kiingerezakuihariri na kuongeza habari

          Swift 4 - func physicsWorld not invoked on collision? The Next CEO of Stack OverflowHow to call Objective-C code from Swift#ifdef replacement in the Swift language@selector() in Swift?#pragma mark in Swift?Swift for loop: for index, element in array?dispatch_after - GCD in Swift?Swift Beta performance: sorting arraysSplit a String into an array in Swift?The use of Swift 3 @objc inference in Swift 4 mode is deprecated?How to optimize UITableViewCell, because my UITableView lags

          Access current req object everywhere in Node.js ExpressWhy are global variables considered bad practice? (node.js)Using req & res across functionsHow do I get the path to the current script with Node.js?What is Node.js' Connect, Express and “middleware”?Node.js w/ express error handling in callbackHow to access the GET parameters after “?” in Express?Modify Node.js req object parametersAccess “app” variable inside of ExpressJS/ConnectJS middleware?Node.js Express app - request objectAngular Http Module considered middleware?Session variables in ExpressJSAdd properties to the req object in expressjs with Typescript