With below piece of code we can easily get a order collection in magento2 easily by using object manager
> to get order collection
<?php $objectManager = \Magento\Framework\App\ObjectManager::getInstance();
$orderDatamodel = $objectManager->get('Magento\Sales\Model\Order')->getCollection();
foreach($orderDatamodel as $orderDatamodel1){
print_r($orderDatamodel1->getData());
}
- > to get order collection with order items data
<?php $objectManager = \Magento\Framework\App\ObjectManager::getInstance();
$orderDatamodel = $objectManager->get('Magento\Sales\Model\Order')->getCollection();
foreach($orderDatamodel as $orderDatamodel1){
$getid = $orderDatamodel1->getData("increment_id");
$orderData = $objectManager->create('Magento\Sales\Model\Order')->loadByIncrementId($getid);
//echo "<pre>";
$getorderdata = $orderData->getData();
$orderItems = $orderData->getAllVisibleItems();
foreach($orderItems as $orderItems){
print_r($orderItems->getData());
}
}
I really enjoyed reading this post, big fan. Keep up the good work andplease tell me when can you publish more articles or where can I read more on the subject?
ReplyDeleteNewizze
vvvvvvvvgbn
ReplyDeleteIf this don't works for you, you can simpy Hire Magento Developers from foremost Magento Development Company .
ReplyDelete