Add product custom options in rest/V1/ordersExport custom option via REST interfaceRest API - how to get custom attributesTrying to add an order_item attribute into the REST APIHow to get the bundle product options via SOAP api?Magento 2 rest api - get orders with products' custom attributesHow to create complex search filters while doing a GET on sales orders through Magento 2 REST API?how to use Search rest api in magento 2?Trying to add product with description via RESTMagento2: Get all orders using REST API?Get pending orders for a specific customer using REST API Magento 2Problem adding attribute options to configurable product via REST Api

Good introductory book to type theory?

Why doesn't a particle exert force on itself?

Does every non-empty set admit an (affine) scheme structure (in ZFC)?

Extracting the parent, leaf, and extension from a valid path

Does it make sense to start saving into a 401k, if you might move out of the US before retirement?

How is it believable that Euron could so easily pull off this ambush?

While drilling into kitchen wall, hit a wire - any advice?

Why can’t you see at the start of the Big Bang?

How to increase row height of a table and vertically "align middle"?

How do I minimise waste on a flight?

What's weird about Proto-Indo-European Stops?

Game artist computer workstation set-up – is this overkill?

Scaling rounded rectangles in Illustrator

Does this website provide consistent translation into Wookiee?

shebang or not shebang

Is there a reason why Turkey took the Balkan territories of the Ottoman Empire, instead of Greece or another of the Balkan states?

Musical Shape on music stand

Can you just subtract the challenge rating of friendly NPCs?

My C Drive is full without reason

I want to write a blog post building upon someone else's paper, how can I properly cite/credit them?

LiOH hydrolysis of methyl 2,2-dimethoxyacetate not giving product?

Why did Dr. Strange keep looking into the future after the snap?

Is throwing dice a stochastic or a deterministic process?

Clauses with 3 infinitives at the end



Add product custom options in rest/V1/orders


Export custom option via REST interfaceRest API - how to get custom attributesTrying to add an order_item attribute into the REST APIHow to get the bundle product options via SOAP api?Magento 2 rest api - get orders with products' custom attributesHow to create complex search filters while doing a GET on sales orders through Magento 2 REST API?how to use Search rest api in magento 2?Trying to add product with description via RESTMagento2: Get all orders using REST API?Get pending orders for a specific customer using REST API Magento 2Problem adding attribute options to configurable product via REST Api






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








3















I want to get product custom options in ordered items by rest/V1/orders.
If i use searchCriteria, i received all custom options enter image description here



but in another way i can't resieved custom options. Which method i must extend ?










share|improve this question






















  • Did you find a solution?

    – Alex
    Sep 24 '18 at 8:33











  • @Alex yes i found

    – omelandr
    Sep 25 '18 at 9:03











  • like this ? magento.stackexchange.com/questions/243442/… @omelandr

    – Alex
    Sep 25 '18 at 10:15






  • 1





    @Alex yes, extenison attributes see my answer

    – omelandr
    Sep 25 '18 at 13:35











  • @omelandr this does not work for me .....

    – Kashif
    May 3 at 14:12

















3















I want to get product custom options in ordered items by rest/V1/orders.
If i use searchCriteria, i received all custom options enter image description here



but in another way i can't resieved custom options. Which method i must extend ?










share|improve this question






















  • Did you find a solution?

    – Alex
    Sep 24 '18 at 8:33











  • @Alex yes i found

    – omelandr
    Sep 25 '18 at 9:03











  • like this ? magento.stackexchange.com/questions/243442/… @omelandr

    – Alex
    Sep 25 '18 at 10:15






  • 1





    @Alex yes, extenison attributes see my answer

    – omelandr
    Sep 25 '18 at 13:35











  • @omelandr this does not work for me .....

    – Kashif
    May 3 at 14:12













3












3








3








I want to get product custom options in ordered items by rest/V1/orders.
If i use searchCriteria, i received all custom options enter image description here



but in another way i can't resieved custom options. Which method i must extend ?










share|improve this question














I want to get product custom options in ordered items by rest/V1/orders.
If i use searchCriteria, i received all custom options enter image description here



but in another way i can't resieved custom options. Which method i must extend ?







magento2 api






share|improve this question













share|improve this question











share|improve this question




