How to get the extension attributes in shipping info and order/id APi magento2?Get Order Info Using SOAP APIMagento2 How to get Custom order attributes value in response in rest api v1Adding extension attributes to Order API EndpointHow to add custom data in order payment extension attribute rest api in magento2Magento 2: Plugin class does not existMagento 2: Logged-in customer can't place order with new shipping methodOrder item extension attributes are always last database entryGet orders API does not include custom extension attributesGet cart info REST APIHow to display and save extension attributes on Magento 2 Admin create order page

When a company launches a new product do they "come out" with a new product or do they "come up" with a new product?

Intersection of two sorted vectors in C++

How to draw the figure with four pentagons?

Has there ever been an airliner design involving reducing generator load by installing solar panels?

Is it unprofessional to ask if a job posting on GlassDoor is real?

Can a rocket refuel on Mars from water?

Why is consensus so controversial in Britain?

What is the word for reserving something for yourself before others do?

Memorizing the Keyboard

If human space travel is limited by the G force vulnerability, is there a way to counter G forces?

Is it legal for company to use my work email to pretend I still work there?

Why is the 'in' operator throwing an error with a string literal instead of logging false?

Doing something right before you need it - expression for this?

Why "Having chlorophyll without photosynthesis is actually very dangerous" and "like living with a bomb"?

How to model explosives?

Stopping power of mountain vs road bike

Emailing HOD to enhance faculty application

Infinite Abelian subgroup of infinite non Abelian group example

What about the virus in 12 Monkeys?

How could indestructible materials be used in power generation?

Is there a hemisphere-neutral way of specifying a season?

Fully-Firstable Anagram Sets

Forgetting the musical notes while performing in concert

CEO ridiculed me with gay jokes and grabbed me and wouldn't let go - now getting pushed out of company



How to get the extension attributes in shipping info and order/id APi magento2?


Get Order Info Using SOAP APIMagento2 How to get Custom order attributes value in response in rest api v1Adding extension attributes to Order API EndpointHow to add custom data in order payment extension attribute rest api in magento2Magento 2: Plugin class does not existMagento 2: Logged-in customer can't place order with new shipping methodOrder item extension attributes are always last database entryGet orders API does not include custom extension attributesGet cart info REST APIHow to display and save extension attributes on Magento 2 Admin create order page






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








0















I have created a sales attribute "port" in sale_order table. I want to POST this post attribute in shipping information API payload and get it in response as extension attribute. I also want to save the value of extension attribute to save in DB using Api only i.e. there is no extra filed for port in backend or frontend.
Please help. Thanks in advance.



Vendor/Module/Setup/InstallSchema.php



<?php

namespace VendorModuleSetup;

use MagentoFrameworkSetupInstallSchemaInterface;
use MagentoFrameworkSetupSchemaSetupInterface;
use MagentoFrameworkSetupModuleContextInterface;

class InstallSchema implements InstallSchemaInterface

public function install(SchemaSetupInterface $setup, ModuleContextInterface $context)

$setup->startSetup();

$tableName = $setup->getTable('sales_order_grid');

$tableNameSales = $setup->getTable('sales_order');
$tableNameQuote = $setup->getTable('quote');

// Check if the table already exists

$columns = [
'delivery_date' => [
'type' => 'datetime',
'nullable' => true,
'comment' => 'Delivery Date',
],
'no_of_days' => [
'type' => MagentoFrameworkDBDdlTable::TYPE_INTEGER,
'nullable' => true,
'comment' => 'Number of Days',
],
'no_of_crew' => [
'type' => MagentoFrameworkDBDdlTable::TYPE_INTEGER,
'nullable' => true,
'comment' => 'Number of Crew',
],
'port' => [
'type' => MagentoFrameworkDBDdlTable::TYPE_INTEGER,
'nullable' => true,
'comment' => 'Port',
]
];

$connection = $setup->getConnection();

foreach ($columns as $name => $definition)
$connection->addColumn($tableName, $name, $definition);
$connection->addColumn($tableNameSales, $name, $definition);
$connection->addColumn($tableNameQuote, $name, $definition);


$setup->endSetup();




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


Vendor/Module/etc/di.xml



<?xml version="1.0"?>
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:ObjectManager/etc/config.xsd">
<type name="MagentoCheckoutModelShippingInformationManagement">
<plugin name="sr_save_delivery_date_in_quote" type="VendorModulePluginCheckoutModelShippingInformationManagement" sortOrder="1"/>
</type>
<virtualType name="MagentoSalesModelResourceModelOrderGrid" type="MagentoSalesModelResourceModelGrid">
<arguments>
<argument name="columns" xsi:type="array">
<item name="delivery_date" xsi:type="string">sales_order.delivery_date</item>
</argument>
</arguments>
</virtualType>
</config>


