Get order item collection from payment magento 2How to get order from customer Magento 2?Magento 2: Get quantity item from the orderMagento 2 Access shipping code from Payment MouleMagento 2: unable to set payment Transaction Id after successful payment processing (solved by myself)Magento 2 get and set Qty of product with observerGet Quote from Order Success ObserverHow to get admin order items from admin order quoteMagento 2, How to get Payment infoInterface from order?Magento2 : On update of quote item price i am not able to get payment method on payment stepGet new field address in the payment module (capture function). M2.2.4

What makes Ada the language of choice for the ISS's safety-critical systems?

Why did the Herschel Space Telescope need helium coolant?

Second (easy access) account in case my bank screws up

Confusion around using "des" in sentences

What is the highest possible permanent AC at character creation?

Grover algorithm for a database search: where is the quantum advantage?

Difference between > and >> when used with a named pipe

Is using haveibeenpwned to validate password strength rational?

1980s live-action movie where individually-coloured nations on clouds fight

bash script: "*.jpg" expansion not working as expected inside $(...), for picking a random file

What to do when surprise and a high initiative roll conflict with the narrative?

Fixing obscure 8080 emulator bug?

What makes an item an artifact?

Do simulator games use a realistic trajectory to get into orbit?

This riddle is not to see but to solve

Would the US government be able to hold control if all electronics were disabled for an indefinite amount of time?

How to handle self harm scars on the arm in work environment?

How is water heavier than petrol, even though its molecular weight is less than petrol?

Are there downsides to using std::string as a buffer?

How to hide an urban landmark?

Déjà vu, again?

Using "subway" as name for London Underground?

What is wrong with this proof that symmetric matrices commute?

Find the limit of a multiplying term function when n tends to infinity.



Get order item collection from payment magento 2


How to get order from customer Magento 2?Magento 2: Get quantity item from the orderMagento 2 Access shipping code from Payment MouleMagento 2: unable to set payment Transaction Id after successful payment processing (solved by myself)Magento 2 get and set Qty of product with observerGet Quote from Order Success ObserverHow to get admin order items from admin order quoteMagento 2, How to get Payment infoInterface from order?Magento2 : On update of quote item price i am not able to get payment method on payment stepGet new field address in the payment module (capture function). M2.2.4






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








1















How to get itemCollection from Payment ?



I get getOrder() on null for the below code



$payment = $observer->getEvent()->getPayment(); 
$items = $payment->getOrder()->getItemsCollection();









share|improve this question






















  • Where you try to get order information?

    – Sohel Rana
    Jul 27 '16 at 8:16











  • When order is completed during the sales_order_payment_place_end event

    – Sushivam
    Jul 27 '16 at 8:54











  • can you please share full information in question or event details?

    – Abdul
    Dec 5 '17 at 12:44


















1















How to get itemCollection from Payment ?



I get getOrder() on null for the below code



$payment = $observer->getEvent()->getPayment(); 
$items = $payment->getOrder()->getItemsCollection();









share|improve this question






















  • Where you try to get order information?

    – Sohel Rana
    Jul 27 '16 at 8:16











  • When order is completed during the sales_order_payment_place_end event

    – Sushivam
    Jul 27 '16 at 8:54











  • can you please share full information in question or event details?

    – Abdul
    Dec 5 '17 at 12:44














1












1








1


1






How to get itemCollection from Payment ?



I get getOrder() on null for the below code



$payment = $observer->getEvent()->getPayment(); 
$items = $payment->getOrder()->getItemsCollection();









share|improve this question














How to get itemCollection from Payment ?



I get getOrder() on null for the below code



$payment = $observer->getEvent()->getPayment(); 
$items = $payment->getOrder()->getItemsCollection();






magento2






share|improve this question













share|improve this question











share|improve this question




share|improve this question










asked Jul 27 '16 at 8:02









SushivamSushivam

1,25921849




