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?
Bete Noir -- no dairy
What does an IRS interview request entail when called in to verify expenses for a sole proprietor small business?
Why did the IBM 650 use bi-quinary?
How does debian/ubuntu knows a package has a updated version
Is there a problem creating Diff Backups every hour instead of Logs and DIffs?
porting install scripts : can rpm replace apt?
How widely used is the term Treppenwitz? Is it something that most Germans know?
List of Python versions
Why are Kinder Surprise Eggs illegal in the USA?
Apollo command module space walk?
How to deal with a team lead who never gives me credit?
In predicate logic, does existential quantification (∃) include universal quantification (∀), i.e. can 'some' imply 'all'?
List *all* the tuples!
What is Arya's weapon design?
Can an alien society believe that their star system is the universe?
English words in a non-english sci-fi novel
What is the role of the transistor and diode in a soft start circuit?
What is the meaning of the new sigil in Game of Thrones Season 8 intro?
ListPlot join points by nearest neighbor rather than order
How to call a function with default parameter through a pointer to function that is the return of another function?
Can a USB port passively 'listen only'?
When a candle burns, why does the top of wick glow if bottom of flame is hottest?
Can I cast Passwall to drop an enemy into a 20-foot pit?
Can a non-EU citizen traveling with me come with me through the EU passport line?
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;
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
add a comment |
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
add a comment |
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
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
magento2 magento2.3.0 magento2.3.1
edited yesterday
Sanjay Gohil
502215
502215
asked yesterday
sanni kalariyasanni kalariya
1019
1019
add a comment |
add a comment |
2 Answers
2
active
oldest
votes
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.
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
add a comment |
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;
add a comment |
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
);
);
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
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
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.
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
add a comment |
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.
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
add a comment |
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.
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.
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
add a comment |
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
add a comment |
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;
add a comment |
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;
add a comment |
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;
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;
answered yesterday
HelenHelen
12
12
add a comment |
add a comment |
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.
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
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
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
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