share|improve this question










asked Jan 9 '18 at 10:13









omelandromelandr

6071822




6071822












  • Did you find a solution?

    – Alex
    Sep 24 '18 at 8:33











  • @Alex yes i found

    – omelandr
    Sep 25 '18 at 9:03











  • like this ? magento.stackexchange.com/questions/243442/… @omelandr

    – Alex
    Sep 25 '18 at 10:15






  • 1





    @Alex yes, extenison attributes see my answer

    – omelandr
    Sep 25 '18 at 13:35











  • @omelandr this does not work for me .....

    – Kashif
    May 3 at 14:12

















  • Did you find a solution?

    – Alex
    Sep 24 '18 at 8:33











  • @Alex yes i found

    – omelandr
    Sep 25 '18 at 9:03











  • like this ? magento.stackexchange.com/questions/243442/… @omelandr

    – Alex
    Sep 25 '18 at 10:15






  • 1





    @Alex yes, extenison attributes see my answer

    – omelandr
    Sep 25 '18 at 13:35











  • @omelandr this does not work for me .....

    – Kashif
    May 3 at 14:12
















Did you find a solution?

– Alex
Sep 24 '18 at 8:33





Did you find a solution?

– Alex
Sep 24 '18 at 8:33













@Alex yes i found

– omelandr
Sep 25 '18 at 9:03





@Alex yes i found

– omelandr
Sep 25 '18 at 9:03













like this ? magento.stackexchange.com/questions/243442/… @omelandr

– Alex
Sep 25 '18 at 10:15





like this ? magento.stackexchange.com/questions/243442/… @omelandr

– Alex
Sep 25 '18 at 10:15




1




1





@Alex yes, extenison attributes see my answer

– omelandr
Sep 25 '18 at 13:35





@Alex yes, extenison attributes see my answer

– omelandr
Sep 25 '18 at 13:35













@omelandr this does not work for me .....

– Kashif
May 3 at 14:12





@omelandr this does not work for me .....

– Kashif
May 3 at 14:12










1 Answer
1






active

oldest

votes


















1














in my extension i've created file etc/extension_attributes.xml with content



 <?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="MagentoSalesApiDataOrderItemInterface">
<attribute code="voc_price" type="string"/>
</extension_attributes>
</config>


create plugin



<type name="MagentoSalesApiOrderRepositoryInterface">
<plugin name="custom_attributes_voc_discount" type="VendorExtensionPluginOrderGet"/>
</type>


OrderGet.php



<?php

namespace VendorExtensionPlugin;

use MagentoCatalogModelProductFactory;

class OrderGet

/** @var MagentoSalesApiDataOrderExtensionFactory */
protected $orderExtensionFactory;

/** @var MagentoSalesApiDataOrderItemExtensionFactory */
protected $orderItemExtensionFactory;

public function __construct(
MagentoSalesApiDataOrderExtensionFactory $orderExtensionFactory,
MagentoSalesApiDataOrderItemExtensionFactory $orderItemExtensionFactory
)
$this->orderExtensionFactory = $orderExtensionFactory;
$this->orderItemExtensionFactory = $orderItemExtensionFactory;




public function afterGet(
MagentoSalesApiOrderRepositoryInterface $subject,
MagentoSalesApiDataOrderInterface $resultOrder
)
$resultOrder = $this->getExtensionAttributesItem($resultOrder);
return $resultOrder;



protected function getExtensionAttributesItem(MagentoSalesApiDataOrderInterface $order)

$orderItems = $order->getItems();
if (null !== $orderItems)
/** @var MagentoSalesApiDataOrderItemInterface $orderItem */
foreach ($orderItems as $orderItem)
$extensionAttributes = $orderItem->getExtensionAttributes();
if ($extensionAttributes && $extensionAttributes->getVocPrice())
continue;

$vocPrice = '5';
/** @var MagentoSalesApiDataOrderItemExtension $orderItemExtension */
$orderItemExtension = $extensionAttributes
? $extensionAttributes
: $this->orderItemExtensionFactory->create();
if($vocPrice)
$orderItemExtension->setVocPrice($vocPrice);


$orderItem->setExtensionAttributes($orderItemExtension);


return $order;