1,25921849












  • Where you try to get order information?

    – Sohel Rana
    Jul 27 '16 at 8:16











  • When order is completed during the sales_order_payment_place_end event

    – Sushivam
    Jul 27 '16 at 8:54











  • can you please share full information in question or event details?

    – Abdul
    Dec 5 '17 at 12:44


















  • Where you try to get order information?

    – Sohel Rana
    Jul 27 '16 at 8:16











  • When order is completed during the sales_order_payment_place_end event

    – Sushivam
    Jul 27 '16 at 8:54











  • can you please share full information in question or event details?

    – Abdul
    Dec 5 '17 at 12:44

















Where you try to get order information?

– Sohel Rana
Jul 27 '16 at 8:16





Where you try to get order information?

– Sohel Rana
Jul 27 '16 at 8:16













When order is completed during the sales_order_payment_place_end event

– Sushivam
Jul 27 '16 at 8:54





When order is completed during the sales_order_payment_place_end event

– Sushivam
Jul 27 '16 at 8:54













can you please share full information in question or event details?

– Abdul
Dec 5 '17 at 12:44






can you please share full information in question or event details?

– Abdul
Dec 5 '17 at 12:44











2 Answers
2






active

oldest

votes


















1














you can get first order id after getting order id load product,



$orderid = $payment->getOrder()->getId()

$orderItems = $order->getAllItems();


public function __construct(
..
MagentoSalesModelOrder $order,
...
)
$this->order = $order;


public function getOrderItems()

$order=$this->order->load($orderId);

return $orderItems = $order->getAllItems();






share|improve this answer























  • Rakesh, could you please tell how to do the above in this magento.stackexchange.com/questions/127636/… in my VendorModuleModelEngine.php, cause im trying the above code during the sales_order_payment_place_end event

    – Sushivam
    Jul 27 '16 at 9:00












  • have you check your order id is getting or not? if order id is getting then you can do above way

    – Rakesh Jesadiya
    Jul 27 '16 at 9:06











  • No im not getting, the moment i m trying to update a product in backend, i get Call to a member function getOrder() on null in C:xampphtdocsmagento2x_3appcodeVendorModuleModelEngine.php on line 158

    – Sushivam
    Jul 27 '16 at 9:11











  • Any update @Rakesh

    – Sushivam
    Jul 27 '16 at 9:22











  • no idea for that

    – Rakesh Jesadiya
    Jul 27 '16 at 9:45


















1














Try following way:




$payment = $observer->getPayment();
$order = $payment->getOrder();

$items = $order->getAllVisibleItems();
foreach ($items as $item)
error_log($item->getProductId());
error_log($item->getSku());






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%2f127644%2fget-order-item-collection-from-payment-magento-2%23new-answer', 'question_page');

    );

    Post as a guest















    Required, but never shown

























    2 Answers
    2






    active

    oldest

    votes








    2 Answers
    2






    active

    oldest

    votes









    active

    oldest

    votes






    active

    oldest

    votes









    1














    you can get first order id after getting order id load product,



    $orderid = $payment->getOrder()->getId()

    $orderItems = $order->getAllItems();


    public function __construct(
    ..
    MagentoSalesModelOrder $order,
    ...
    )
    $this->order = $order;


    public function getOrderItems()

    $order=$this->order->load($orderId);

    return $orderItems = $order->getAllItems();






    share|improve this answer























    • Rakesh, could you please tell how to do the above in this magento.stackexchange.com/questions/127636/… in my VendorModuleModelEngine.php, cause im trying the above code during the sales_order_payment_place_end event

      – Sushivam
      Jul 27 '16 at 9:00












    • have you check your order id is getting or not? if order id is getting then you can do above way

      – Rakesh Jesadiya
      Jul 27 '16 at 9:06











    • No im not getting, the moment i m trying to update a product in backend, i get Call to a member function getOrder() on null in C:xampphtdocsmagento2x_3appcodeVendorModuleModelEngine.php on line 158

      – Sushivam
      Jul 27 '16 at 9:11











    • Any update @Rakesh

      – Sushivam
      Jul 27 '16 at 9:22











    • no idea for that

      – Rakesh Jesadiya
      Jul 27 '16 at 9:45















    1














    you can get first order id after getting order id load product,



    $orderid = $payment->getOrder()->getId()

    $orderItems = $order->getAllItems();


    public function __construct(
    ..
    MagentoSalesModelOrder $order,
    ...
    )
    $this->order = $order;


    public function getOrderItems()

    $order=$this->order->load($orderId);

    return $orderItems = $order->getAllItems();






    share|improve this answer























    • Rakesh, could you please tell how to do the above in this magento.stackexchange.com/questions/127636/… in my VendorModuleModelEngine.php, cause im trying the above code during the sales_order_payment_place_end event

      – Sushivam
      Jul 27 '16 at 9:00












    • have you check your order id is getting or not? if order id is getting then you can do above way

      – Rakesh Jesadiya
      Jul 27 '16 at 9:06











    • No im not getting, the moment i m trying to update a product in backend, i get Call to a member function getOrder() on null in C:xampphtdocsmagento2x_3appcodeVendorModuleModelEngine.php on line 158

      – Sushivam
      Jul 27 '16 at 9:11











    • Any update @Rakesh

      – Sushivam
      Jul 27 '16 at 9:22











    • no idea for that

      – Rakesh Jesadiya
      Jul 27 '16 at 9:45













    1












    1








    1







    you can get first order id after getting order id load product,



    $orderid = $payment->getOrder()->getId()

    $orderItems = $order->getAllItems();


    public function __construct(
    ..
    MagentoSalesModelOrder $order,
    ...
    )
    $this->order = $order;


    public function getOrderItems()

    $order=$this->order->load($orderId);

    return $orderItems = $order->getAllItems();






    share|improve this answer













    you can get first order id after getting order id load product,



    $orderid = $payment->getOrder()->getId()

    $orderItems = $order->getAllItems();


    public function __construct(
    ..
    MagentoSalesModelOrder $order,
    ...
    )
    $this->order = $order;


    public function getOrderItems()

    $order=$this->order->load($orderId);

    return $orderItems = $order->getAllItems();







    share|improve this answer












    share|improve this answer



    share|improve this answer










    answered Jul 27 '16 at 8:57









    Rakesh JesadiyaRakesh Jesadiya

    30.6k1578130




    30.6k1578130












    • Rakesh, could you please tell how to do the above in this magento.stackexchange.com/questions/127636/… in my VendorModuleModelEngine.php, cause im trying the above code during the sales_order_payment_place_end event

      – Sushivam
      Jul 27 '16 at 9:00












    • have you check your order id is getting or not? if order id is getting then you can do above way

      – Rakesh Jesadiya
      Jul 27 '16 at 9:06











    • No im not getting, the moment i m trying to update a product in backend, i get Call to a member function getOrder() on null in C:xampphtdocsmagento2x_3appcodeVendorModuleModelEngine.php on line 158

      – Sushivam
      Jul 27 '16 at 9:11











    • Any update @Rakesh

      – Sushivam
      Jul 27 '16 at 9:22











    • no idea for that

      – Rakesh Jesadiya
      Jul 27 '16 at 9:45

















    • Rakesh, could you please tell how to do the above in this magento.stackexchange.com/questions/127636/… in my VendorModuleModelEngine.php, cause im trying the above code during the sales_order_payment_place_end event

      – Sushivam
      Jul 27 '16 at 9:00












    • have you check your order id is getting or not? if order id is getting then you can do above way

      – Rakesh Jesadiya
      Jul 27 '16 at 9:06











    • No im not getting, the moment i m trying to update a product in backend, i get Call to a member function getOrder() on null in C:xampphtdocsmagento2x_3appcodeVendorModuleModelEngine.php on line 158

      – Sushivam
      Jul 27 '16 at 9:11











    • Any update @Rakesh

      – Sushivam
      Jul 27 '16 at 9:22











    • no idea for that

      – Rakesh Jesadiya
      Jul 27 '16 at 9:45
















    Rakesh, could you please tell how to do the above in this magento.stackexchange.com/questions/127636/… in my VendorModuleModelEngine.php, cause im trying the above code during the sales_order_payment_place_end event

    – Sushivam
    Jul 27 '16 at 9:00






    Rakesh, could you please tell how to do the above in this magento.stackexchange.com/questions/127636/… in my VendorModuleModelEngine.php, cause im trying the above code during the sales_order_payment_place_end event

    – Sushivam
    Jul 27 '16 at 9:00














    have you check your order id is getting or not? if order id is getting then you can do above way

    – Rakesh Jesadiya
    Jul 27 '16 at 9:06





    have you check your order id is getting or not? if order id is getting then you can do above way

    – Rakesh Jesadiya
    Jul 27 '16 at 9:06













    No im not getting, the moment i m trying to update a product in backend, i get Call to a member function getOrder() on null in C:xampphtdocsmagento2x_3appcodeVendorModuleModelEngine.php on line 158

    – Sushivam
    Jul 27 '16 at 9:11





    No im not getting, the moment i m trying to update a product in backend, i get Call to a member function getOrder() on null in C:xampphtdocsmagento2x_3appcodeVendorModuleModelEngine.php on line 158

    – Sushivam
    Jul 27 '16 at 9:11













    Any update @Rakesh

    – Sushivam
    Jul 27 '16 at 9:22





    Any update @Rakesh

    – Sushivam
    Jul 27 '16 at 9:22













    no idea for that

    – Rakesh Jesadiya
    Jul 27 '16 at 9:45





    no idea for that

    – Rakesh Jesadiya
    Jul 27 '16 at 9:45













    1














    Try following way:




    $payment = $observer->getPayment();
    $order = $payment->getOrder();

    $items = $order->getAllVisibleItems();
    foreach ($items as $item)
    error_log($item->getProductId());
    error_log($item->getSku());






    share|improve this answer



























      1














      Try following way:




      $payment = $observer->getPayment();
      $order = $payment->getOrder();

      $items = $order->getAllVisibleItems();
      foreach ($items as $item)
      error_log($item->getProductId());
      error_log($item->getSku());






      share|improve this answer

























        1












        1








        1







        Try following way:




        $payment = $observer->getPayment();
        $order = $payment->getOrder();

        $items = $order->getAllVisibleItems();
        foreach ($items as $item)
        error_log($item->getProductId());
        error_log($item->getSku());






        share|improve this answer













        Try following way:




        $payment = $observer->getPayment();
        $order = $payment->getOrder();

        $items = $order->getAllVisibleItems();
        foreach ($items as $item)
        error_log($item->getProductId());
        error_log($item->getSku());







        share|improve this answer












        share|improve this answer



        share|improve this answer










        answered Jul 27 '16 at 10:05









        Sohel RanaSohel Rana

        24.3k34664




        24.3k34664



























            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%2f127644%2fget-order-item-collection-from-payment-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

            Category:9 (number) SubcategoriesMedia in category "9 (number)"Navigation menuUpload mediaGND ID: 4485639-8Library of Congress authority ID: sh85091979ReasonatorScholiaStatistics

            Circuit construction for execution of conditional statements using least significant bitHow are two different registers being used as “control”?How exactly is the stated composite state of the two registers being produced using the $R_zz$ controlled rotations?Efficiently performing controlled rotations in HHLWould this quantum algorithm implementation work?How to prepare a superposed states of odd integers from $1$ to $sqrtN$?Why is this implementation of the order finding algorithm not working?Circuit construction for Hamiltonian simulationHow can I invert the least significant bit of a certain term of a superposed state?Implementing an oracleImplementing a controlled sum operation

            Magento 2 “No Payment Methods” in Admin New OrderHow to integrate Paypal Express Checkout with the Magento APIMagento 1.5 - Sales > Order > edit order and shipping methods disappearAuto Invoice Check/Money Order Payment methodAdd more simple payment methods?Shipping methods not showingWhat should I do to change payment methods if changing the configuration has no effects?1.9 - No Payment Methods showing upMy Payment Methods not Showing for downloadable/virtual product when checkout?Magento2 API to access internal payment methodHow to call an existing payment methods in the registration form?