Advertisement
Guest User

Untitled

a guest
Jun 25th, 2019
60
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.11 KB | None | 0 0
  1. Please Use below code
  2.  
  3. <?php
  4. namespace VendorModuleBlock;
  5.  
  6. class order extends MagentoFrameworkViewElementTemplate
  7. {
  8. protected $OrderFactory;
  9.  
  10. public function __construct(
  11. ...
  12. MagentoSalesModelOrderFactory $OrderFactory
  13. ...
  14. ) {
  15. ...
  16. $this->OrderFactory = $OrderFactory;
  17. ...
  18. }
  19.  
  20. public function orderCollection()
  21. {
  22. $orderCollection = $this->OrderFactory->create()->getCollection();
  23. $orderCollection->getSelect()->limit(5);
  24. foreach ($orderCollection as $key => $orderID) {
  25. $order = $this->OrderFactory->create()->load($orderID->getId());
  26. $orderItems = $order->getAllItems();
  27. foreach ($orderItems as $item) {
  28. $product_name = $item->getName();
  29. $product_id = $item->getProductId();
  30. echo $productName . "||" . $product_id;
  31. }
  32. }
  33. }
  34. }
  35. ->'orderCollection' Method call in your phtml.
  36. -> like $this->orderCollection();
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement