SHARE
TWEET

Untitled

a guest Jul 17th, 2017 48 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. namespace MyTrackorderControllerIndex;
  2.  
  3. use MagentoFrameworkAppActionContext;
  4.  
  5. class Result extends MagentoFrameworkAppActionAction
  6. {
  7.     protected $resultFactory;
  8.     protected $orderRepository;
  9.     private $orderFactory;
  10.     public function __construct(Context $context,
  11.          MagentoSalesModelOrderFactory $orderFactory,
  12.          MagentoFrameworkJsonHelperData $jsonHelper,
  13.          MagentoSalesApiOrderRepositoryInterface $orderRepository,
  14.         MagentoFrameworkViewResultPageFactory $resultFactory
  15.         )
  16.     {
  17.         $this->jsonHelper = $jsonHelper;
  18.         $this->resultFactory = $resultFactory;
  19.          $this->orderRepository = $orderRepository;
  20.         $this->orderFactory = $orderFactory;
  21.         parent::__construct($context);
  22.     }
  23.  
  24.     public function execute()  
  25.     {
  26.  
  27.         $order_id = $this->getRequest()->getParam('order_id');
  28.  
  29.         $order = $this->orderFactory->create();  
  30.         $order->loadByIncrementId($order_id);
  31. $product = $order->getAllVisibleItems();
  32.    
  33. private $orderFactory;
  34.  
  35. public function __construct(
  36.     ...
  37.     MagentoSalesModelOrder $orderFactory,
  38.     ...
  39. ) {
  40.     ...
  41.     $this->orderFactory = $orderFactory;
  42.     ...
  43. }
  44.  
  45. public function execute()  
  46. {
  47.  
  48.     $order_id = $this->getRequest()->getParam('order_id');
  49.     $order = $this->orderFactory->loadByIncrementId($order_id);
  50.     //$orderItems = $order->getAllItems();
  51.     $orderItems = $order->getAllVisibleItems();
  52.  
  53.     foreach ($orderItems as $item) {
  54.         // var_dump($item->getData());
  55.     }
  56. }
RAW Paste Data
Top