GetShippingItemsGrid.php 1.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  1. <?php
  2. /**
  3. *
  4. * Copyright © Magento, Inc. All rights reserved.
  5. * See COPYING.txt for license details.
  6. */
  7. namespace Magento\Shipping\Controller\Adminhtml\Order\Shipment;
  8. use Magento\Backend\App\Action;
  9. use Magento\Framework\App\ResponseInterface;
  10. class GetShippingItemsGrid extends \Magento\Backend\App\Action
  11. {
  12. /**
  13. * Authorization level of a basic admin session
  14. *
  15. * @see _isAllowed()
  16. */
  17. const ADMIN_RESOURCE = 'Magento_Sales::shipment';
  18. /**
  19. * @var \Magento\Shipping\Controller\Adminhtml\Order\ShipmentLoader
  20. */
  21. protected $shipmentLoader;
  22. /**
  23. * @param Action\Context $context
  24. * @param \Magento\Shipping\Controller\Adminhtml\Order\ShipmentLoader $shipmentLoader
  25. */
  26. public function __construct(
  27. Action\Context $context,
  28. \Magento\Shipping\Controller\Adminhtml\Order\ShipmentLoader $shipmentLoader
  29. ) {
  30. $this->shipmentLoader = $shipmentLoader;
  31. parent::__construct($context);
  32. }
  33. /**
  34. * Return grid with shipping items for Ajax request
  35. *
  36. * @return ResponseInterface
  37. */
  38. public function execute()
  39. {
  40. $this->shipmentLoader->setOrderId($this->getRequest()->getParam('order_id'));
  41. $this->shipmentLoader->setShipmentId($this->getRequest()->getParam('shipment_id'));
  42. $this->shipmentLoader->setShipment($this->getRequest()->getParam('shipment'));
  43. $this->shipmentLoader->setTracking($this->getRequest()->getParam('tracking'));
  44. $this->shipmentLoader->load();
  45. return $this->getResponse()->setBody(
  46. $this->_view->getLayout()->createBlock(
  47. \Magento\Shipping\Block\Adminhtml\Order\Packaging\Grid::class
  48. )->setIndex(
  49. $this->getRequest()->getParam('index')
  50. )->toHtml()
  51. );
  52. }
  53. }