Items.php 1.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  1. <?php
  2. /**
  3. * Copyright © Magento, Inc. All rights reserved.
  4. * See COPYING.txt for license details.
  5. */
  6. namespace Magento\Sales\Block\Adminhtml\Order\View;
  7. use Magento\Sales\Model\ResourceModel\Order\Item\Collection;
  8. /**
  9. * Adminhtml order items grid
  10. *
  11. * @api
  12. * @since 100.0.2
  13. */
  14. class Items extends \Magento\Sales\Block\Adminhtml\Items\AbstractItems
  15. {
  16. /**
  17. * @return array
  18. * @since 100.1.0
  19. */
  20. public function getColumns()
  21. {
  22. $columns = array_key_exists('columns', $this->_data) ? $this->_data['columns'] : [];
  23. return $columns;
  24. }
  25. /**
  26. * Retrieve required options from parent
  27. *
  28. * @return void
  29. * @throws \Magento\Framework\Exception\LocalizedException
  30. */
  31. protected function _beforeToHtml()
  32. {
  33. if (!$this->getParentBlock()) {
  34. throw new \Magento\Framework\Exception\LocalizedException(__('Invalid parent block for this block'));
  35. }
  36. $this->setOrder($this->getParentBlock()->getOrder());
  37. parent::_beforeToHtml();
  38. }
  39. /**
  40. * Retrieve order items collection
  41. *
  42. * @return Collection
  43. */
  44. public function getItemsCollection()
  45. {
  46. return $this->getOrder()->getItemsCollection();
  47. }
  48. }