How to get 5 latest order in home page in Magento 2? Planned maintenance scheduled April 17/18, 2019 at 00:00UTC (8:00pm US/Eastern) Announcing the arrival of Valued Associate #679: Cesar Manara Unicorn Meta Zoo #1: Why another podcast?Magento 2 get product details in product review list phtml?Magento 2: How to load admin login on home page?Get Latest Products REST APIHow to show Hamburger icon on magento2 home pageHow to get order data in magento2Magento 2.2.4 : Cart Subtotal, Shipping, Tax and Order Total not showing on checkout order summary sectionMagento 2 - how to get customer entity_id when order is placed rest apiGet customers latest order?How to used brands attribute set on top reating product on show home page?How to get feature product on home page in magento 2 customization?

English words in a non-english sci-fi novel

How to deal with a team lead who never gives me credit?

What's the purpose of writing one's academic biography in the third person?

Why light coming from distant stars is not discreet?

What is Arya's weapon design?

51k Euros annually for a family of 4 in Berlin: Is it enough?

Is it ethical to give a final exam after the professor has quit before teaching the remaining chapters of the course?

Single word antonym of "flightless"

Error "illegal generic type for instanceof" when using local classes

Check which numbers satisfy the condition [A*B*C = A! + B! + C!]

What does "fit" mean in this sentence?

How to call a function with default parameter through a pointer to function that is the return of another function?

Why are Kinder Surprise Eggs illegal in the USA?

What does the "x" in "x86" represent?

Seeking colloquialism for “just because”

How to answer "Have you ever been terminated?"

What is the role of the transistor and diode in a soft start circuit?

How does debian/ubuntu knows a package has a updated version

What to do with chalk when deepwater soloing?

2001: A Space Odyssey's use of the song "Daisy Bell" (Bicycle Built for Two); life imitates art or vice-versa?

Should I use a zero-interest credit card for a large one-time purchase?

Why is my conclusion inconsistent with the van't Hoff equation?

Is there a (better) way to access $wpdb results?

How to tell that you are a giant?



How to get 5 latest order in home page in Magento 2?



Planned maintenance scheduled April 17/18, 2019 at 00:00UTC (8:00pm US/Eastern)
Announcing the arrival of Valued Associate #679: Cesar Manara
Unicorn Meta Zoo #1: Why another podcast?Magento 2 get product details in product review list phtml?Magento 2: How to load admin login on home page?Get Latest Products REST APIHow to show Hamburger icon on magento2 home pageHow to get order data in magento2Magento 2.2.4 : Cart Subtotal, Shipping, Tax and Order Total not showing on checkout order summary sectionMagento 2 - how to get customer entity_id when order is placed rest apiGet customers latest order?How to used brands attribute set on top reating product on show home page?How to get feature product on home page in magento 2 customization?



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








0















How to Get the latest 5 order in home page in Magento2 with all order details?



Any help would be appreciated.










share|improve this question






























    0















    How to Get the latest 5 order in home page in Magento2 with all order details?



    Any help would be appreciated.










    share|improve this question


























      0












      0








      0








      How to Get the latest 5 order in home page in Magento2 with all order details?



      Any help would be appreciated.










      share|improve this question
















      How to Get the latest 5 order in home page in Magento2 with all order details?



      Any help would be appreciated.







      magento2 magento2.3.0 magento2.3.1






      share|improve this question















      share|improve this question













      share|improve this question




      share|improve this question








      edited yesterday









      Sanjay Gohil

      502215




      502215










      asked yesterday









      sanni kalariyasanni kalariya

      1019




      1019




















          2 Answers
          2






          active

          oldest

          votes


















          0














          Try this,



          Create a helper and add the below code to it,



          Helper path be like




          app/code/Vendor/Module/Helper/Data.php




          <?php
          namespace VendorModuleHelper;
          class Data extends MagentoFrameworkAppHelperAbstractHelper

          public function __construct(
          MagentoSalesModelOrderFactory $orderFactory
          )
          $this->orderFactory = $orderFactory;

          public function getCollection()

          $collection = $this->orderFactory->create()->getCollection()->setOrder('entity_id', 'DESC');
          $collection->setPageSize(5)->setCurPage(1);
          return $collection;




          then in your phtml you can call like below



          $order = $this->helper('VendorModuleHelperData')->getCollection();
          foreach($order as $items)
          echo "Entity Id :". $items->getEntityId();
          echo "Order Status :". $items->getStatus();



          you can call any of the phtml in the home page to get this information.



          To call a phtml only on home page follow the below steps



          create a cms_index_index.xml in the below path




          app/code/Vendor/Module/view/frontend/layout/cms_index_index.xml




          then add the below code to it



          <?xml version="1.0"?>
          <page xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:View/Layout/etc/page_configuration.xsd">
          <body>
          <referenceContainer name="content">
          <block class="MagentoFrameworkViewElementTemplate" name="sales_total" template="Vendor_Module::total.phtml">
          </block>
          </referenceContainer>
          </body>
          </page>


          Vendor_Module - this should you namespace_modulename



          And also place total.phtml in the below path




          app/code/Vendor/Module/view/frontend/templates/total.phtml




          Hope this helps.






          share|improve this answer























          • Thanks help to me Prathap .. but I have add echo "Price : ".$items->getPrice(); not show me price ?

            – sanni kalariya
            yesterday











          • You can use it like $items->getSubtotal(); and for more information about attributes see sales_order table and you can get all the information from that table using above method

            – Prathap Gunasekaran
            yesterday











          • If you want a link in for order status means do it like this <a href="order detail page url"><?php echo "Order Status :". $items->getStatus(); ?></a> inside foreach and for more information create a separte question and let others answer to it

            – Prathap Gunasekaran
            yesterday


















          0














          protected $_checkoutSession;
          protected $_orderFactory;
          protected $_scopeConfig;



          public function __construct(
          MagentoCheckoutModelSession $checkoutSession,
          MagentoSalesModelOrderFactory $orderFactory,
          MagentoFrameworkViewElementContext $context
          )
          $this->_checkoutSession = $checkoutSession;
          $this->_orderFactory = $orderFactory;
          $this->_scopeConfig = $context->getScopeConfig();



          // Use this method to get ID
          public function getRealOrderId()

          $lastorderId = $this->_checkoutSession->getLastOrderId();
          return $lastorderId;


          public function getOrder()

          if ($this->_checkoutSession->getLastRealOrderId())
          $order = $this->_orderFactory->create()->loadByIncrementId($this->_checkoutSession->getLastRealOrderId());
          return $order;

          return false;






          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%2f270065%2fhow-to-get-5-latest-order-in-home-page-in-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









            0














            Try this,



            Create a helper and add the below code to it,



            Helper path be like




            app/code/Vendor/Module/Helper/Data.php




            <?php
            namespace VendorModuleHelper;
            class Data extends MagentoFrameworkAppHelperAbstractHelper

            public function __construct(
            MagentoSalesModelOrderFactory $orderFactory
            )
            $this->orderFactory = $orderFactory;

            public function getCollection()

            $collection = $this->orderFactory->create()->getCollection()->setOrder('entity_id', 'DESC');
            $collection->setPageSize(5)->setCurPage(1);
            return $collection;




            then in your phtml you can call like below



            $order = $this->helper('VendorModuleHelperData')->getCollection();
            foreach($order as $items)
            echo "Entity Id :". $items->getEntityId();
            echo "Order Status :". $items->getStatus();



            you can call any of the phtml in the home page to get this information.



            To call a phtml only on home page follow the below steps



            create a cms_index_index.xml in the below path




            app/code/Vendor/Module/view/frontend/layout/cms_index_index.xml




            then add the below code to it



            <?xml version="1.0"?>
            <page xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:View/Layout/etc/page_configuration.xsd">
            <body>
            <referenceContainer name="content">
            <block class="MagentoFrameworkViewElementTemplate" name="sales_total" template="Vendor_Module::total.phtml">
            </block>
            </referenceContainer>
            </body>
            </page>


            Vendor_Module - this should you namespace_modulename



            And also place total.phtml in the below path




            app/code/Vendor/Module/view/frontend/templates/total.phtml




            Hope this helps.






            share|improve this answer























            • Thanks help to me Prathap .. but I have add echo "Price : ".$items->getPrice(); not show me price ?

              – sanni kalariya
              yesterday











            • You can use it like $items->getSubtotal(); and for more information about attributes see sales_order table and you can get all the information from that table using above method

              – Prathap Gunasekaran
              yesterday











            • If you want a link in for order status means do it like this <a href="order detail page url"><?php echo "Order Status :". $items->getStatus(); ?></a> inside foreach and for more information create a separte question and let others answer to it

              – Prathap Gunasekaran
              yesterday















            0














            Try this,



            Create a helper and add the below code to it,



            Helper path be like




            app/code/Vendor/Module/Helper/Data.php




            <?php
            namespace VendorModuleHelper;
            class Data extends MagentoFrameworkAppHelperAbstractHelper

            public function __construct(
            MagentoSalesModelOrderFactory $orderFactory
            )
            $this->orderFactory = $orderFactory;

            public function getCollection()

            $collection = $this->orderFactory->create()->getCollection()->setOrder('entity_id', 'DESC');
            $collection->setPageSize(5)->setCurPage(1);
            return $collection;




            then in your phtml you can call like below



            $order = $this->helper('VendorModuleHelperData')->getCollection();
            foreach($order as $items)
            echo "Entity Id :". $items->getEntityId();
            echo "Order Status :". $items->getStatus();



            you can call any of the phtml in the home page to get this information.



            To call a phtml only on home page follow the below steps



            create a cms_index_index.xml in the below path




            app/code/Vendor/Module/view/frontend/layout/cms_index_index.xml




            then add the below code to it



            <?xml version="1.0"?>
            <page xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:View/Layout/etc/page_configuration.xsd">
            <body>
            <referenceContainer name="content">
            <block class="MagentoFrameworkViewElementTemplate" name="sales_total" template="Vendor_Module::total.phtml">
            </block>
            </referenceContainer>
            </body>
            </page>


            Vendor_Module - this should you namespace_modulename



            And also place total.phtml in the below path




            app/code/Vendor/Module/view/frontend/templates/total.phtml




            Hope this helps.






            share|improve this answer























            • Thanks help to me Prathap .. but I have add echo "Price : ".$items->getPrice(); not show me price ?

              – sanni kalariya
              yesterday











            • You can use it like $items->getSubtotal(); and for more information about attributes see sales_order table and you can get all the information from that table using above method

              – Prathap Gunasekaran
              yesterday











            • If you want a link in for order status means do it like this <a href="order detail page url"><?php echo "Order Status :". $items->getStatus(); ?></a> inside foreach and for more information create a separte question and let others answer to it

              – Prathap Gunasekaran
              yesterday













            0












            0








            0







            Try this,



            Create a helper and add the below code to it,



            Helper path be like




            app/code/Vendor/Module/Helper/Data.php




            <?php
            namespace VendorModuleHelper;
            class Data extends MagentoFrameworkAppHelperAbstractHelper

            public function __construct(
            MagentoSalesModelOrderFactory $orderFactory
            )
            $this->orderFactory = $orderFactory;

            public function getCollection()

            $collection = $this->orderFactory->create()->getCollection()->setOrder('entity_id', 'DESC');
            $collection->setPageSize(5)->setCurPage(1);
            return $collection;




            then in your phtml you can call like below



            $order = $this->helper('VendorModuleHelperData')->getCollection();
            foreach($order as $items)
            echo "Entity Id :". $items->getEntityId();
            echo "Order Status :". $items->getStatus();



            you can call any of the phtml in the home page to get this information.



            To call a phtml only on home page follow the below steps



            create a cms_index_index.xml in the below path




            app/code/Vendor/Module/view/frontend/layout/cms_index_index.xml




            then add the below code to it



            <?xml version="1.0"?>
            <page xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:View/Layout/etc/page_configuration.xsd">
            <body>
            <referenceContainer name="content">
            <block class="MagentoFrameworkViewElementTemplate" name="sales_total" template="Vendor_Module::total.phtml">
            </block>
            </referenceContainer>
            </body>
            </page>


            Vendor_Module - this should you namespace_modulename



            And also place total.phtml in the below path




            app/code/Vendor/Module/view/frontend/templates/total.phtml




            Hope this helps.






            share|improve this answer













            Try this,



            Create a helper and add the below code to it,



            Helper path be like




            app/code/Vendor/Module/Helper/Data.php




            <?php
            namespace VendorModuleHelper;
            class Data extends MagentoFrameworkAppHelperAbstractHelper

            public function __construct(
            MagentoSalesModelOrderFactory $orderFactory
            )
            $this->orderFactory = $orderFactory;

            public function getCollection()

            $collection = $this->orderFactory->create()->getCollection()->setOrder('entity_id', 'DESC');
            $collection->setPageSize(5)->setCurPage(1);
            return $collection;




            then in your phtml you can call like below



            $order = $this->helper('VendorModuleHelperData')->getCollection();
            foreach($order as $items)
            echo "Entity Id :". $items->getEntityId();
            echo "Order Status :". $items->getStatus();



            you can call any of the phtml in the home page to get this information.



            To call a phtml only on home page follow the below steps



            create a cms_index_index.xml in the below path




            app/code/Vendor/Module/view/frontend/layout/cms_index_index.xml




            then add the below code to it



            <?xml version="1.0"?>
            <page xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:View/Layout/etc/page_configuration.xsd">
            <body>
            <referenceContainer name="content">
            <block class="MagentoFrameworkViewElementTemplate" name="sales_total" template="Vendor_Module::total.phtml">
            </block>
            </referenceContainer>
            </body>
            </page>


            Vendor_Module - this should you namespace_modulename



            And also place total.phtml in the below path




            app/code/Vendor/Module/view/frontend/templates/total.phtml




            Hope this helps.







            share|improve this answer












            share|improve this answer



            share|improve this answer










            answered yesterday









            Prathap GunasekaranPrathap Gunasekaran

            1,8721618




            1,8721618












            • Thanks help to me Prathap .. but I have add echo "Price : ".$items->getPrice(); not show me price ?

              – sanni kalariya
              yesterday











            • You can use it like $items->getSubtotal(); and for more information about attributes see sales_order table and you can get all the information from that table using above method

              – Prathap Gunasekaran
              yesterday











            • If you want a link in for order status means do it like this <a href="order detail page url"><?php echo "Order Status :". $items->getStatus(); ?></a> inside foreach and for more information create a separte question and let others answer to it

              – Prathap Gunasekaran
              yesterday

















            • Thanks help to me Prathap .. but I have add echo "Price : ".$items->getPrice(); not show me price ?

              – sanni kalariya
              yesterday











            • You can use it like $items->getSubtotal(); and for more information about attributes see sales_order table and you can get all the information from that table using above method

              – Prathap Gunasekaran
              yesterday











            • If you want a link in for order status means do it like this <a href="order detail page url"><?php echo "Order Status :". $items->getStatus(); ?></a> inside foreach and for more information create a separte question and let others answer to it

              – Prathap Gunasekaran
              yesterday
















            Thanks help to me Prathap .. but I have add echo "Price : ".$items->getPrice(); not show me price ?

            – sanni kalariya
            yesterday





            Thanks help to me Prathap .. but I have add echo "Price : ".$items->getPrice(); not show me price ?

            – sanni kalariya
            yesterday













            You can use it like $items->getSubtotal(); and for more information about attributes see sales_order table and you can get all the information from that table using above method

            – Prathap Gunasekaran
            yesterday





            You can use it like $items->getSubtotal(); and for more information about attributes see sales_order table and you can get all the information from that table using above method

            – Prathap Gunasekaran
            yesterday













            If you want a link in for order status means do it like this <a href="order detail page url"><?php echo "Order Status :". $items->getStatus(); ?></a> inside foreach and for more information create a separte question and let others answer to it

            – Prathap Gunasekaran
            yesterday





            If you want a link in for order status means do it like this <a href="order detail page url"><?php echo "Order Status :". $items->getStatus(); ?></a> inside foreach and for more information create a separte question and let others answer to it

            – Prathap Gunasekaran
            yesterday













            0














            protected $_checkoutSession;
            protected $_orderFactory;
            protected $_scopeConfig;



            public function __construct(
            MagentoCheckoutModelSession $checkoutSession,
            MagentoSalesModelOrderFactory $orderFactory,
            MagentoFrameworkViewElementContext $context
            )
            $this->_checkoutSession = $checkoutSession;
            $this->_orderFactory = $orderFactory;
            $this->_scopeConfig = $context->getScopeConfig();



            // Use this method to get ID
            public function getRealOrderId()

            $lastorderId = $this->_checkoutSession->getLastOrderId();
            return $lastorderId;


            public function getOrder()

            if ($this->_checkoutSession->getLastRealOrderId())
            $order = $this->_orderFactory->create()->loadByIncrementId($this->_checkoutSession->getLastRealOrderId());
            return $order;

            return false;






            share|improve this answer



























              0














              protected $_checkoutSession;
              protected $_orderFactory;
              protected $_scopeConfig;



              public function __construct(
              MagentoCheckoutModelSession $checkoutSession,
              MagentoSalesModelOrderFactory $orderFactory,
              MagentoFrameworkViewElementContext $context
              )
              $this->_checkoutSession = $checkoutSession;
              $this->_orderFactory = $orderFactory;
              $this->_scopeConfig = $context->getScopeConfig();



              // Use this method to get ID
              public function getRealOrderId()

              $lastorderId = $this->_checkoutSession->getLastOrderId();
              return $lastorderId;


              public function getOrder()

              if ($this->_checkoutSession->getLastRealOrderId())
              $order = $this->_orderFactory->create()->loadByIncrementId($this->_checkoutSession->getLastRealOrderId());
              return $order;

              return false;






              share|improve this answer

























                0












                0








                0







                protected $_checkoutSession;
                protected $_orderFactory;
                protected $_scopeConfig;



                public function __construct(
                MagentoCheckoutModelSession $checkoutSession,
                MagentoSalesModelOrderFactory $orderFactory,
                MagentoFrameworkViewElementContext $context
                )
                $this->_checkoutSession = $checkoutSession;
                $this->_orderFactory = $orderFactory;
                $this->_scopeConfig = $context->getScopeConfig();



                // Use this method to get ID
                public function getRealOrderId()

                $lastorderId = $this->_checkoutSession->getLastOrderId();
                return $lastorderId;


                public function getOrder()

                if ($this->_checkoutSession->getLastRealOrderId())
                $order = $this->_orderFactory->create()->loadByIncrementId($this->_checkoutSession->getLastRealOrderId());
                return $order;

                return false;






                share|improve this answer













                protected $_checkoutSession;
                protected $_orderFactory;
                protected $_scopeConfig;



                public function __construct(
                MagentoCheckoutModelSession $checkoutSession,
                MagentoSalesModelOrderFactory $orderFactory,
                MagentoFrameworkViewElementContext $context
                )
                $this->_checkoutSession = $checkoutSession;
                $this->_orderFactory = $orderFactory;
                $this->_scopeConfig = $context->getScopeConfig();



                // Use this method to get ID
                public function getRealOrderId()

                $lastorderId = $this->_checkoutSession->getLastOrderId();
                return $lastorderId;


                public function getOrder()

                if ($this->_checkoutSession->getLastRealOrderId())
                $order = $this->_orderFactory->create()->loadByIncrementId($this->_checkoutSession->getLastRealOrderId());
                return $order;

                return false;







                share|improve this answer












                share|improve this answer



                share|improve this answer










                answered yesterday









                HelenHelen

                12




                12



























                    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%2f270065%2fhow-to-get-5-latest-order-in-home-page-in-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?