Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- 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);
- foreach ($orderCollection as $key => $orderID) {
- $order = $this->OrderFactory->create()->load($orderID->getId());
- $orderItems = $order->getAllItems();
- foreach ($orderItems as $item) {
- $product_name = $item->getName();
- $product_id = $item->getProductId();
- echo $productName . "||" . $product_id;
- }
- }
- }
- }
- ->'orderCollection' Method call in your phtml.
- -> like $this->orderCollection();
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement