Magento 2 : Get last five order information using DI on homepage?In magento 2 How to get all customer data without using object manager?Magento 2 - Get order PayPal information programmaticallyGet Total Order by a customerMagento 2 product image custom resizeHow to get last ordered product details in Magento 2.2?Magento 2: Sort Product collection by Last update ProductHow to get last order id in Magento 2.3?Get Additional information in the order view payment information sectionMagento 2 : pagination using knockoutHow to get 5 latest order in home page in Magento 2?how to get orders in table form? in magento 2 table form is Order #,Order Date,Order Total,Total Item,Action
Has any spacecraft ever had the ability to directly communicate with civilian air traffic control?
Survey Confirmation - Emphasize the question or the answer?
How to avoid grep command finding commented out strings in the source file?
How can I close a gap between my fence and my neighbor's that's on his side of the property line?
Junior developer struggles: how to communicate with management?
How to get SEEK accessing converted ID via view
You look catfish vs You look like a catfish?
Pressure to defend the relevance of one's area of mathematics
Is there a QGIS plugin that reclassify raster symbology based on current extent?
How did Arya get back her dagger from Sansa?
Transfer over $10k
Can a cyclic Amine form an Amide?
Map one pandas column using two dictionaries
Is this homebrew race based on the Draco Volans lizard species balanced?
What happens if I start too many background jobs?
I’ve officially counted to infinity!
Why do computer-science majors learn calculus?
Field Length Validation for Desktop Application which has maximum 1000 characters
How long can a 35mm film be used/stored before it starts to lose its quality after expiry?
Why is Arya visibly scared in the library in S8E3?
Is balancing necessary on a full-wheel change?
Is Cola "probably the best-known" Latin word in the world? If not, which might it be?
The barbers paradox first order logic formalization
Applying a function to a nested list
Magento 2 : Get last five order information using DI on homepage?
In magento 2 How to get all customer data without using object manager?Magento 2 - Get order PayPal information programmaticallyGet Total Order by a customerMagento 2 product image custom resizeHow to get last ordered product details in Magento 2.2?Magento 2: Sort Product collection by Last update ProductHow to get last order id in Magento 2.3?Get Additional information in the order view payment information sectionMagento 2 : pagination using knockoutHow to get 5 latest order in home page in Magento 2?how to get orders in table form? in magento 2 table form is Order #,Order Date,Order Total,Total Item,Action
.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty margin-bottom:0;
I want to get last 5 order information on home page.
Question : How to get last five order collection information on homepage?
NOTE : Avoid giving answers using object manager.
Any help would be appreciated.
magento2 magento-2.1 magento2.3
add a comment |
I want to get last 5 order information on home page.
Question : How to get last five order collection information on homepage?
NOTE : Avoid giving answers using object manager.
Any help would be appreciated.
magento2 magento-2.1 magento2.3
add a comment |
I want to get last 5 order information on home page.
Question : How to get last five order collection information on homepage?
NOTE : Avoid giving answers using object manager.
Any help would be appreciated.
magento2 magento-2.1 magento2.3
I want to get last 5 order information on home page.
Question : How to get last five order collection information on homepage?
NOTE : Avoid giving answers using object manager.
Any help would be appreciated.
magento2 magento-2.1 magento2.3
magento2 magento-2.1 magento2.3
edited Apr 26 at 11:25
Prathap Gunasekaran
2,1191619
2,1191619
asked Apr 26 at 11:02
sanni kalariyasanni kalariya
1109
1109
add a comment |
add a comment |
2 Answers
2
active
oldest
votes
Try this,
Create a block and add the below code to it,
Block path be like
app/code/Vendor/Module/Block/Orders.php
<?php
namespace VendorModuleBlock;
class Orders extends MagentoFrameworkViewElementTemplate
public function __construct(
MagentoSalesModelOrderFactory $orderFactory
)
$this->orderFactory = $orderFactory;
public function getCollection()
$collection = $this->orderFactory->create()->getCollection()->addFieldToSelect('*')->setOrder('created_at','desc');
$collection->setPageSize(5);
return $collection;
then in your phtml you can call like below
$order_collection = $block->getCollection();
foreach($order_collection as $items)
$items->getId();
$items->getName(); // like this you can get any data from sales_order table information
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::order_total.phtml">
</block>
</referenceContainer>
</body>
</page>
Vendor_Module - this should you namespace_modulename
And also place order_total.phtml in the below path
app/code/Vendor/Module/view/frontend/templates/order_total.phtml
Hope this helps.
hello Prathap I have recevice orders but I have used block folder and in this one file create and call phtml this way I have get any solution for this?
– sanni kalariya
Apr 26 at 12:48
updated for block, you can simple follow the above instruction and hope that will work if not please let me know
– Prathap Gunasekaran
Apr 26 at 13:00
Exception #0 (MagentoFrameworkConfigDomValidationException): Element 'block', attribute 'class': [facet 'pattern'] The value 'WdsCoreoverrideBlockorders' is not accepted by the pattern '[A-Z][_a-zA-Zd]*([A-Z][_a-zA-Zd]*)*'. Line: 713Prathap Gunasekaran I am facing this error
– sanni kalariya
17 hours ago
add a comment |
Please Use below code
<?php
namespace VendorModuleBlock;
class order extends MagentoFrameworkViewElementTemplate
protected $OrderFactory;
public function __construct(
...
MagentoSalesModelOrderFactory $OrderFactory
...
)
...
$this->OrderFactory = $OrderFactory;
...
public function orderCollection()
$orderCollection = $this->OrderFactory->create()->getCollection();
$orderCollection->getSelect()->limit(5);
return $orderCollection;
<?php $orderCollection = $this->orderCollection(); ?> in phtml file this way call
– sanni kalariya
Apr 26 at 11:23
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%2f272574%2fmagento-2-get-last-five-order-information-using-di-on-homepage%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 block and add the below code to it,
Block path be like
app/code/Vendor/Module/Block/Orders.php
<?php
namespace VendorModuleBlock;
class Orders extends MagentoFrameworkViewElementTemplate
public function __construct(
MagentoSalesModelOrderFactory $orderFactory
)
$this->orderFactory = $orderFactory;
public function getCollection()
$collection = $this->orderFactory->create()->getCollection()->addFieldToSelect('*')->setOrder('created_at','desc');
$collection->setPageSize(5);
return $collection;
then in your phtml you can call like below
$order_collection = $block->getCollection();
foreach($order_collection as $items)
$items->getId();
$items->getName(); // like this you can get any data from sales_order table information
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::order_total.phtml">
</block>
</referenceContainer>
</body>
</page>
Vendor_Module - this should you namespace_modulename
And also place order_total.phtml in the below path
app/code/Vendor/Module/view/frontend/templates/order_total.phtml
Hope this helps.
hello Prathap I have recevice orders but I have used block folder and in this one file create and call phtml this way I have get any solution for this?
– sanni kalariya
Apr 26 at 12:48
updated for block, you can simple follow the above instruction and hope that will work if not please let me know
– Prathap Gunasekaran
Apr 26 at 13:00
Exception #0 (MagentoFrameworkConfigDomValidationException): Element 'block', attribute 'class': [facet 'pattern'] The value 'WdsCoreoverrideBlockorders' is not accepted by the pattern '[A-Z][_a-zA-Zd]*([A-Z][_a-zA-Zd]*)*'. Line: 713Prathap Gunasekaran I am facing this error
– sanni kalariya
17 hours ago
add a comment |
Try this,
Create a block and add the below code to it,
Block path be like
app/code/Vendor/Module/Block/Orders.php
<?php
namespace VendorModuleBlock;
class Orders extends MagentoFrameworkViewElementTemplate
public function __construct(
MagentoSalesModelOrderFactory $orderFactory
)
$this->orderFactory = $orderFactory;
public function getCollection()
$collection = $this->orderFactory->create()->getCollection()->addFieldToSelect('*')->setOrder('created_at','desc');
$collection->setPageSize(5);
return $collection;
then in your phtml you can call like below
$order_collection = $block->getCollection();
foreach($order_collection as $items)
$items->getId();
$items->getName(); // like this you can get any data from sales_order table information
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::order_total.phtml">
</block>
</referenceContainer>
</body>
</page>
Vendor_Module - this should you namespace_modulename
And also place order_total.phtml in the below path
app/code/Vendor/Module/view/frontend/templates/order_total.phtml
Hope this helps.
hello Prathap I have recevice orders but I have used block folder and in this one file create and call phtml this way I have get any solution for this?
– sanni kalariya
Apr 26 at 12:48
updated for block, you can simple follow the above instruction and hope that will work if not please let me know
– Prathap Gunasekaran
Apr 26 at 13:00
Exception #0 (MagentoFrameworkConfigDomValidationException): Element 'block', attribute 'class': [facet 'pattern'] The value 'WdsCoreoverrideBlockorders' is not accepted by the pattern '[A-Z][_a-zA-Zd]*([A-Z][_a-zA-Zd]*)*'. Line: 713Prathap Gunasekaran I am facing this error
– sanni kalariya
17 hours ago
add a comment |
Try this,
Create a block and add the below code to it,
Block path be like
app/code/Vendor/Module/Block/Orders.php
<?php
namespace VendorModuleBlock;
class Orders extends MagentoFrameworkViewElementTemplate
public function __construct(
MagentoSalesModelOrderFactory $orderFactory
)
$this->orderFactory = $orderFactory;
public function getCollection()
$collection = $this->orderFactory->create()->getCollection()->addFieldToSelect('*')->setOrder('created_at','desc');
$collection->setPageSize(5);
return $collection;
then in your phtml you can call like below
$order_collection = $block->getCollection();
foreach($order_collection as $items)
$items->getId();
$items->getName(); // like this you can get any data from sales_order table information
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::order_total.phtml">
</block>
</referenceContainer>
</body>
</page>
Vendor_Module - this should you namespace_modulename
And also place order_total.phtml in the below path
app/code/Vendor/Module/view/frontend/templates/order_total.phtml
Hope this helps.
Try this,
Create a block and add the below code to it,
Block path be like
app/code/Vendor/Module/Block/Orders.php
<?php
namespace VendorModuleBlock;
class Orders extends MagentoFrameworkViewElementTemplate
public function __construct(
MagentoSalesModelOrderFactory $orderFactory
)
$this->orderFactory = $orderFactory;
public function getCollection()
$collection = $this->orderFactory->create()->getCollection()->addFieldToSelect('*')->setOrder('created_at','desc');
$collection->setPageSize(5);
return $collection;
then in your phtml you can call like below
$order_collection = $block->getCollection();
foreach($order_collection as $items)
$items->getId();
$items->getName(); // like this you can get any data from sales_order table information
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::order_total.phtml">
</block>
</referenceContainer>
</body>
</page>
Vendor_Module - this should you namespace_modulename
And also place order_total.phtml in the below path
app/code/Vendor/Module/view/frontend/templates/order_total.phtml
Hope this helps.
edited Apr 26 at 13:00
answered Apr 26 at 11:19
Prathap GunasekaranPrathap Gunasekaran
2,1191619
2,1191619
hello Prathap I have recevice orders but I have used block folder and in this one file create and call phtml this way I have get any solution for this?
– sanni kalariya
Apr 26 at 12:48
updated for block, you can simple follow the above instruction and hope that will work if not please let me know
– Prathap Gunasekaran
Apr 26 at 13:00
Exception #0 (MagentoFrameworkConfigDomValidationException): Element 'block', attribute 'class': [facet 'pattern'] The value 'WdsCoreoverrideBlockorders' is not accepted by the pattern '[A-Z][_a-zA-Zd]*([A-Z][_a-zA-Zd]*)*'. Line: 713Prathap Gunasekaran I am facing this error
– sanni kalariya
17 hours ago
add a comment |
hello Prathap I have recevice orders but I have used block folder and in this one file create and call phtml this way I have get any solution for this?
– sanni kalariya
Apr 26 at 12:48
updated for block, you can simple follow the above instruction and hope that will work if not please let me know
– Prathap Gunasekaran
Apr 26 at 13:00
Exception #0 (MagentoFrameworkConfigDomValidationException): Element 'block', attribute 'class': [facet 'pattern'] The value 'WdsCoreoverrideBlockorders' is not accepted by the pattern '[A-Z][_a-zA-Zd]*([A-Z][_a-zA-Zd]*)*'. Line: 713Prathap Gunasekaran I am facing this error
– sanni kalariya
17 hours ago
hello Prathap I have recevice orders but I have used block folder and in this one file create and call phtml this way I have get any solution for this?
– sanni kalariya
Apr 26 at 12:48
hello Prathap I have recevice orders but I have used block folder and in this one file create and call phtml this way I have get any solution for this?
– sanni kalariya
Apr 26 at 12:48
updated for block, you can simple follow the above instruction and hope that will work if not please let me know
– Prathap Gunasekaran
Apr 26 at 13:00
updated for block, you can simple follow the above instruction and hope that will work if not please let me know
– Prathap Gunasekaran
Apr 26 at 13:00
Exception #0 (MagentoFrameworkConfigDomValidationException): Element 'block', attribute 'class': [facet 'pattern'] The value 'WdsCoreoverrideBlockorders' is not accepted by the pattern '[A-Z][_a-zA-Zd]*([A-Z][_a-zA-Zd]*)*'. Line: 713Prathap Gunasekaran I am facing this error
– sanni kalariya
17 hours ago
Exception #0 (MagentoFrameworkConfigDomValidationException): Element 'block', attribute 'class': [facet 'pattern'] The value 'WdsCoreoverrideBlockorders' is not accepted by the pattern '[A-Z][_a-zA-Zd]*([A-Z][_a-zA-Zd]*)*'. Line: 713Prathap Gunasekaran I am facing this error
– sanni kalariya
17 hours ago
add a comment |
Please Use below code
<?php
namespace VendorModuleBlock;
class order extends MagentoFrameworkViewElementTemplate
protected $OrderFactory;
public function __construct(
...
MagentoSalesModelOrderFactory $OrderFactory
...
)
...
$this->OrderFactory = $OrderFactory;
...
public function orderCollection()
$orderCollection = $this->OrderFactory->create()->getCollection();
$orderCollection->getSelect()->limit(5);
return $orderCollection;
<?php $orderCollection = $this->orderCollection(); ?> in phtml file this way call
– sanni kalariya
Apr 26 at 11:23
add a comment |
Please Use below code
<?php
namespace VendorModuleBlock;
class order extends MagentoFrameworkViewElementTemplate
protected $OrderFactory;
public function __construct(
...
MagentoSalesModelOrderFactory $OrderFactory
...
)
...
$this->OrderFactory = $OrderFactory;
...
public function orderCollection()
$orderCollection = $this->OrderFactory->create()->getCollection();
$orderCollection->getSelect()->limit(5);
return $orderCollection;
<?php $orderCollection = $this->orderCollection(); ?> in phtml file this way call
– sanni kalariya
Apr 26 at 11:23
add a comment |
Please Use below code
<?php
namespace VendorModuleBlock;
class order extends MagentoFrameworkViewElementTemplate
protected $OrderFactory;
public function __construct(
...
MagentoSalesModelOrderFactory $OrderFactory
...
)
...
$this->OrderFactory = $OrderFactory;
...
public function orderCollection()
$orderCollection = $this->OrderFactory->create()->getCollection();
$orderCollection->getSelect()->limit(5);
return $orderCollection;
Please Use below code
<?php
namespace VendorModuleBlock;
class order extends MagentoFrameworkViewElementTemplate
protected $OrderFactory;
public function __construct(
...
MagentoSalesModelOrderFactory $OrderFactory
...
)
...
$this->OrderFactory = $OrderFactory;
...
public function orderCollection()
$orderCollection = $this->OrderFactory->create()->getCollection();
$orderCollection->getSelect()->limit(5);
return $orderCollection;
edited 19 hours ago
answered Apr 26 at 11:09
TusharTushar
1598
1598
<?php $orderCollection = $this->orderCollection(); ?> in phtml file this way call
– sanni kalariya
Apr 26 at 11:23
add a comment |
<?php $orderCollection = $this->orderCollection(); ?> in phtml file this way call
– sanni kalariya
Apr 26 at 11:23
<?php $orderCollection = $this->orderCollection(); ?> in phtml file this way call
– sanni kalariya
Apr 26 at 11:23
<?php $orderCollection = $this->orderCollection(); ?> in phtml file this way call
– sanni kalariya
Apr 26 at 11:23
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%2f272574%2fmagento-2-get-last-five-order-information-using-di-on-homepage%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