diff --git a/app/code/Magento/Sales/Block/Adminhtml/Order/View/Tab/Shipments.php b/app/code/Magento/Sales/Block/Adminhtml/Order/View/Tab/Shipments.php
index ca7726e567b66..691d2b241fca3 100644
--- a/app/code/Magento/Sales/Block/Adminhtml/Order/View/Tab/Shipments.php
+++ b/app/code/Magento/Sales/Block/Adminhtml/Order/View/Tab/Shipments.php
@@ -30,7 +30,7 @@
namespace Magento\Sales\Block\Adminhtml\Order\View\Tab;
class Shipments
- extends \Magento\Backend\Block\Widget\Grid\Extended
+ extends \Magento\View\Element\Text\ListText
implements \Magento\Backend\Block\Widget\Tab\TabInterface
{
/**
@@ -41,29 +41,22 @@ class Shipments
protected $_coreRegistry = null;
/**
- * @var \Magento\Sales\Model\Resource\Order\Collection\Factory
- */
- protected $_collectionFactory;
-
- /**
- * @param \Magento\Backend\Block\Template\Context $context
- * @param \Magento\Backend\Helper\Data $backendHelper
- * @param \Magento\Sales\Model\Resource\Order\Collection\Factory $collectionFactory
+ * @param \Magento\View\Element\Context $context
* @param \Magento\Core\Model\Registry $coreRegistry
* @param array $data
*/
public function __construct(
- \Magento\Backend\Block\Template\Context $context,
- \Magento\Backend\Helper\Data $backendHelper,
- \Magento\Sales\Model\Resource\Order\Collection\Factory $collectionFactory,
+ \Magento\View\Element\Context $context,
\Magento\Core\Model\Registry $coreRegistry,
array $data = array()
) {
- $this->_coreRegistry = $coreRegistry;
- $this->_collectionFactory = $collectionFactory;
- parent::__construct($context, $backendHelper, $data);
+ $this->_coreRegistry = $coreRegistry;
+ parent::__construct($context, $data);
}
+ /**
+ * Initialize grid params
+ */
protected function _construct()
{
parent::_construct();
@@ -72,62 +65,23 @@ protected function _construct()
}
/**
- * Retrieve collection class
+ * Return Tab label
*
* @return string
*/
- protected function _getCollectionClass()
- {
- return 'Magento\Sales\Model\Resource\Order\Shipment\Grid\Collection';
- }
-
- protected function _prepareCollection()
+ public function getTabLabel()
{
- $collection = $this->_collectionFactory->create($this->_getCollectionClass())
- ->addFieldToSelect('entity_id')
- ->addFieldToSelect('created_at')
- ->addFieldToSelect('increment_id')
- ->addFieldToSelect('total_qty')
- ->addFieldToSelect('shipping_name')
- ->setOrderFilter($this->getOrder())
- ;
- $this->setCollection($collection);
- return parent::_prepareCollection();
+ return __('Shipments');
}
- protected function _prepareColumns()
+ /**
+ * Return Tab title
+ *
+ * @return string
+ */
+ public function getTabTitle()
{
- $this->addColumn('increment_id', array(
- 'header' => __('Shipment'),
- 'index' => 'increment_id',
- 'header_css_class' => 'col-memo',
- 'column_css_class' => 'col-memo'
- ));
-
- $this->addColumn('shipping_name', array(
- 'header' => __('Ship-to Name'),
- 'index' => 'shipping_name',
- 'header_css_class' => 'col-name',
- 'column_css_class' => 'col-name'
- ));
-
- $this->addColumn('created_at', array(
- 'header' => __('Ship Date'),
- 'index' => 'created_at',
- 'type' => 'datetime',
- 'header_css_class' => 'col-period',
- 'column_css_class' => 'col-period'
- ));
-
- $this->addColumn('total_qty', array(
- 'header' => __('Total Quantity'),
- 'index' => 'total_qty',
- 'type' => 'number',
- 'header_css_class' => 'col-qty',
- 'column_css_class' => 'col-qty'
- ));
-
- return parent::_prepareColumns();
+ return __('Order Shipments');
}
/**
@@ -135,47 +89,29 @@ protected function _prepareColumns()
*
* @return \Magento\Sales\Model\Order
*/
- public function getOrder()
+ protected function _getOrder()
{
return $this->_coreRegistry->registry('current_order');
}
- public function getRowUrl($row)
- {
- return $this->getUrl(
- 'adminhtml/order_shipment/view',
- array(
- 'shipment_id'=> $row->getId(),
- 'order_id' => $row->getOrderId()
- ));
- }
-
- public function getGridUrl()
- {
- return $this->getUrl('sales/*/shipments', array('_current' => true));
- }
-
/**
- * ######################## TAB settings #################################
+ * Can show tab in tabs
+ *
+ * @return boolean
*/
- public function getTabLabel()
- {
- return __('Shipments');
- }
-
- public function getTabTitle()
- {
- return __('Order Shipments');
- }
-
public function canShowTab()
{
- if ($this->getOrder()->getIsVirtual()) {
+ if ($this->_getOrder()->getIsVirtual()) {
return false;
}
return true;
}
+ /**
+ * Tab is hidden
+ *
+ * @return boolean
+ */
public function isHidden()
{
return false;
diff --git a/app/code/Magento/Sales/Controller/Adminhtml/Order.php b/app/code/Magento/Sales/Controller/Adminhtml/Order.php
index 0306be7151247..6d5f96addfbaf 100644
--- a/app/code/Magento/Sales/Controller/Adminhtml/Order.php
+++ b/app/code/Magento/Sales/Controller/Adminhtml/Order.php
@@ -369,9 +369,8 @@ public function invoicesAction()
public function shipmentsAction()
{
$this->_initOrder();
- $this->getResponse()->setBody(
- $this->_view->getLayout()->createBlock('Magento\Sales\Block\Adminhtml\Order\View\Tab\Shipments')->toHtml()
- );
+ $this->_view->loadLayout(false);
+ $this->_view->renderLayout();
}
/**
diff --git a/app/code/Magento/Sales/Model/Order/ShipmentsUpdater.php b/app/code/Magento/Sales/Model/Order/ShipmentsUpdater.php
new file mode 100644
index 0000000000000..e290b3dda3549
--- /dev/null
+++ b/app/code/Magento/Sales/Model/Order/ShipmentsUpdater.php
@@ -0,0 +1,65 @@
+_registryManager = $registryManager;
+ }
+
+ /**
+ * Add order filter
+ *
+ * @param \Magento\Sales\Model\Resource\Order\Shipment\Grid\Collection $argument
+ * @return mixed
+ * @throws \DomainException
+ */
+ public function update($argument)
+ {
+ $order = $this->_registryManager->registry('current_order');
+
+ if (!$order) {
+ throw new \DomainException('Undefined order object');
+ }
+
+ $argument->setOrderFilter($order->getId());
+ return $argument;
+ }
+}
diff --git a/app/code/Magento/Sales/view/adminhtml/layout/sales_order_shipment_grid_block.xml b/app/code/Magento/Sales/view/adminhtml/layout/sales_order_shipment_grid_block.xml
new file mode 100644
index 0000000000000..3b8e7e316f1d2
--- /dev/null
+++ b/app/code/Magento/Sales/view/adminhtml/layout/sales_order_shipment_grid_block.xml
@@ -0,0 +1,96 @@
+
+
+
+
+
+
+ sales_order_shipment_grid
+
+ Magento\Sales\Model\Resource\Order\Shipment\Grid\Collection
+ Magento\Sales\Model\Order\ShipmentsUpdater
+
+ true
+ created_at
+ DESC
+ 1
+
+ 1
+
+
+
+
+ sales_order_shipment_grid
+
+ - Magento\Sales\Model\Grid\Row\UrlGenerator
+ - sales/order_shipment/view
+ -
+
- getId
+
+
+
+
+
+ Shipment
+ text
+ increment_id
+ real_shipment_id
+ col-shipment-number
+ col-shipment-number
+
+
+
+
+ shipping_name
+ Ship-to Name
+ shipping_name
+ col-ship-to-name
+ col-ship-to-name
+
+
+
+
+ Ship Date
+ datetime
+ created_at
+ created_at
+ col-period
+ col-period
+
+
+
+
+ total_qty
+ Total Quantity
+ number
+ total_qty
+ col-qty
+ col-qty
+
+
+
+
+
+
diff --git a/app/code/Magento/Sales/view/adminhtml/layout/sales_order_shipments.xml b/app/code/Magento/Sales/view/adminhtml/layout/sales_order_shipments.xml
new file mode 100644
index 0000000000000..6ef7b0b48ecb4
--- /dev/null
+++ b/app/code/Magento/Sales/view/adminhtml/layout/sales_order_shipments.xml
@@ -0,0 +1,29 @@
+
+
+
+
+
+
diff --git a/app/code/Magento/Sales/view/adminhtml/layout/sales_order_view.xml b/app/code/Magento/Sales/view/adminhtml/layout/sales_order_view.xml
index f31d90e746455..60ac25d6f7ef7 100644
--- a/app/code/Magento/Sales/view/adminhtml/layout/sales_order_view.xml
+++ b/app/code/Magento/Sales/view/adminhtml/layout/sales_order_view.xml
@@ -40,6 +40,7 @@
+
@@ -73,9 +74,10 @@
order_creditmemos
Magento\Sales\Block\Adminhtml\Order\View\Tab\Creditmemos
+
order_shipments
- Magento\Sales\Block\Adminhtml\Order\View\Tab\Shipments
+ sales_order_shipment.grid.container
order_history