public function afterGetList(
MagentoSalesApiOrderRepositoryInterface $subject,
MagentoSalesModelResourceModelOrderCollection $resultOrder
)
foreach ($resultOrder->getItems() as $order)
$this->afterGet($subject, $order);


return $resultOrder;







share|improve this answer























    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%2f208670%2fadd-product-custom-options-in-rest-v1-orders%23new-answer', 'question_page');

    );

    Post as a guest















    Required, but never shown

























    1 Answer
    1






    active

    oldest

    votes








    1 Answer
    1






    active

    oldest

    votes









    active

    oldest

    votes






    active

    oldest

    votes









    1














    in my extension i've created file etc/extension_attributes.xml with content



     <?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="MagentoSalesApiDataOrderItemInterface">
    <attribute code="voc_price" type="string"/>
    </extension_attributes>
    </config>


    create plugin



    <type name="MagentoSalesApiOrderRepositoryInterface">
    <plugin name="custom_attributes_voc_discount" type="VendorExtensionPluginOrderGet"/>
    </type>


    OrderGet.php



    <?php

    namespace VendorExtensionPlugin;

    use MagentoCatalogModelProductFactory;

    class OrderGet

    /** @var MagentoSalesApiDataOrderExtensionFactory */
    protected $orderExtensionFactory;

    /** @var MagentoSalesApiDataOrderItemExtensionFactory */
    protected $orderItemExtensionFactory;

    public function __construct(
    MagentoSalesApiDataOrderExtensionFactory $orderExtensionFactory,
    MagentoSalesApiDataOrderItemExtensionFactory $orderItemExtensionFactory
    )
    $this->orderExtensionFactory = $orderExtensionFactory;
    $this->orderItemExtensionFactory = $orderItemExtensionFactory;




    public function afterGet(
    MagentoSalesApiOrderRepositoryInterface $subject,
    MagentoSalesApiDataOrderInterface $resultOrder
    )
    $resultOrder = $this->getExtensionAttributesItem($resultOrder);
    return $resultOrder;



    protected function getExtensionAttributesItem(MagentoSalesApiDataOrderInterface $order)

    $orderItems = $order->getItems();
    if (null !== $orderItems)
    /** @var MagentoSalesApiDataOrderItemInterface $orderItem */
    foreach ($orderItems as $orderItem)
    $extensionAttributes = $orderItem->getExtensionAttributes();
    if ($extensionAttributes && $extensionAttributes->getVocPrice())
    continue;

    $vocPrice = '5';
    /** @var MagentoSalesApiDataOrderItemExtension $orderItemExtension */
    $orderItemExtension = $extensionAttributes
    ? $extensionAttributes
    : $this->orderItemExtensionFactory->create();
    if($vocPrice)
    $orderItemExtension->setVocPrice($vocPrice);


    $orderItem->setExtensionAttributes($orderItemExtension);


    return $order;




    public function afterGetList(
    MagentoSalesApiOrderRepositoryInterface $subject,
    MagentoSalesModelResourceModelOrderCollection $resultOrder
    )
    foreach ($resultOrder->getItems() as $order)
    $this->afterGet($subject, $order);


    return $resultOrder;







    share|improve this answer



























      1














      in my extension i've created file etc/extension_attributes.xml with content



       <?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="MagentoSalesApiDataOrderItemInterface">
      <attribute code="voc_price" type="string"/>
      </extension_attributes>
      </config>


      create plugin



      <type name="MagentoSalesApiOrderRepositoryInterface">
      <plugin name="custom_attributes_voc_discount" type="VendorExtensionPluginOrderGet"/>
      </type>


      OrderGet.php



      <?php

      namespace VendorExtensionPlugin;

      use MagentoCatalogModelProductFactory;

      class OrderGet

      /** @var MagentoSalesApiDataOrderExtensionFactory */
      protected $orderExtensionFactory;

      /** @var MagentoSalesApiDataOrderItemExtensionFactory */
      protected $orderItemExtensionFactory;

      public function __construct(
      MagentoSalesApiDataOrderExtensionFactory $orderExtensionFactory,
      MagentoSalesApiDataOrderItemExtensionFactory $orderItemExtensionFactory
      )
      $this->orderExtensionFactory = $orderExtensionFactory;
      $this->orderItemExtensionFactory = $orderItemExtensionFactory;




      public function afterGet(
      MagentoSalesApiOrderRepositoryInterface $subject,
      MagentoSalesApiDataOrderInterface $resultOrder
      )
      $resultOrder = $this->getExtensionAttributesItem($resultOrder);
      return $resultOrder;



      protected function getExtensionAttributesItem(MagentoSalesApiDataOrderInterface $order)

      $orderItems = $order->getItems();
      if (null !== $orderItems)
      /** @var MagentoSalesApiDataOrderItemInterface $orderItem */
      foreach ($orderItems as $orderItem)
      $extensionAttributes = $orderItem->getExtensionAttributes();
      if ($extensionAttributes && $extensionAttributes->getVocPrice())
      continue;

      $vocPrice = '5';
      /** @var MagentoSalesApiDataOrderItemExtension $orderItemExtension */
      $orderItemExtension = $extensionAttributes
      ? $extensionAttributes
      : $this->orderItemExtensionFactory->create();
      if($vocPrice)
      $orderItemExtension->setVocPrice($vocPrice);


      $orderItem->setExtensionAttributes($orderItemExtension);


      return $order;




      public function afterGetList(
      MagentoSalesApiOrderRepositoryInterface $subject,
      MagentoSalesModelResourceModelOrderCollection $resultOrder
      )
      foreach ($resultOrder->getItems() as $order)
      $this->afterGet($subject, $order);


      return $resultOrder;







      share|improve this answer

























        1












        1








        1







        in my extension i've created file etc/extension_attributes.xml with content



         <?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="MagentoSalesApiDataOrderItemInterface">
        <attribute code="voc_price" type="string"/>
        </extension_attributes>
        </config>


        create plugin



        <type name="MagentoSalesApiOrderRepositoryInterface">
        <plugin name="custom_attributes_voc_discount" type="VendorExtensionPluginOrderGet"/>
        </type>


        OrderGet.php



        <?php

        namespace VendorExtensionPlugin;

        use MagentoCatalogModelProductFactory;

        class OrderGet

        /** @var MagentoSalesApiDataOrderExtensionFactory */
        protected $orderExtensionFactory;

        /** @var MagentoSalesApiDataOrderItemExtensionFactory */
        protected $orderItemExtensionFactory;

        public function __construct(
        MagentoSalesApiDataOrderExtensionFactory $orderExtensionFactory,
        MagentoSalesApiDataOrderItemExtensionFactory $orderItemExtensionFactory
        )
        $this->orderExtensionFactory = $orderExtensionFactory;
        $this->orderItemExtensionFactory = $orderItemExtensionFactory;




        public function afterGet(
        MagentoSalesApiOrderRepositoryInterface $subject,
        MagentoSalesApiDataOrderInterface $resultOrder
        )
        $resultOrder = $this->getExtensionAttributesItem($resultOrder);
        return $resultOrder;



        protected function getExtensionAttributesItem(MagentoSalesApiDataOrderInterface $order)

        $orderItems = $order->getItems();
        if (null !== $orderItems)
        /** @var MagentoSalesApiDataOrderItemInterface $orderItem */
        foreach ($orderItems as $orderItem)
        $extensionAttributes = $orderItem->getExtensionAttributes();
        if ($extensionAttributes && $extensionAttributes->getVocPrice())
        continue;

        $vocPrice = '5';
        /** @var MagentoSalesApiDataOrderItemExtension $orderItemExtension */
        $orderItemExtension = $extensionAttributes
        ? $extensionAttributes
        : $this->orderItemExtensionFactory->create();
        if($vocPrice)
        $orderItemExtension->setVocPrice($vocPrice);


        $orderItem->setExtensionAttributes($orderItemExtension);


        return $order;




        public function afterGetList(
        MagentoSalesApiOrderRepositoryInterface $subject,
        MagentoSalesModelResourceModelOrderCollection $resultOrder
        )
        foreach ($resultOrder->getItems() as $order)
        $this->afterGet($subject, $order);


        return $resultOrder;







        share|improve this answer













        in my extension i've created file etc/extension_attributes.xml with content



         <?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="MagentoSalesApiDataOrderItemInterface">
        <attribute code="voc_price" type="string"/>
        </extension_attributes>
        </config>


        create plugin



        <type name="MagentoSalesApiOrderRepositoryInterface">
        <plugin name="custom_attributes_voc_discount" type="VendorExtensionPluginOrderGet"/>
        </type>


        OrderGet.php



        <?php

        namespace VendorExtensionPlugin;

        use MagentoCatalogModelProductFactory;

        class OrderGet

        /** @var MagentoSalesApiDataOrderExtensionFactory */
        protected $orderExtensionFactory;

        /** @var MagentoSalesApiDataOrderItemExtensionFactory */
        protected $orderItemExtensionFactory;

        public function __construct(
        MagentoSalesApiDataOrderExtensionFactory $orderExtensionFactory,
        MagentoSalesApiDataOrderItemExtensionFactory $orderItemExtensionFactory
        )
        $this->orderExtensionFactory = $orderExtensionFactory;
        $this->orderItemExtensionFactory = $orderItemExtensionFactory;




        public function afterGet(
        MagentoSalesApiOrderRepositoryInterface $subject,
        MagentoSalesApiDataOrderInterface $resultOrder
        )
        $resultOrder = $this->getExtensionAttributesItem($resultOrder);
        return $resultOrder;



        protected function getExtensionAttributesItem(MagentoSalesApiDataOrderInterface $order)

        $orderItems = $order->getItems();
        if (null !== $orderItems)
        /** @var MagentoSalesApiDataOrderItemInterface $orderItem */
        foreach ($orderItems as $orderItem)
        $extensionAttributes = $orderItem->getExtensionAttributes();
        if ($extensionAttributes && $extensionAttributes->getVocPrice())
        continue;

        $vocPrice = '5';
        /** @var MagentoSalesApiDataOrderItemExtension $orderItemExtension */
        $orderItemExtension = $extensionAttributes
        ? $extensionAttributes
        : $this->orderItemExtensionFactory->create();
        if($vocPrice)
        $orderItemExtension->setVocPrice($vocPrice);


        $orderItem->setExtensionAttributes($orderItemExtension);


        return $order;




        public function afterGetList(
        MagentoSalesApiOrderRepositoryInterface $subject,
        MagentoSalesModelResourceModelOrderCollection $resultOrder
        )
        foreach ($resultOrder->getItems() as $order)
        $this->afterGet($subject, $order);


        return $resultOrder;








        share|improve this answer












        share|improve this answer



        share|improve this answer










        answered Sep 25 '18 at 13:45









        omelandromelandr

        6071822




        6071822



























            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%2f208670%2fadd-product-custom-options-in-rest-v1-orders%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

            Grendel Contents Story Scholarship Depictions Notes References Navigation menu10.1093/notesj/gjn112Berserkeree

            Area configuration aggregation error after install Porto themeMagento 2.1 CE Installed but front/backend not loading/workingCSS not loading on page within Magento 2 pageCannot install module in Magento 2no commands defined in the “setup” namespace. in Magento2Magento 2: Static files are present but shows 404Why do i have to always run the commands to clean cache in Magento 2.1.8?Failure reason: 'Unable to unserialize value.'Error 500 after magento migrationIn production mode the site does not loadMagento 2 : Error 500 after installing

            Middle Expansion Olielle Resaix Definition: Uttering songs of triumph shouting with joy triumphant exulting Sejunction Journal 붙다 달 고급 품목 외출 The stretch trades the screeching tin. Definition: The act of speaking with a drawl a drawl Cough Sand Definition: An uproar a quarrel a noisy outbreak Shake Iron Publicize Horse House Baby 사과 Resaix Flaggy Jelly Temporary Unequaled Puppet A drop in the bucket Shrew 성격 회원 성질 미팅 The burn frames the tacky quality. Materialistic The smoke reduces the way. Yammoe Nondescript Cheek 얼굴 배 약하다 날리다 타다 The illegal country shows the iron. Help Rule Drearien Smoke Teaching Meaty Wasp Abraham Lincoln Jaws 진심 수리하다 Size Cork Idea Convert Think Lark John Lennon 거울 청소 군 추천하다 아이스크림