how to set extension attribute to Order search interface api magento 2Create Order via SOAP apiMagento 2...

lead or lag function to get several values, not just the nth

When was drinking water recognized as crucial in marathon running?

Can throughput exceed the bandwidth of a network

School performs periodic password audits. Is my password compromised?

If nine coins are tossed, what is the probability that the number of heads is even?

What are all the squawk codes?

A right or the right?

In iTunes 12 on macOS, how can I reset the skip count of a song?

How to mitigate "bandwagon attacking" from players?

How do I deal with being jealous of my own players?

Is 長 in Japanese related to “naga” in Thai and Sanskrit?

What is a term for a function that when called repeatedly, has the same effect as calling once?

Is there a math equivalent to the conditional ternary operator?

Book about a time-travel war fought by computers

What's the values for the Freq_Interval column in MSDB.dbo.SysSchedules when Freq_Type is weekly and more than one day is selected in the schedule?

Skis versus snow shoes - when to choose which for travelling the backcountry?

How can I create a Table like this in Latex?

Plagiarism of code by other PhD student

In Adventurer's League, is it possible to keep the Ring of Winter if you manage to acquire it in the Tomb of Annihilation adventure?

Where is the fallacy here?

Roots of 6th chords on the guitar for different inversions/voicings

What is better: yes / no radio, or simple checkbox?

Toast materialize

Difference between 'stomach' and 'uterus'



how to set extension attribute to Order search interface api magento 2


Create Order via SOAP apiMagento 2 custom API ImplementationMagento 2 search criteriaAssign Related Product In Magento 2 APIRefund order and invoice api not workingHow to enable extension in magento 2.2.6?Overriding Block class causes constructor err in magento 2Magento 2.2.6: Programatically updating product custom optionsMagento 2 Custom REST API Json responseHow to show product custom attribute value on sales order view page under magento admin













0















this is my plugin file OrderRepositoryPlugin.php
`


use MagentoCatalogApiProductRepositoryInterfaceFactory as ProductRepository;



use MagentoSalesApiDataOrderExtensionFactory;



use MagentoSalesApiDataOrderExtensionInterface;



use MagentoSalesApiDataOrderInterface;



use MagentoSalesApiDataOrderSearchResultInterface;
use MagentoCatalogHelperImageFactory as ProductImageHelper;



use MagentoSalesApiOrderRepositoryInterface;



/**





  • Class OrderRepositoryPlugin



    */




class OrderRepositoryPlugin



{



     /**

*@var MagentoCatalogHelperImageFactory

*/

protected $productImageHelper;

/**

* @var ProductRepository

*/

protected $productRepository;

/**

* Order Comment field name

*/

const FIELD_NAME = 'unitm';



/**

* Order Extension Attributes Factory

*

* @var OrderExtensionFactory

*/

protected $extensionFactory;

/**

* OrderRepositoryPlugin constructor

*

* @param OrderExtensionFactory $extensionFactory

*/

public function __construct(

ProductImageHelper $productImageHelper,

OrderExtensionFactory $extensionFactory,

MagentoCatalogApiProductRepositoryInterface $productRepository

)

{

$this->productImageHelper = $productImageHelper;

$this->extensionFactory = $extensionFactory;

$this->_productRepository = $productRepository;

}
public function afterGet(OrderRepositoryInterface $subject, OrderInterface $order)

{

$addAtt = array();

$info = array();
$addImage = array();

$infoImage = array();

foreach ($order->getAllItems() as $orderItems) {

$itemExtAttr = $order->getExtensionAttributes();
$product = $this->_productRepository->getById($orderItems->getProductId());
$uom = $product->getUnitm();
$weight = round($product->getWeight(), 0);
$optionId = $product->getUnitm();
$attribute = $product->getResource()->getAttribute('unitm');
if ($attribute->usesSource()) {
$optionText = $attribute->getSource()->getOptionText($optionId);
}

$sku = $orderItems->getSku();

$imageurl =$this->productImageHelper->create()->init($product, 'product_thumbnail_image')->setImageFile($product->getThumbnail())->getUrl();
$addAtt[$sku] = $weight." ".$optionText;
$addImage[$sku] = $imageurl;
}

$info[] = $addAtt;

$infoImage[] = $addImage;

$data = json_encode($info);

$dataImage = json_encode($infoImage);

$orderComment = $order->getData(self::FIELD_NAME);

$extensionAttributes = $order->getExtensionAttributes();

$extensionAttributes = $extensionAttributes ? $extensionAttributes : $this->extensionFactory->create();
$extensionAttributes->setUnitm($data);

$extensionAttributes->setImageUrl($dataImage);

$order->setExtensionAttributes($extensionAttributes);
return $order;

}


}
this is
extension_attributes.xml




Here am trying set extension attribute to order interface, but its working in other Orders but not is search criteria, how to achieve it, Thank you in advance.
API is like
rest/V1/orders?searchCriteria[filter_groups][0][filters][0][field]=customer_email&searchCriteria[filter_groups][0][filters][0][value]=me345@gmail.com`