Vendor/Module/Plugin/Checkout/Model/ShippingInformationManagement.php



<?php
namespace VendorModulePluginCheckoutModel;
class ShippingInformationManagement

protected $quoteRepository;
public function __construct(
MagentoQuoteModelQuoteRepository $quoteRepository
)
$this->quoteRepository = $quoteRepository;

/**
* @param MagentoCheckoutModelShippingInformationManagement $subject
* @param $cartId
* @param MagentoCheckoutApiDataShippingInformationInterface $addressInformation
*/
public function beforeSaveAddressInformation(
MagentoCheckoutModelShippingInformationManagement $subject,
$cartId,
MagentoCheckoutApiDataShippingInformationInterface $addressInformation
)
$extAttributes = $addressInformation->getExtensionAttributes();
$deliveryDate = $extAttributes->getDeliveryDate();
$quote = $this->quoteRepository->getActive($cartId);
$quote->setDeliveryDate($deliveryDate);











share|improve this question







New contributor




Meetali Gupta is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.


























    0















    I have created a sales attribute "port" in sale_order table. I want to POST this post attribute in shipping information API payload and get it in response as extension attribute. I also want to save the value of extension attribute to save in DB using Api only i.e. there is no extra filed for port in backend or frontend.
    Please help. Thanks in advance.



    Vendor/Module/Setup/InstallSchema.php



    <?php

    namespace VendorModuleSetup;

    use MagentoFrameworkSetupInstallSchemaInterface;
    use MagentoFrameworkSetupSchemaSetupInterface;
    use MagentoFrameworkSetupModuleContextInterface;

    class InstallSchema implements InstallSchemaInterface

    public function install(SchemaSetupInterface $setup, ModuleContextInterface $context)

    $setup->startSetup();

    $tableName = $setup->getTable('sales_order_grid');

    $tableNameSales = $setup->getTable('sales_order');
    $tableNameQuote = $setup->getTable('quote');

    // Check if the table already exists

    $columns = [
    'delivery_date' => [
    'type' => 'datetime',
    'nullable' => true,
    'comment' => 'Delivery Date',
    ],
    'no_of_days' => [
    'type' => MagentoFrameworkDBDdlTable::TYPE_INTEGER,
    'nullable' => true,
    'comment' => 'Number of Days',
    ],
    'no_of_crew' => [
    'type' => MagentoFrameworkDBDdlTable::TYPE_INTEGER,
    'nullable' => true,
    'comment' => 'Number of Crew',
    ],
    'port' => [
    'type' => MagentoFrameworkDBDdlTable::TYPE_INTEGER,
    'nullable' => true,
    'comment' => 'Port',
    ]
    ];

    $connection = $setup->getConnection();

    foreach ($columns as $name => $definition)
    $connection->addColumn($tableName, $name, $definition);
    $connection->addColumn($tableNameSales, $name, $definition);
    $connection->addColumn($tableNameQuote, $name, $definition);


    $setup->endSetup();




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


    Vendor/Module/etc/di.xml



    <?xml version="1.0"?>
    <config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:ObjectManager/etc/config.xsd">
    <type name="MagentoCheckoutModelShippingInformationManagement">
    <plugin name="sr_save_delivery_date_in_quote" type="VendorModulePluginCheckoutModelShippingInformationManagement" sortOrder="1"/>
    </type>
    <virtualType name="MagentoSalesModelResourceModelOrderGrid" type="MagentoSalesModelResourceModelGrid">
    <arguments>
    <argument name="columns" xsi:type="array">
    <item name="delivery_date" xsi:type="string">sales_order.delivery_date</item>
    </argument>
    </arguments>
    </virtualType>
    </config>


    Vendor/Module/Plugin/Checkout/Model/ShippingInformationManagement.php



    <?php
    namespace VendorModulePluginCheckoutModel;
    class ShippingInformationManagement

    protected $quoteRepository;
    public function __construct(
    MagentoQuoteModelQuoteRepository $quoteRepository
    )
    $this->quoteRepository = $quoteRepository;

    /**
    * @param MagentoCheckoutModelShippingInformationManagement $subject
    * @param $cartId
    * @param MagentoCheckoutApiDataShippingInformationInterface $addressInformation
    */
    public function beforeSaveAddressInformation(
    MagentoCheckoutModelShippingInformationManagement $subject,
    $cartId,
    MagentoCheckoutApiDataShippingInformationInterface $addressInformation
    )
    $extAttributes = $addressInformation->getExtensionAttributes();
    $deliveryDate = $extAttributes->getDeliveryDate();
    $quote = $this->quoteRepository->getActive($cartId);
    $quote->setDeliveryDate($deliveryDate);











    share|improve this question







    New contributor




    Meetali Gupta is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
    Check out our Code of Conduct.






















      0












      0








      0








      I have created a sales attribute "port" in sale_order table. I want to POST this post attribute in shipping information API payload and get it in response as extension attribute. I also want to save the value of extension attribute to save in DB using Api only i.e. there is no extra filed for port in backend or frontend.
      Please help. Thanks in advance.



      Vendor/Module/Setup/InstallSchema.php



      <?php

      namespace VendorModuleSetup;

      use MagentoFrameworkSetupInstallSchemaInterface;
      use MagentoFrameworkSetupSchemaSetupInterface;
      use MagentoFrameworkSetupModuleContextInterface;

      class InstallSchema implements InstallSchemaInterface

      public function install(SchemaSetupInterface $setup, ModuleContextInterface $context)

      $setup->startSetup();

      $tableName = $setup->getTable('sales_order_grid');

      $tableNameSales = $setup->getTable('sales_order');
      $tableNameQuote = $setup->getTable('quote');

      // Check if the table already exists

      $columns = [
      'delivery_date' => [
      'type' => 'datetime',
      'nullable' => true,
      'comment' => 'Delivery Date',
      ],
      'no_of_days' => [
      'type' => MagentoFrameworkDBDdlTable::TYPE_INTEGER,
      'nullable' => true,
      'comment' => 'Number of Days',
      ],
      'no_of_crew' => [
      'type' => MagentoFrameworkDBDdlTable::TYPE_INTEGER,
      'nullable' => true,
      'comment' => 'Number of Crew',
      ],
      'port' => [
      'type' => MagentoFrameworkDBDdlTable::TYPE_INTEGER,
      'nullable' => true,
      'comment' => 'Port',
      ]
      ];

      $connection = $setup->getConnection();

      foreach ($columns as $name => $definition)
      $connection->addColumn($tableName, $name, $definition);
      $connection->addColumn($tableNameSales, $name, $definition);
      $connection->addColumn($tableNameQuote, $name, $definition);


      $setup->endSetup();




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


      Vendor/Module/etc/di.xml



      <?xml version="1.0"?>
      <config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:ObjectManager/etc/config.xsd">
      <type name="MagentoCheckoutModelShippingInformationManagement">
      <plugin name="sr_save_delivery_date_in_quote" type="VendorModulePluginCheckoutModelShippingInformationManagement" sortOrder="1"/>
      </type>
      <virtualType name="MagentoSalesModelResourceModelOrderGrid" type="MagentoSalesModelResourceModelGrid">
      <arguments>
      <argument name="columns" xsi:type="array">
      <item name="delivery_date" xsi:type="string">sales_order.delivery_date</item>
      </argument>
      </arguments>
      </virtualType>
      </config>


      Vendor/Module/Plugin/Checkout/Model/ShippingInformationManagement.php



      <?php
      namespace VendorModulePluginCheckoutModel;
      class ShippingInformationManagement

      protected $quoteRepository;
      public function __construct(
      MagentoQuoteModelQuoteRepository $quoteRepository
      )
      $this->quoteRepository = $quoteRepository;

      /**
      * @param MagentoCheckoutModelShippingInformationManagement $subject
      * @param $cartId
      * @param MagentoCheckoutApiDataShippingInformationInterface $addressInformation
      */
      public function beforeSaveAddressInformation(
      MagentoCheckoutModelShippingInformationManagement $subject,
      $cartId,
      MagentoCheckoutApiDataShippingInformationInterface $addressInformation
      )
      $extAttributes = $addressInformation->getExtensionAttributes();
      $deliveryDate = $extAttributes->getDeliveryDate();
      $quote = $this->quoteRepository->getActive($cartId);
      $quote->setDeliveryDate($deliveryDate);











      share|improve this question







      New contributor




      Meetali Gupta is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
      Check out our Code of Conduct.












      I have created a sales attribute "port" in sale_order table. I want to POST this post attribute in shipping information API payload and get it in response as extension attribute. I also want to save the value of extension attribute to save in DB using Api only i.e. there is no extra filed for port in backend or frontend.
      Please help. Thanks in advance.



      Vendor/Module/Setup/InstallSchema.php



      <?php

      namespace VendorModuleSetup;

      use MagentoFrameworkSetupInstallSchemaInterface;
      use MagentoFrameworkSetupSchemaSetupInterface;
      use MagentoFrameworkSetupModuleContextInterface;

      class InstallSchema implements InstallSchemaInterface

      public function install(SchemaSetupInterface $setup, ModuleContextInterface $context)

      $setup->startSetup();

      $tableName = $setup->getTable('sales_order_grid');

      $tableNameSales = $setup->getTable('sales_order');
      $tableNameQuote = $setup->getTable('quote');

      // Check if the table already exists

      $columns = [
      'delivery_date' => [
      'type' => 'datetime',
      'nullable' => true,
      'comment' => 'Delivery Date',
      ],
      'no_of_days' => [
      'type' => MagentoFrameworkDBDdlTable::TYPE_INTEGER,
      'nullable' => true,
      'comment' => 'Number of Days',
      ],
      'no_of_crew' => [
      'type' => MagentoFrameworkDBDdlTable::TYPE_INTEGER,
      'nullable' => true,
      'comment' => 'Number of Crew',
      ],
      'port' => [
      'type' => MagentoFrameworkDBDdlTable::TYPE_INTEGER,
      'nullable' => true,
      'comment' => 'Port',
      ]
      ];

      $connection = $setup->getConnection();

      foreach ($columns as $name => $definition)
      $connection->addColumn($tableName, $name, $definition);
      $connection->addColumn($tableNameSales, $name, $definition);
      $connection->addColumn($tableNameQuote, $name, $definition);


      $setup->endSetup();




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


      Vendor/Module/etc/di.xml



      <?xml version="1.0"?>
      <config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:ObjectManager/etc/config.xsd">
      <type name="MagentoCheckoutModelShippingInformationManagement">
      <plugin name="sr_save_delivery_date_in_quote" type="VendorModulePluginCheckoutModelShippingInformationManagement" sortOrder="1"/>
      </type>
      <virtualType name="MagentoSalesModelResourceModelOrderGrid" type="MagentoSalesModelResourceModelGrid">
      <arguments>
      <argument name="columns" xsi:type="array">
      <item name="delivery_date" xsi:type="string">sales_order.delivery_date</item>
      </argument>
      </arguments>
      </virtualType>
      </config>


      Vendor/Module/Plugin/Checkout/Model/ShippingInformationManagement.php



      <?php
      namespace VendorModulePluginCheckoutModel;
      class ShippingInformationManagement

      protected $quoteRepository;
      public function __construct(
      MagentoQuoteModelQuoteRepository $quoteRepository
      )
      $this->quoteRepository = $quoteRepository;

      /**
      * @param MagentoCheckoutModelShippingInformationManagement $subject
      * @param $cartId
      * @param MagentoCheckoutApiDataShippingInformationInterface $addressInformation
      */
      public function beforeSaveAddressInformation(
      MagentoCheckoutModelShippingInformationManagement $subject,
      $cartId,
      MagentoCheckoutApiDataShippingInformationInterface $addressInformation
      )
      $extAttributes = $addressInformation->getExtensionAttributes();
      $deliveryDate = $extAttributes->getDeliveryDate();
      $quote = $this->quoteRepository->getActive($cartId);
      $quote->setDeliveryDate($deliveryDate);








      magento2.2 sales-order rest-api extension-attributes






      share|improve this question







      New contributor




      Meetali Gupta is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
      Check out our Code of Conduct.











      share|improve this question







      New contributor




      Meetali Gupta is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
      Check out our Code of Conduct.









      share|improve this question




      share|improve this question






      New contributor




      Meetali Gupta is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
      Check out our Code of Conduct.









      asked 2 days ago









      Meetali GuptaMeetali Gupta

      162




      162




      New contributor




      Meetali Gupta is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
      Check out our Code of Conduct.





      New contributor





      Meetali Gupta is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
      Check out our Code of Conduct.






      Meetali Gupta is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
      Check out our Code of Conduct.




















          0






          active

          oldest

          votes












          Your Answer








          StackExchange.ready(function()
          var channelOptions =
          tags: "".split(" "),
          id: "479"
          ;
          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: false,
          noModals: true,
          showLowRepImageUploadWarning: true,
          reputationToPostImages: null,
          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
          );



          );






          Meetali Gupta is a new contributor. Be nice, and check out our Code of Conduct.









          draft saved

          draft discarded


















          StackExchange.ready(
          function ()
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fmagento.stackexchange.com%2fquestions%2f268327%2fhow-to-get-the-extension-attributes-in-shipping-info-and-order-id-api-magento2%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








          Meetali Gupta is a new contributor. Be nice, and check out our Code of Conduct.









          draft saved

          draft discarded


















          Meetali Gupta is a new contributor. Be nice, and check out our Code of Conduct.












          Meetali Gupta is a new contributor. Be nice, and check out our Code of Conduct.











          Meetali Gupta is a new contributor. Be nice, and check out our Code of Conduct.














          Thanks for contributing an answer to Magento Stack Exchange!


          • 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%2fmagento.stackexchange.com%2fquestions%2f268327%2fhow-to-get-the-extension-attributes-in-shipping-info-and-order-id-api-magento2%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

          Sum ergo cogito? 1 nng

          三茅街道4182Guuntc Dn precexpngmageondP