share



























    0















    this is my plugin file OrderRepositoryPlugin.php
    `


    use MagentoCatalogApiProductRepositoryInterfaceFactory as ProductRepository;



    use MagentoSalesApiDataOrderExtensionFactory;



    use MagentoSalesApiDataOrderExtensionInterface;



    use MagentoSalesApiDataOrderInterface;



    use MagentoSalesApiDataOrderSearchResultInterface;
    use MagentoCatalogHelperImageFactory as ProductImageHelper;



    use MagentoSalesApiOrderRepositoryInterface;



    /**





    • Class OrderRepositoryPlugin



      */




    class OrderRepositoryPlugin



    {



         /**

    *@var MagentoCatalogHelperImageFactory

    */

    protected $productImageHelper;

    /**

    * @var ProductRepository

    */

    protected $productRepository;

    /**

    * Order Comment field name

    */

    const FIELD_NAME = 'unitm';



    /**

    * Order Extension Attributes Factory

    *

    * @var OrderExtensionFactory

    */

    protected $extensionFactory;

    /**

    * OrderRepositoryPlugin constructor

    *

    * @param OrderExtensionFactory $extensionFactory

    */

    public function __construct(

    ProductImageHelper $productImageHelper,

    OrderExtensionFactory $extensionFactory,

    MagentoCatalogApiProductRepositoryInterface $productRepository

    )

    {

    $this->productImageHelper = $productImageHelper;

    $this->extensionFactory = $extensionFactory;

    $this->_productRepository = $productRepository;

    }
    public function afterGet(OrderRepositoryInterface $subject, OrderInterface $order)

    {

    $addAtt = array();

    $info = array();
    $addImage = array();

    $infoImage = array();

    foreach ($order->getAllItems() as $orderItems) {

    $itemExtAttr = $order->getExtensionAttributes();
    $product = $this->_productRepository->getById($orderItems->getProductId());
    $uom = $product->getUnitm();
    $weight = round($product->getWeight(), 0);
    $optionId = $product->getUnitm();
    $attribute = $product->getResource()->getAttribute('unitm');
    if ($attribute->usesSource()) {
    $optionText = $attribute->getSource()->getOptionText($optionId);
    }

    $sku = $orderItems->getSku();

    $imageurl =$this->productImageHelper->create()->init($product, 'product_thumbnail_image')->setImageFile($product->getThumbnail())->getUrl();
    $addAtt[$sku] = $weight." ".$optionText;
    $addImage[$sku] = $imageurl;
    }

    $info[] = $addAtt;

    $infoImage[] = $addImage;

    $data = json_encode($info);

    $dataImage = json_encode($infoImage);

    $orderComment = $order->getData(self::FIELD_NAME);

    $extensionAttributes = $order->getExtensionAttributes();

    $extensionAttributes = $extensionAttributes ? $extensionAttributes : $this->extensionFactory->create();
    $extensionAttributes->setUnitm($data);

    $extensionAttributes->setImageUrl($dataImage);

    $order->setExtensionAttributes($extensionAttributes);
    return $order;

    }


    }
    this is
    extension_attributes.xml




    Here am trying set extension attribute to order interface, but its working in other Orders but not is search criteria, how to achieve it, Thank you in advance.
    API is like
    rest/V1/orders?searchCriteria[filter_groups][0][filters][0][field]=customer_email&searchCriteria[filter_groups][0][filters][0][value]=me345@gmail.com`









    share

























      0












      0








      0








      this is my plugin file OrderRepositoryPlugin.php
      `


      use MagentoCatalogApiProductRepositoryInterfaceFactory as ProductRepository;



      use MagentoSalesApiDataOrderExtensionFactory;



      use MagentoSalesApiDataOrderExtensionInterface;



      use MagentoSalesApiDataOrderInterface;



      use MagentoSalesApiDataOrderSearchResultInterface;
      use MagentoCatalogHelperImageFactory as ProductImageHelper;



      use MagentoSalesApiOrderRepositoryInterface;



      /**





      • Class OrderRepositoryPlugin



        */




      class OrderRepositoryPlugin



      {



           /**

      *@var MagentoCatalogHelperImageFactory

      */

      protected $productImageHelper;

      /**

      * @var ProductRepository

      */

      protected $productRepository;

      /**

      * Order Comment field name

      */

      const FIELD_NAME = 'unitm';



      /**

      * Order Extension Attributes Factory

      *

      * @var OrderExtensionFactory

      */

      protected $extensionFactory;

      /**

      * OrderRepositoryPlugin constructor

      *

      * @param OrderExtensionFactory $extensionFactory

      */

      public function __construct(

      ProductImageHelper $productImageHelper,

      OrderExtensionFactory $extensionFactory,

      MagentoCatalogApiProductRepositoryInterface $productRepository

      )

      {

      $this->productImageHelper = $productImageHelper;

      $this->extensionFactory = $extensionFactory;

      $this->_productRepository = $productRepository;

      }
      public function afterGet(OrderRepositoryInterface $subject, OrderInterface $order)

      {

      $addAtt = array();

      $info = array();
      $addImage = array();

      $infoImage = array();

      foreach ($order->getAllItems() as $orderItems) {

      $itemExtAttr = $order->getExtensionAttributes();
      $product = $this->_productRepository->getById($orderItems->getProductId());
      $uom = $product->getUnitm();
      $weight = round($product->getWeight(), 0);
      $optionId = $product->getUnitm();
      $attribute = $product->getResource()->getAttribute('unitm');
      if ($attribute->usesSource()) {
      $optionText = $attribute->getSource()->getOptionText($optionId);
      }

      $sku = $orderItems->getSku();

      $imageurl =$this->productImageHelper->create()->init($product, 'product_thumbnail_image')->setImageFile($product->getThumbnail())->getUrl();
      $addAtt[$sku] = $weight." ".$optionText;
      $addImage[$sku] = $imageurl;
      }

      $info[] = $addAtt;

      $infoImage[] = $addImage;

      $data = json_encode($info);

      $dataImage = json_encode($infoImage);

      $orderComment = $order->getData(self::FIELD_NAME);

      $extensionAttributes = $order->getExtensionAttributes();

      $extensionAttributes = $extensionAttributes ? $extensionAttributes : $this->extensionFactory->create();
      $extensionAttributes->setUnitm($data);

      $extensionAttributes->setImageUrl($dataImage);

      $order->setExtensionAttributes($extensionAttributes);
      return $order;

      }


      }
      this is
      extension_attributes.xml




      Here am trying set extension attribute to order interface, but its working in other Orders but not is search criteria, how to achieve it, Thank you in advance.
      API is like
      rest/V1/orders?searchCriteria[filter_groups][0][filters][0][field]=customer_email&searchCriteria[filter_groups][0][filters][0][value]=me345@gmail.com`









      share














      this is my plugin file OrderRepositoryPlugin.php
      `


      use MagentoCatalogApiProductRepositoryInterfaceFactory as ProductRepository;



      use MagentoSalesApiDataOrderExtensionFactory;



      use MagentoSalesApiDataOrderExtensionInterface;



      use MagentoSalesApiDataOrderInterface;



      use MagentoSalesApiDataOrderSearchResultInterface;
      use MagentoCatalogHelperImageFactory as ProductImageHelper;



      use MagentoSalesApiOrderRepositoryInterface;



      /**





      • Class OrderRepositoryPlugin



        */




      class OrderRepositoryPlugin



      {



           /**

      *@var MagentoCatalogHelperImageFactory

      */

      protected $productImageHelper;

      /**

      * @var ProductRepository

      */

      protected $productRepository;

      /**

      * Order Comment field name

      */

      const FIELD_NAME = 'unitm';



      /**

      * Order Extension Attributes Factory

      *

      * @var OrderExtensionFactory

      */

      protected $extensionFactory;

      /**

      * OrderRepositoryPlugin constructor

      *

      * @param OrderExtensionFactory $extensionFactory

      */

      public function __construct(

      ProductImageHelper $productImageHelper,

      OrderExtensionFactory $extensionFactory,

      MagentoCatalogApiProductRepositoryInterface $productRepository

      )

      {

      $this->productImageHelper = $productImageHelper;

      $this->extensionFactory = $extensionFactory;

      $this->_productRepository = $productRepository;

      }
      public function afterGet(OrderRepositoryInterface $subject, OrderInterface $order)

      {

      $addAtt = array();

      $info = array();
      $addImage = array();

      $infoImage = array();

      foreach ($order->getAllItems() as $orderItems) {

      $itemExtAttr = $order->getExtensionAttributes();
      $product = $this->_productRepository->getById($orderItems->getProductId());
      $uom = $product->getUnitm();
      $weight = round($product->getWeight(), 0);
      $optionId = $product->getUnitm();
      $attribute = $product->getResource()->getAttribute('unitm');
      if ($attribute->usesSource()) {
      $optionText = $attribute->getSource()->getOptionText($optionId);
      }

      $sku = $orderItems->getSku();

      $imageurl =$this->productImageHelper->create()->init($product, 'product_thumbnail_image')->setImageFile($product->getThumbnail())->getUrl();
      $addAtt[$sku] = $weight." ".$optionText;
      $addImage[$sku] = $imageurl;
      }

      $info[] = $addAtt;

      $infoImage[] = $addImage;

      $data = json_encode($info);

      $dataImage = json_encode($infoImage);

      $orderComment = $order->getData(self::FIELD_NAME);

      $extensionAttributes = $order->getExtensionAttributes();

      $extensionAttributes = $extensionAttributes ? $extensionAttributes : $this->extensionFactory->create();
      $extensionAttributes->setUnitm($data);

      $extensionAttributes->setImageUrl($dataImage);

      $order->setExtensionAttributes($extensionAttributes);
      return $order;

      }


      }
      this is
      extension_attributes.xml




      Here am trying set extension attribute to order interface, but its working in other Orders but not is search criteria, how to achieve it, Thank you in advance.
      API is like
      rest/V1/orders?searchCriteria[filter_groups][0][filters][0][field]=customer_email&searchCriteria[filter_groups][0][filters][0][value]=me345@gmail.com`







      magento2.2.6 magento2-api





      share












      share










      share



      share










      asked 6 mins ago









      Praveen NegimaniPraveen Negimani

      106




      106






















          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
          });


          }
          });














          draft saved

          draft discarded


















          StackExchange.ready(
          function () {
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fmagento.stackexchange.com%2fquestions%2f264592%2fhow-to-set-extension-attribute-to-order-search-interface-api-magento-2%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
















          draft saved

          draft discarded




















































          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%2f264592%2fhow-to-set-extension-attribute-to-order-search-interface-api-magento-2%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

          “%fieldName is a required field.”, in Magento2 REST API Call for GET Method Type The Next...

          How to change City field to a dropdown in Checkout step Magento 2Magento 2 : How to change UI field(s)...

          夢乃愛華...