diff --git a/app/code/Magento/Catalog/Controller/Adminhtml/Product/MassDelete.php b/app/code/Magento/Catalog/Controller/Adminhtml/Product/MassDelete.php
index 4a312adfb6366..945e80c93e44c 100644
--- a/app/code/Magento/Catalog/Controller/Adminhtml/Product/MassDelete.php
+++ b/app/code/Magento/Catalog/Controller/Adminhtml/Product/MassDelete.php
@@ -6,69 +6,58 @@
*/
namespace Magento\Catalog\Controller\Adminhtml\Product;
-use Magento\Catalog\Model\Resource\Product\Collection;
use Magento\Framework\Controller\ResultFactory;
+use Magento\Catalog\Controller\Adminhtml\Product\Builder;
+use Magento\Backend\App\Action\Context;
+use Magento\Ui\Component\MassAction\Filter;
+use Magento\Catalog\Model\Resource\Product\CollectionFactory;
class MassDelete extends \Magento\Catalog\Controller\Adminhtml\Product
{
/**
- * Field id
+ * Massactions filter
+ *
+ * @var Filter
*/
- const ID_FIELD = 'entity_id';
+ protected $filter;
/**
- * Redirect url
+ * @var CollectionFactory
*/
- const REDIRECT_URL = 'catalog/*/index';
+ protected $collectionFactory;
/**
- * Resource collection
- *
- * @var string
+ * @param Context $context
+ * @param Builder $productBuilder
+ * @param Filter $filter
+ * @param CollectionFactory $collectionFactory
*/
- protected $collection = 'Magento\Catalog\Model\Resource\Product\Collection';
+ public function __construct(
+ Context $context,
+ Builder $productBuilder,
+ Filter $filter,
+ CollectionFactory $collectionFactory
+ ) {
+ $this->filter = $filter;
+ $this->collectionFactory = $collectionFactory;
+ parent::__construct($context, $productBuilder);
+ }
/**
* @return \Magento\Backend\Model\View\Result\Redirect
*/
public function execute()
{
- $selected = $this->getRequest()->getParam('selected');
- $excluded = $this->getRequest()->getParam('excluded');
-
- $collection = $this->_objectManager->create($this->collection);
- try {
- if (!empty($excluded)) {
- $collection->addFieldToFilter(static::ID_FIELD, ['nin' => $excluded]);
- $this->massAction($collection);
- } elseif (!empty($selected)) {
- $collection->addFieldToFilter(static::ID_FIELD, ['in' => $selected]);
- $this->massAction($collection);
- } else {
- $this->messageManager->addError(__('Please select product(s).'));
- }
- } catch (\Exception $e) {
- $this->messageManager->addError($e->getMessage());
- }
-
- /** @var \Magento\Backend\Model\View\Result\Redirect $resultRedirect */
- $resultRedirect = $this->resultFactory->create(ResultFactory::TYPE_REDIRECT);
- return $resultRedirect->setPath(static::REDIRECT_URL);
- }
-
- /**
- * Cancel selected orders
- *
- * @param Collection $collection
- * @return void
- */
- protected function massAction($collection)
- {
- $count = 0;
+ $collection = $this->filter->getCollection($this->collectionFactory->create());
+ $productDeleted = 0;
foreach ($collection->getItems() as $product) {
$product->delete();
- ++$count;
+ $productDeleted++;
}
- $this->messageManager->addSuccess(__('A total of %1 record(s) have been deleted.', $count));
+ $this->messageManager->addSuccess(
+ __('A total of %1 record(s) have been deleted.', $productDeleted)
+ );
+
+ return $this->resultFactory->create(ResultFactory::TYPE_REDIRECT)->setPath('catalog/*/index');
}
}
diff --git a/app/code/Magento/Catalog/Model/Resource/Product/Collection.php b/app/code/Magento/Catalog/Model/Resource/Product/Collection.php
index d4412878e504b..85cad10802f68 100644
--- a/app/code/Magento/Catalog/Model/Resource/Product/Collection.php
+++ b/app/code/Magento/Catalog/Model/Resource/Product/Collection.php
@@ -34,6 +34,11 @@ class Collection extends \Magento\Catalog\Model\Resource\Collection\AbstractColl
*/
const MAIN_TABLE_ALIAS = 'e';
+ /**
+ * @var string
+ */
+ protected $_idFieldName = 'entity_id';
+
/**
* Catalog Product Flat is enabled cache per store
*
diff --git a/app/code/Magento/Catalog/Ui/DataProvider/Product/AddStoreFieldToCollection.php b/app/code/Magento/Catalog/Ui/DataProvider/Product/AddStoreFieldToCollection.php
index 439c62044ba52..ea841e030babf 100644
--- a/app/code/Magento/Catalog/Ui/DataProvider/Product/AddStoreFieldToCollection.php
+++ b/app/code/Magento/Catalog/Ui/DataProvider/Product/AddStoreFieldToCollection.php
@@ -34,6 +34,7 @@ public function __construct(StoreManagerInterface $storeManager)
public function addFilter(Collection $collection, $field, $condition = null)
{
if (isset($condition['eq']) && $condition['eq']) {
+ /** @var \Magento\Catalog\Model\Resource\Product\Collection $collection */
$collection->addStoreFilter($this->storeManager->getStore($condition['eq']));
}
}
diff --git a/app/code/Magento/Catalog/Ui/DataProvider/Product/ProductDataProvider.php b/app/code/Magento/Catalog/Ui/DataProvider/Product/ProductDataProvider.php
index c26416b4a2ac5..8e558d9318deb 100644
--- a/app/code/Magento/Catalog/Ui/DataProvider/Product/ProductDataProvider.php
+++ b/app/code/Magento/Catalog/Ui/DataProvider/Product/ProductDataProvider.php
@@ -57,16 +57,6 @@ public function __construct(
$this->addFilterStrategies = $addFilterStrategies;
}
- /**
- * Get collection
- *
- * @return \Magento\Catalog\Model\Resource\Product\Collection
- */
- protected function getCollection()
- {
- return $this->collection;
- }
-
/**
* Get data
*
@@ -104,12 +94,17 @@ public function addField($field, $alias = null)
/**
* {@inheritdoc}
*/
- public function addFilter($condition, $field = null, $type = 'regular')
+ public function addFilter(\Magento\Framework\Api\Filter $filter)
{
- if (isset($this->addFilterStrategies[$field])) {
- $this->addFilterStrategies[$field]->addFilter($this->getCollection(), $field, $condition);
+ if (isset($this->addFilterStrategies[$filter->getField()])) {
+ $this->addFilterStrategies[$filter->getField()]
+ ->addFilter(
+ $this->getCollection(),
+ $filter->getField(),
+ [$filter->getConditionType() => $filter->getValue()]
+ );
} else {
- parent::addFilter($condition, $field);
+ parent::addFilter($filter);
}
}
}
diff --git a/app/code/Magento/Cms/Controller/Adminhtml/AbstractMassDelete.php b/app/code/Magento/Cms/Controller/Adminhtml/AbstractMassDelete.php
deleted file mode 100644
index b8b22afca1ab7..0000000000000
--- a/app/code/Magento/Cms/Controller/Adminhtml/AbstractMassDelete.php
+++ /dev/null
@@ -1,145 +0,0 @@
-getRequest()->getParam('selected');
- $excluded = $this->getRequest()->getParam('excluded');
-
- try {
- if (isset($excluded)) {
- if (!empty($excluded)) {
- $this->excludedDelete($excluded);
- } else {
- $this->deleteAll();
- }
- } elseif (!empty($selected)) {
- $this->selectedDelete($selected);
- } else {
- $this->messageManager->addError(__('Please select item(s).'));
- }
- } catch (\Exception $e) {
- $this->messageManager->addError($e->getMessage());
- }
-
- /** @var \Magento\Backend\Model\View\Result\Redirect $resultRedirect */
- $resultRedirect = $this->resultFactory->create(ResultFactory::TYPE_REDIRECT);
- return $resultRedirect->setPath(static::REDIRECT_URL);
- }
-
- /**
- * Delete all
- *
- * @return void
- * @throws \Exception
- */
- protected function deleteAll()
- {
- /** @var AbstractCollection $collection */
- $collection = $this->_objectManager->get($this->collection);
- $this->setSuccessMessage($this->delete($collection));
- }
-
- /**
- * Delete all but the not selected
- *
- * @param array $excluded
- * @return void
- * @throws \Exception
- */
- protected function excludedDelete(array $excluded)
- {
- /** @var AbstractCollection $collection */
- $collection = $this->_objectManager->get($this->collection);
- $collection->addFieldToFilter(static::ID_FIELD, ['nin' => $excluded]);
- $this->setSuccessMessage($this->delete($collection));
- }
-
- /**
- * Delete selected items
- *
- * @param array $selected
- * @return void
- * @throws \Exception
- */
- protected function selectedDelete(array $selected)
- {
- /** @var AbstractCollection $collection */
- $collection = $this->_objectManager->get($this->collection);
- $collection->addFieldToFilter(static::ID_FIELD, ['in' => $selected]);
- $this->setSuccessMessage($this->delete($collection));
- }
-
- /**
- * Delete collection items
- *
- * @param AbstractCollection $collection
- * @return int
- */
- protected function delete(AbstractCollection $collection)
- {
- $count = 0;
- foreach ($collection->getAllIds() as $id) {
- /** @var \Magento\Framework\Model\AbstractModel $model */
- $model = $this->_objectManager->get($this->model);
- $model->load($id);
- $model->delete();
- ++$count;
- }
-
- return $count;
- }
-
- /**
- * Set error messages
- *
- * @param int $count
- * @return void
- */
- protected function setSuccessMessage($count)
- {
- $this->messageManager->addSuccess(__('A total of %1 record(s) have been deleted.', $count));
- }
-}
diff --git a/app/code/Magento/Cms/Controller/Adminhtml/AbstractMassStatus.php b/app/code/Magento/Cms/Controller/Adminhtml/AbstractMassStatus.php
deleted file mode 100644
index fa2219309b56b..0000000000000
--- a/app/code/Magento/Cms/Controller/Adminhtml/AbstractMassStatus.php
+++ /dev/null
@@ -1,137 +0,0 @@
-getRequest()->getParam('selected');
- $excluded = $this->getRequest()->getParam('excluded');
- try {
- if (isset($excluded)) {
- if (!empty($excluded)) {
- $this->excludedSetStatus($excluded);
- } else {
- $this->setStatusAll();
- }
- } elseif (!empty($selected)) {
- $this->selectedSetStatus($selected);
- } else {
- $this->messageManager->addError(__('Please select item(s).'));
- }
- } catch (\Exception $e) {
- $this->messageManager->addError($e->getMessage());
- }
-
- /** @var \Magento\Backend\Model\View\Result\Redirect $resultRedirect */
- $resultRedirect = $this->resultFactory->create(ResultFactory::TYPE_REDIRECT);
- return $resultRedirect->setPath(static::REDIRECT_URL);
- }
-
- /**
- * Set status to all
- *
- * @return void
- * @throws \Exception
- */
- protected function setStatusAll()
- {
- /** @var AbstractCollection $collection */
- $collection = $this->_objectManager->get($this->collection);
- $this->setStatus($collection);
- }
-
- /**
- * Set status to all but the not selected
- *
- * @param array $excluded
- * @return void
- * @throws \Exception
- */
- protected function excludedSetStatus(array $excluded)
- {
- /** @var AbstractCollection $collection */
- $collection = $this->_objectManager->get($this->collection);
- $collection->addFieldToFilter(static::ID_FIELD, ['nin' => $excluded]);
- $this->setStatus($collection);
- }
-
- /**
- * Set status to selected items
- *
- * @param array $selected
- * @return void
- * @throws \Exception
- */
- protected function selectedSetStatus(array $selected)
- {
- /** @var AbstractCollection $collection */
- $collection = $this->_objectManager->get($this->collection);
- $collection->addFieldToFilter(static::ID_FIELD, ['in' => $selected]);
- $this->setStatus($collection);
- }
-
- /**
- * Set status to collection items
- *
- * @param AbstractCollection $collection
- * @return void
- */
- protected function setStatus(AbstractCollection $collection)
- {
- foreach ($collection->getAllIds() as $id) {
- /** @var \Magento\Framework\Model\AbstractModel $model */
- $model = $this->_objectManager->get($this->model);
- $model->load($id);
- $model->setIsActive($this->status);
- $model->save();
- }
- }
-}
diff --git a/app/code/Magento/Cms/Controller/Adminhtml/Block/MassDelete.php b/app/code/Magento/Cms/Controller/Adminhtml/Block/MassDelete.php
index c40c373d205d0..d9a8c044873cf 100644
--- a/app/code/Magento/Cms/Controller/Adminhtml/Block/MassDelete.php
+++ b/app/code/Magento/Cms/Controller/Adminhtml/Block/MassDelete.php
@@ -6,29 +6,56 @@
*/
namespace Magento\Cms\Controller\Adminhtml\Block;
-use Magento\Cms\Controller\Adminhtml\AbstractMassDelete;
+use Magento\Framework\Controller\ResultFactory;
+use Magento\Backend\App\Action\Context;
+use Magento\Ui\Component\MassAction\Filter;
+use Magento\Cms\Model\Resource\Block\CollectionFactory;
/**
* Class MassDelete
*/
-class MassDelete extends AbstractMassDelete
+class MassDelete extends \Magento\Backend\App\Action
{
/**
- * Field id
+ * @var Filter
*/
- const ID_FIELD = 'block_id';
+ protected $filter;
/**
- * Resource collection
- *
- * @var string
+ * @var CollectionFactory
+ */
+ protected $collectionFactory;
+
+ /**
+ * @param Context $context
+ * @param Filter $filter
+ * @param CollectionFactory $collectionFactory
*/
- protected $collection = 'Magento\Cms\Model\Resource\Block\Collection';
+ public function __construct(Context $context, Filter $filter, CollectionFactory $collectionFactory)
+ {
+ $this->filter = $filter;
+ $this->collectionFactory = $collectionFactory;
+ parent::__construct($context);
+ }
/**
- * Block model
+ * Execute action
*
- * @var string
+ * @return \Magento\Backend\Model\View\Result\Redirect
+ * @throws \Magento\Framework\Exception\LocalizedException|\Exception
*/
- protected $model = 'Magento\Cms\Model\Block';
+ public function execute()
+ {
+ $collection = $this->filter->getCollection($this->collectionFactory->create());
+
+ foreach ($collection as $item) {
+ $item->delete();
+ }
+
+ $this->messageManager->addSuccess(__('A total of %1 record(s) have been deleted.', $collection->getSize()));
+
+ /** @var \Magento\Backend\Model\View\Result\Redirect $resultRedirect */
+ $resultRedirect = $this->resultFactory->create(ResultFactory::TYPE_REDIRECT);
+ return $resultRedirect->setPath('*/*/');
+ }
}
diff --git a/app/code/Magento/Cms/Controller/Adminhtml/Page/MassDelete.php b/app/code/Magento/Cms/Controller/Adminhtml/Page/MassDelete.php
index b255b784a1ac9..e5cfcf22966f5 100644
--- a/app/code/Magento/Cms/Controller/Adminhtml/Page/MassDelete.php
+++ b/app/code/Magento/Cms/Controller/Adminhtml/Page/MassDelete.php
@@ -5,29 +5,56 @@
*/
namespace Magento\Cms\Controller\Adminhtml\Page;
-use Magento\Cms\Controller\Adminhtml\AbstractMassDelete;
+use Magento\Framework\Controller\ResultFactory;
+use Magento\Backend\App\Action\Context;
+use Magento\Ui\Component\MassAction\Filter;
+use Magento\Cms\Model\Resource\Page\CollectionFactory;
/**
* Class MassDelete
*/
-class MassDelete extends AbstractMassDelete
+class MassDelete extends \Magento\Backend\App\Action
{
/**
- * Field id
+ * @var Filter
*/
- const ID_FIELD = 'page_id';
+ protected $filter;
/**
- * Resource collection
- *
- * @var string
+ * @var CollectionFactory
+ */
+ protected $collectionFactory;
+
+ /**
+ * @param Context $context
+ * @param Filter $filter
+ * @param CollectionFactory $collectionFactory
*/
- protected $collection = 'Magento\Cms\Model\Resource\Page\Collection';
+ public function __construct(Context $context, Filter $filter, CollectionFactory $collectionFactory)
+ {
+ $this->filter = $filter;
+ $this->collectionFactory = $collectionFactory;
+ parent::__construct($context);
+ }
/**
- * Page model
+ * Execute action
*
- * @var string
+ * @return \Magento\Backend\Model\View\Result\Redirect
+ * @throws \Magento\Framework\Exception\LocalizedException|\Exception
*/
- protected $model = 'Magento\Cms\Model\Page';
+ public function execute()
+ {
+ $collection = $this->filter->getCollection($this->collectionFactory->create());
+
+ foreach ($collection as $item) {
+ $item->delete();
+ }
+
+ $this->messageManager->addSuccess(__('A total of %1 record(s) have been deleted.', $collection->getSize()));
+
+ /** @var \Magento\Backend\Model\View\Result\Redirect $resultRedirect */
+ $resultRedirect = $this->resultFactory->create(ResultFactory::TYPE_REDIRECT);
+ return $resultRedirect->setPath('*/*/');
+ }
}
diff --git a/app/code/Magento/Cms/Controller/Adminhtml/Page/MassDisable.php b/app/code/Magento/Cms/Controller/Adminhtml/Page/MassDisable.php
index ef56988a592c7..a3c5b07513f1e 100644
--- a/app/code/Magento/Cms/Controller/Adminhtml/Page/MassDisable.php
+++ b/app/code/Magento/Cms/Controller/Adminhtml/Page/MassDisable.php
@@ -5,36 +5,57 @@
*/
namespace Magento\Cms\Controller\Adminhtml\Page;
-use Magento\Cms\Controller\Adminhtml\AbstractMassStatus;
+use Magento\Framework\Controller\ResultFactory;
+use Magento\Backend\App\Action\Context;
+use Magento\Ui\Component\MassAction\Filter;
+use Magento\Cms\Model\Resource\Page\CollectionFactory;
/**
* Class MassDisable
*/
-class MassDisable extends AbstractMassStatus
+class MassDisable extends \Magento\Backend\App\Action
{
/**
- * Field id
+ * @var Filter
*/
- const ID_FIELD = 'page_id';
+ protected $filter;
/**
- * Resource collection
- *
- * @var string
+ * @var CollectionFactory
*/
- protected $collection = 'Magento\Cms\Model\Resource\Page\Collection';
+ protected $collectionFactory;
/**
- * Page model
- *
- * @var string
+ * @param Context $context
+ * @param Filter $filter
+ * @param CollectionFactory $collectionFactory
*/
- protected $model = 'Magento\Cms\Model\Page';
+ public function __construct(Context $context, Filter $filter, CollectionFactory $collectionFactory)
+ {
+ $this->filter = $filter;
+ $this->collectionFactory = $collectionFactory;
+ parent::__construct($context);
+ }
/**
- * Page disable status
+ * Execute action
*
- * @var boolean
+ * @return \Magento\Backend\Model\View\Result\Redirect
+ * @throws \Magento\Framework\Exception\LocalizedException|\Exception
*/
- protected $status = false;
+ public function execute()
+ {
+ $collection = $this->filter->getCollection($this->collectionFactory->create());
+
+ foreach ($collection as $item) {
+ $item->setIsActive(false);
+ $item->save();
+ }
+
+ $this->messageManager->addSuccess(__('A total of %1 record(s) have been deleted.', $collection->getSize()));
+
+ /** @var \Magento\Backend\Model\View\Result\Redirect $resultRedirect */
+ $resultRedirect = $this->resultFactory->create(ResultFactory::TYPE_REDIRECT);
+ return $resultRedirect->setPath('*/*/');
+ }
}
diff --git a/app/code/Magento/Cms/Controller/Adminhtml/Page/MassEnable.php b/app/code/Magento/Cms/Controller/Adminhtml/Page/MassEnable.php
index 4eac33a6fa4a7..fff1f58a5b1c0 100644
--- a/app/code/Magento/Cms/Controller/Adminhtml/Page/MassEnable.php
+++ b/app/code/Magento/Cms/Controller/Adminhtml/Page/MassEnable.php
@@ -5,36 +5,57 @@
*/
namespace Magento\Cms\Controller\Adminhtml\Page;
-use Magento\Cms\Controller\Adminhtml\AbstractMassStatus;
+use Magento\Framework\Controller\ResultFactory;
+use Magento\Backend\App\Action\Context;
+use Magento\Ui\Component\MassAction\Filter;
+use Magento\Cms\Model\Resource\Page\CollectionFactory;
/**
* Class MassEnable
*/
-class MassEnable extends AbstractMassStatus
+class MassEnable extends \Magento\Backend\App\Action
{
/**
- * Field id
+ * @var Filter
*/
- const ID_FIELD = 'page_id';
+ protected $filter;
/**
- * Resource collection
- *
- * @var string
+ * @var CollectionFactory
*/
- protected $collection = 'Magento\Cms\Model\Resource\Page\Collection';
+ protected $collectionFactory;
/**
- * Page model
- *
- * @var string
+ * @param Context $context
+ * @param Filter $filter
+ * @param CollectionFactory $collectionFactory
*/
- protected $model = 'Magento\Cms\Model\Page';
+ public function __construct(Context $context, Filter $filter, CollectionFactory $collectionFactory)
+ {
+ $this->filter = $filter;
+ $this->collectionFactory = $collectionFactory;
+ parent::__construct($context);
+ }
/**
- * Page enable status
+ * Execute action
*
- * @var boolean
+ * @return \Magento\Backend\Model\View\Result\Redirect
+ * @throws \Magento\Framework\Exception\LocalizedException|\Exception
*/
- protected $status = true;
+ public function execute()
+ {
+ $collection = $this->filter->getCollection($this->collectionFactory->create());
+
+ foreach ($collection as $item) {
+ $item->setIsActive(true);
+ $item->save();
+ }
+
+ $this->messageManager->addSuccess(__('A total of %1 record(s) have been deleted.', $collection->getSize()));
+
+ /** @var \Magento\Backend\Model\View\Result\Redirect $resultRedirect */
+ $resultRedirect = $this->resultFactory->create(ResultFactory::TYPE_REDIRECT);
+ return $resultRedirect->setPath('*/*/');
+ }
}
diff --git a/app/code/Magento/Cms/Model/Block/DataProvider.php b/app/code/Magento/Cms/Model/Block/DataProvider.php
deleted file mode 100644
index a1aed9394efe9..0000000000000
--- a/app/code/Magento/Cms/Model/Block/DataProvider.php
+++ /dev/null
@@ -1,87 +0,0 @@
-collection = $collectionFactory->create();
- $this->filterPool = $filterPool;
- }
-
- /**
- * @return \Magento\Cms\Model\Resource\Block\Collection
- */
- protected function getCollection()
- {
- return $this->collection;
- }
-
- /**
- * @inheritdoc
- */
- public function addFilter($condition, $field = null, $type = 'regular')
- {
- $this->filterPool->registerNewFilter($condition, $field, $type);
- }
-
- /**
- * Get data
- *
- * @return array
- */
- public function getData()
- {
- $this->filterPool->applyFilters($this->collection);
- return $this->collection->toArray();
- }
-
- /**
- * Retrieve count of loaded items
- *
- * @return int
- */
- public function count()
- {
- $this->filterPool->applyFilters($this->collection);
- return $this->collection->count();
- }
-}
diff --git a/app/code/Magento/Cms/Model/Page/DataProvider.php b/app/code/Magento/Cms/Model/Page/DataProvider.php
deleted file mode 100644
index f3d4d61303bd1..0000000000000
--- a/app/code/Magento/Cms/Model/Page/DataProvider.php
+++ /dev/null
@@ -1,88 +0,0 @@
-filterPool = $filterPool;
- $this->collection = $collectionFactory->create();
- $this->collection->setFirstStoreFlag(true);
- }
-
- /**
- * @return \Magento\Cms\Model\Resource\Page\Collection
- */
- protected function getCollection()
- {
- return $this->collection;
- }
-
- /**
- * @inheritdoc
- */
- public function addFilter($condition, $field = null, $type = 'regular')
- {
- $this->filterPool->registerNewFilter($condition, $field, $type);
- }
-
- /**
- * Get data
- *
- * @return array
- */
- public function getData()
- {
- $this->filterPool->applyFilters($this->collection);
- return $this->collection->toArray();
- }
-
- /**
- * Retrieve count of loaded items
- *
- * @return int
- */
- public function count()
- {
- $this->filterPool->applyFilters($this->collection);
- return $this->collection->count();
- }
-}
diff --git a/app/code/Magento/Cms/Model/Resource/Block/Collection.php b/app/code/Magento/Cms/Model/Resource/Block/Collection.php
index 0bed33c3c0308..bb7657bdb357f 100644
--- a/app/code/Magento/Cms/Model/Resource/Block/Collection.php
+++ b/app/code/Magento/Cms/Model/Resource/Block/Collection.php
@@ -12,6 +12,11 @@
*/
class Collection extends \Magento\Framework\Model\Resource\Db\Collection\AbstractCollection
{
+ /**
+ * @var string
+ */
+ protected $_idFieldName = 'block_id';
+
/**
* @return \Magento\Cms\Model\Resource\Block\Collection
*/
diff --git a/app/code/Magento/Cms/Model/Resource/Block/Grid/Collection.php b/app/code/Magento/Cms/Model/Resource/Block/Grid/Collection.php
new file mode 100644
index 0000000000000..427dbe5f1b67a
--- /dev/null
+++ b/app/code/Magento/Cms/Model/Resource/Block/Grid/Collection.php
@@ -0,0 +1,150 @@
+_eventPrefix = $eventPrefix;
+ $this->_eventObject = $eventObject;
+ $this->_init($model, $resourceModel);
+ $this->setMainTable($mainTable);
+ }
+
+ /**
+ * @return AggregationInterface
+ */
+ public function getAggregations()
+ {
+ return $this->aggregations;
+ }
+
+ /**
+ * @param AggregationInterface $aggregations
+ * @return $this
+ */
+ public function setAggregations($aggregations)
+ {
+ $this->aggregations = $aggregations;
+ }
+
+
+ /**
+ * Retrieve all ids for collection
+ * Backward compatibility with EAV collection
+ *
+ * @param int $limit
+ * @param int $offset
+ * @return array
+ */
+ public function getAllIds($limit = null, $offset = null)
+ {
+ return $this->getConnection()->fetchCol($this->_getAllIdsSelect($limit, $offset), $this->_bindParams);
+ }
+
+ /**
+ * Get search criteria.
+ *
+ * @return \Magento\Framework\Api\SearchCriteriaInterface|null
+ */
+ public function getSearchCriteria()
+ {
+ return null;
+ }
+
+ /**
+ * Set search criteria.
+ *
+ * @param \Magento\Framework\Api\SearchCriteriaInterface $searchCriteria
+ * @return $this
+ * @SuppressWarnings(PHPMD.UnusedFormalParameter)
+ */
+ public function setSearchCriteria(\Magento\Framework\Api\SearchCriteriaInterface $searchCriteria = null)
+ {
+ return $this;
+ }
+
+ /**
+ * Get total count.
+ *
+ * @return int
+ */
+ public function getTotalCount()
+ {
+ return $this->getSize();
+ }
+
+ /**
+ * Set total count.
+ *
+ * @param int $totalCount
+ * @return $this
+ * @SuppressWarnings(PHPMD.UnusedFormalParameter)
+ */
+ public function setTotalCount($totalCount)
+ {
+ return $this;
+ }
+
+ /**
+ * Set items list.
+ *
+ * @param \Magento\Framework\Api\ExtensibleDataInterface[] $items
+ * @return $this
+ * @SuppressWarnings(PHPMD.UnusedFormalParameter)
+ */
+ public function setItems(array $items = null)
+ {
+ return $this;
+ }
+}
diff --git a/app/code/Magento/Cms/Model/Resource/Page/Collection.php b/app/code/Magento/Cms/Model/Resource/Page/Collection.php
index 7e6aa38ddf9f4..b8eadc87623f8 100644
--- a/app/code/Magento/Cms/Model/Resource/Page/Collection.php
+++ b/app/code/Magento/Cms/Model/Resource/Page/Collection.php
@@ -12,6 +12,11 @@
*/
class Collection extends \Magento\Framework\Model\Resource\Db\Collection\AbstractCollection
{
+ /**
+ * @var string
+ */
+ protected $_idFieldName = 'page_id';
+
/**
* Load data for preview flag
*
diff --git a/app/code/Magento/Cms/Model/Resource/Page/Grid/Collection.php b/app/code/Magento/Cms/Model/Resource/Page/Grid/Collection.php
new file mode 100644
index 0000000000000..f2df536005439
--- /dev/null
+++ b/app/code/Magento/Cms/Model/Resource/Page/Grid/Collection.php
@@ -0,0 +1,153 @@
+_eventPrefix = $eventPrefix;
+ $this->_eventObject = $eventObject;
+ $this->_init($model, $resourceModel);
+ $this->setMainTable($mainTable);
+ }
+
+ /**
+ * @return AggregationInterface
+ */
+ public function getAggregations()
+ {
+ return $this->aggregations;
+ }
+
+ /**
+ * @param AggregationInterface $aggregations
+ * @return $this
+ */
+ public function setAggregations($aggregations)
+ {
+ $this->aggregations = $aggregations;
+ }
+
+
+ /**
+ * Retrieve all ids for collection
+ * Backward compatibility with EAV collection
+ *
+ * @param int $limit
+ * @param int $offset
+ * @return array
+ */
+ public function getAllIds($limit = null, $offset = null)
+ {
+ return $this->getConnection()->fetchCol($this->_getAllIdsSelect($limit, $offset), $this->_bindParams);
+ }
+
+ /**
+ * Get search criteria.
+ *
+ * @return \Magento\Framework\Api\SearchCriteriaInterface|null
+ */
+ public function getSearchCriteria()
+ {
+ return null;
+ }
+
+ /**
+ * Set search criteria.
+ *
+ * @param \Magento\Framework\Api\SearchCriteriaInterface $searchCriteria
+ * @return $this
+ * @SuppressWarnings(PHPMD.UnusedFormalParameter)
+ */
+ public function setSearchCriteria(\Magento\Framework\Api\SearchCriteriaInterface $searchCriteria = null)
+ {
+ return $this;
+ }
+
+ /**
+ * Get total count.
+ *
+ * @return int
+ */
+ public function getTotalCount()
+ {
+ return $this->getSize();
+ }
+
+ /**
+ * Set total count.
+ *
+ * @param int $totalCount
+ * @return $this
+ * @SuppressWarnings(PHPMD.UnusedFormalParameter)
+ */
+ public function setTotalCount($totalCount)
+ {
+ return $this;
+ }
+
+ /**
+ * Set items list.
+ *
+ * @param \Magento\Framework\Api\ExtensibleDataInterface[] $items
+ * @return $this
+ * @SuppressWarnings(PHPMD.UnusedFormalParameter)
+ */
+ public function setItems(array $items = null)
+ {
+ return $this;
+ }
+}
diff --git a/app/code/Magento/Cms/etc/di.xml b/app/code/Magento/Cms/etc/di.xml
index ae53723ea07a3..3c24a50d54504 100644
--- a/app/code/Magento/Cms/etc/di.xml
+++ b/app/code/Magento/Cms/etc/di.xml
@@ -56,6 +56,30 @@
+
+
+
+ - Magento\Cms\Model\Resource\Page\Grid\Collection
+ - Magento\Cms\Model\Resource\Block\Grid\Collection
+
+
+
+
+
+ cms_page
+ cms_page_grid_collection
+ page_grid_collection
+ Magento\Cms\Model\Resource\Page
+
+
+
+
+ cms_block
+ cms_block_grid_collection
+ block_grid_collection
+ Magento\Cms\Model\Resource\Block
+
+
diff --git a/app/code/Magento/Cms/view/adminhtml/ui_component/cms_page_listing.xml b/app/code/Magento/Cms/view/adminhtml/ui_component/cms_page_listing.xml
index 0c39341b9fc6f..0edc6d6f675f4 100644
--- a/app/code/Magento/Cms/view/adminhtml/ui_component/cms_page_listing.xml
+++ b/app/code/Magento/Cms/view/adminhtml/ui_component/cms_page_listing.xml
@@ -25,7 +25,7 @@
PageGridDataProvider
cms_page_listing_data_source
- block_id
+ page_id
id
-
diff --git a/app/code/Magento/ConfigurableProduct/Ui/DataProvider/Attributes.php b/app/code/Magento/ConfigurableProduct/Ui/DataProvider/Attributes.php
index 2a59355b82834..69506ea143107 100644
--- a/app/code/Magento/ConfigurableProduct/Ui/DataProvider/Attributes.php
+++ b/app/code/Magento/ConfigurableProduct/Ui/DataProvider/Attributes.php
@@ -37,7 +37,7 @@ public function __construct(
/**
* @return \Magento\Catalog\Model\Resource\Product\Attribute\Collection
*/
- protected function getCollection()
+ public function getCollection()
{
return $this->collection;
}
diff --git a/app/code/Magento/Customer/Block/Adminhtml/Edit/Tab/Orders.php b/app/code/Magento/Customer/Block/Adminhtml/Edit/Tab/Orders.php
index 93effab82be11..3705f6451156f 100644
--- a/app/code/Magento/Customer/Block/Adminhtml/Edit/Tab/Orders.php
+++ b/app/code/Magento/Customer/Block/Adminhtml/Edit/Tab/Orders.php
@@ -27,16 +27,14 @@ class Orders extends \Magento\Backend\Block\Widget\Grid\Extended
protected $_coreRegistry = null;
/**
- * @var \Magento\Sales\Model\Resource\Order\Grid\CollectionFactory
+ * @var \Magento\Framework\View\Element\UiComponent\DataProvider\CollectionFactory
*/
- protected $_collectionFactory;
+ protected $collectionFactory;
/**
- * Constructor
- *
* @param \Magento\Backend\Block\Template\Context $context
* @param \Magento\Backend\Helper\Data $backendHelper
- * @param \Magento\Sales\Model\Resource\Order\Grid\CollectionFactory $collectionFactory
+ * @param \Magento\Framework\View\Element\UiComponent\DataProvider\CollectionFactory $collectionFactory
* @param \Magento\Sales\Helper\Reorder $salesReorder
* @param \Magento\Framework\Registry $coreRegistry
* @param array $data
@@ -44,7 +42,7 @@ class Orders extends \Magento\Backend\Block\Widget\Grid\Extended
public function __construct(
\Magento\Backend\Block\Template\Context $context,
\Magento\Backend\Helper\Data $backendHelper,
- \Magento\Sales\Model\Resource\Order\Grid\CollectionFactory $collectionFactory,
+ \Magento\Framework\View\Element\UiComponent\DataProvider\CollectionFactory $collectionFactory,
\Magento\Sales\Helper\Reorder $salesReorder,
\Magento\Framework\Registry $coreRegistry,
array $data = []
@@ -73,7 +71,7 @@ protected function _construct()
*/
protected function _prepareCollection()
{
- $collection = $this->_collectionFactory->create()->addFieldToSelect(
+ $collection = $this->_collectionFactory->getReport('sales_order_grid_data_source')->addFieldToSelect(
'entity_id'
)->addFieldToSelect(
'increment_id'
@@ -94,8 +92,6 @@ protected function _prepareCollection()
)->addFieldToFilter(
'customer_id',
$this->_coreRegistry->registry(RegistryConstants::CURRENT_CUSTOMER_ID)
- )->setIsCustomerMode(
- true
);
$this->setCollection($collection);
diff --git a/app/code/Magento/Customer/Block/Adminhtml/Edit/Tab/View/Orders.php b/app/code/Magento/Customer/Block/Adminhtml/Edit/Tab/View/Orders.php
deleted file mode 100644
index adc9caffbf026..0000000000000
--- a/app/code/Magento/Customer/Block/Adminhtml/Edit/Tab/View/Orders.php
+++ /dev/null
@@ -1,151 +0,0 @@
-_coreRegistry = $coreRegistry;
- $this->_collectionFactory = $collectionFactory;
- parent::__construct($context, $backendHelper, $data);
- }
-
- /**
- * Initialize the orders grid.
- *
- * @return void
- */
- protected function _construct()
- {
- parent::_construct();
- $this->setId('customer_view_orders_grid');
- $this->setDefaultSort('created_at', 'desc');
- $this->setSortable(false);
- $this->setPagerVisibility(false);
- $this->setFilterVisibility(false);
- }
-
- /**
- * {@inheritdoc}
- */
- protected function _preparePage()
- {
- $this->getCollection()->setPageSize(5)->setCurPage(1);
- }
-
- /**
- * {@inheritdoc}
- */
- protected function _prepareCollection()
- {
- $collection = $this->_collectionFactory->create()->addFieldToFilter(
- 'customer_id',
- $this->_coreRegistry->registry(RegistryConstants::CURRENT_CUSTOMER_ID)
- )->setIsCustomerMode(
- true
- );
- $this->setCollection($collection);
- return parent::_prepareCollection();
- }
-
- /**
- * {@inheritdoc}
- */
- protected function _prepareColumns()
- {
- $this->addColumn(
- 'increment_id',
- ['header' => __('Order'), 'align' => 'center', 'index' => 'increment_id', 'width' => '100px']
- );
-
- $this->addColumn(
- 'created_at',
- ['header' => __('Purchased'), 'index' => 'created_at', 'type' => 'datetime']
- );
-
- $this->addColumn('billing_name', ['header' => __('Bill-to Name'), 'index' => 'billing_name']);
-
- $this->addColumn('shipping_name', ['header' => __('Shipped-to Name'), 'index' => 'shipping_name']);
-
- $this->addColumn(
- 'grand_total',
- [
- 'header' => __('Grand Total'),
- 'index' => 'grand_total',
- 'type' => 'currency',
- 'currency' => 'order_currency_code'
- ]
- );
-
- if (!$this->_storeManager->isSingleStoreMode()) {
- $this->addColumn(
- 'store_id',
- ['header' => __('Purchase Point'), 'index' => 'store_id', 'type' => 'store', 'store_view' => true]
- );
- }
-
- $this->addColumn(
- 'action',
- [
- 'header' => ' ',
- 'filter' => false,
- 'sortable' => false,
- 'width' => '100px',
- 'renderer' => 'Magento\Sales\Block\Adminhtml\Reorder\Renderer\Action'
- ]
- );
-
- return parent::_prepareColumns();
- }
-
- /**
- * {@inheritdoc}
- */
- public function getRowUrl($row)
- {
- return $this->getUrl('sales/order/view', ['order_id' => $row->getId()]);
- }
-
- /**
- * {@inheritdoc}
- */
- public function getHeadersVisibility()
- {
- return $this->getCollection()->getSize() >= 0;
- }
-}
diff --git a/app/code/Magento/Customer/Model/Customer/DataProvider.php b/app/code/Magento/Customer/Model/Customer/DataProvider.php
index 23fe67286f29a..750e3b9dba7b6 100644
--- a/app/code/Magento/Customer/Model/Customer/DataProvider.php
+++ b/app/code/Magento/Customer/Model/Customer/DataProvider.php
@@ -108,22 +108,6 @@ public function __construct(
);
}
- /**
- * @return Collection|\Magento\Framework\Model\Resource\Db\Collection\AbstractCollection
- */
- protected function getCollection()
- {
- return $this->collection;
- }
-
- /**
- * @inheritdoc
- */
- public function addFilter($condition, $field = null, $type = 'regular')
- {
- $this->filterPool->registerNewFilter($condition, $field, $type);
- }
-
/**
* Get data
*
@@ -134,7 +118,6 @@ public function getData()
if (isset($this->loadedData)) {
return $this->loadedData;
}
- $this->filterPool->applyFilters($this->collection);
$items = $this->collection->getItems();
/** @var Customer $customer */
foreach ($items as $customer) {
@@ -158,17 +141,6 @@ public function getData()
return $this->loadedData;
}
- /**
- * Retrieve count of loaded items
- *
- * @return int
- */
- public function count()
- {
- $this->filterPool->applyFilters($this->collection);
- return $this->collection->count();
- }
-
/**
* Get attributes meta
*
diff --git a/app/code/Magento/Customer/view/adminhtml/layout/customer_index_lastorders.xml b/app/code/Magento/Customer/view/adminhtml/layout/customer_index_lastorders.xml
deleted file mode 100644
index 49c2cf49f3488..0000000000000
--- a/app/code/Magento/Customer/view/adminhtml/layout/customer_index_lastorders.xml
+++ /dev/null
@@ -1,12 +0,0 @@
-
-
-
-
-
-
-
diff --git a/app/code/Magento/Sales/Block/Adminhtml/Order/Grid.php b/app/code/Magento/Sales/Block/Adminhtml/Order/Grid.php
deleted file mode 100644
index f3b8531f03bb6..0000000000000
--- a/app/code/Magento/Sales/Block/Adminhtml/Order/Grid.php
+++ /dev/null
@@ -1,15 +0,0 @@
-
- */
-class Grid extends \Magento\Backend\Block\Widget\Grid
-{
-}
diff --git a/app/code/Magento/Sales/Block/Adminhtml/Reorder/Renderer/Action.php b/app/code/Magento/Sales/Block/Adminhtml/Reorder/Renderer/Action.php
index 31827e5595f30..3780d74a3b9bd 100644
--- a/app/code/Magento/Sales/Block/Adminhtml/Reorder/Renderer/Action.php
+++ b/app/code/Magento/Sales/Block/Adminhtml/Reorder/Renderer/Action.php
@@ -47,7 +47,7 @@ public function __construct(
public function render(\Magento\Framework\DataObject $row)
{
$this->_actions = [];
- if ($this->_salesReorder->canReorder($row)) {
+ if ($this->_salesReorder->canReorder($row->getId())) {
$reorderAction = [
'@' => [
'href' => $this->getUrl('sales/order_create/reorder', ['order_id' => $row->getId()]),
diff --git a/app/code/Magento/Sales/Controller/Adminhtml/Creditmemo/AbstractCreditmemo/Pdfcreditmemos.php b/app/code/Magento/Sales/Controller/Adminhtml/Creditmemo/AbstractCreditmemo/Pdfcreditmemos.php
index 1e5bce8fb535a..920be7c4c242a 100644
--- a/app/code/Magento/Sales/Controller/Adminhtml/Creditmemo/AbstractCreditmemo/Pdfcreditmemos.php
+++ b/app/code/Magento/Sales/Controller/Adminhtml/Creditmemo/AbstractCreditmemo/Pdfcreditmemos.php
@@ -7,31 +7,56 @@
use Magento\Framework\App\ResponseInterface;
use Magento\Framework\App\Filesystem\DirectoryList;
-
use Magento\Framework\Model\Resource\Db\Collection\AbstractCollection;
+use Magento\Sales\Model\Order\Pdf\Creditmemo;
+use Magento\Framework\Stdlib\DateTime\DateTime;
+use Magento\Backend\App\Action\Context;
+use Magento\Framework\App\Response\Http\FileFactory;
+use Magento\Ui\Component\MassAction\Filter;
+use Magento\Sales\Model\Resource\Order\Creditmemo\CollectionFactory;
+/**
+ * Class Pdfcreditmemos
+ * @SuppressWarnings(PHPMD.CouplingBetweenObjects)
+ */
class Pdfcreditmemos extends \Magento\Sales\Controller\Adminhtml\Order\AbstractMassAction
{
/**
- * @var \Magento\Framework\App\Response\Http\FileFactory
+ * @var FileFactory
*/
- protected $_fileFactory;
+ protected $fileFactory;
/**
- * @var string
+ * @var Creditmemo
*/
- protected $collection = 'Magento\Sales\Model\Resource\Order\Creditmemo\Grid\Collection';
+ protected $pdfCreditmemo;
/**
- * @param \Magento\Backend\App\Action\Context $context
- * @param \Magento\Framework\App\Response\Http\FileFactory $fileFactory
+ * @var DateTime
+ */
+ protected $dateTime;
+
+ /**
+ * @param Context $context
+ * @param Filter $filter
+ * @param Creditmemo $pdfCreditmemo
+ * @param DateTime $dateTime
+ * @param FileFactory $fileFactory
+ * @param CollectionFactory $collectionFactory
*/
public function __construct(
- \Magento\Backend\App\Action\Context $context,
- \Magento\Framework\App\Response\Http\FileFactory $fileFactory
+ Context $context,
+ Filter $filter,
+ Creditmemo $pdfCreditmemo,
+ DateTime $dateTime,
+ FileFactory $fileFactory,
+ CollectionFactory $collectionFactory
) {
- $this->_fileFactory = $fileFactory;
- parent::__construct($context);
+ $this->pdfCreditmemo = $pdfCreditmemo;
+ $this->fileFactory = $fileFactory;
+ $this->dateTime = $dateTime;
+ $this->collectionFactory = $collectionFactory;
+ parent::__construct($context, $filter);
}
/**
@@ -44,22 +69,15 @@ protected function _isAllowed()
/**
* @param AbstractCollection $collection
- * @return ResponseInterface|\Magento\Framework\Controller\Result\Redirect
+ * @return ResponseInterface
* @throws \Exception
+ * @throws \Zend_Pdf_Exception
*/
public function massAction(AbstractCollection $collection)
{
- if (!isset($pdf)) {
- $pdf = $this->_objectManager->create('Magento\Sales\Model\Order\Pdf\Creditmemo')->getPdf($collection);
- } else {
- $pages = $this->_objectManager->create('Magento\Sales\Model\Order\Pdf\Creditmemo')->getPdf($collection);
- $pdf->pages = array_merge($pdf->pages, $pages->pages);
- }
- $date = $this->_objectManager->get('Magento\Framework\Stdlib\DateTime\DateTime')->date('Y-m-d_H-i-s');
-
- return $this->_fileFactory->create(
- 'creditmemo' . $date . '.pdf',
- $pdf->render(),
+ return $this->fileFactory->create(
+ sprintf('creditmemo%s.pdf', $this->dateTime->date('Y-m-d_H-i-s')),
+ $this->pdfCreditmemo->getPdf($collection)->render(),
DirectoryList::VAR_DIR,
'application/pdf'
);
diff --git a/app/code/Magento/Sales/Controller/Adminhtml/Creditmemo/ExportCsv.php b/app/code/Magento/Sales/Controller/Adminhtml/Creditmemo/ExportCsv.php
deleted file mode 100644
index b7b09998c15f7..0000000000000
--- a/app/code/Magento/Sales/Controller/Adminhtml/Creditmemo/ExportCsv.php
+++ /dev/null
@@ -1,59 +0,0 @@
-_fileFactory = $fileFactory;
- $this->resultLayoutFactory = $resultLayoutFactory;
- parent::__construct($context);
- }
-
- /**
- * {@inheritdoc}
- */
- protected function _isAllowed()
- {
- return $this->_authorization->isAllowed('Magento_Sales::sales_creditmemo');
- }
-
- /**
- * Export credit memo grid to CSV format
- *
- * @return ResponseInterface
- */
- public function execute()
- {
- $fileName = 'creditmemos.csv';
- $resultLayout = $this->resultLayoutFactory->create();
- $grid = $resultLayout->getLayout()->getChildBlock('sales.creditmemo.grid', 'grid.export');
- $csvFile = $grid->getCsvFile();
- return $this->_fileFactory->create($fileName, $csvFile, DirectoryList::VAR_DIR);
- }
-}
diff --git a/app/code/Magento/Sales/Controller/Adminhtml/Creditmemo/ExportExcel.php b/app/code/Magento/Sales/Controller/Adminhtml/Creditmemo/ExportExcel.php
deleted file mode 100644
index 8fe35c3d16a05..0000000000000
--- a/app/code/Magento/Sales/Controller/Adminhtml/Creditmemo/ExportExcel.php
+++ /dev/null
@@ -1,59 +0,0 @@
-_fileFactory = $fileFactory;
- $this->resultLayoutFactory = $resultLayoutFactory;
- parent::__construct($context);
- }
-
- /**
- * {@inheritdoc}
- */
- protected function _isAllowed()
- {
- return $this->_authorization->isAllowed('Magento_Sales::sales_creditmemo');
- }
-
- /**
- * Export credit memo grid to Excel XML format
- *
- * @return ResponseInterface
- */
- public function execute()
- {
- $fileName = 'creditmemos.xml';
- $resultLayout = $this->resultLayoutFactory->create();
- $grid = $resultLayout->getLayout()->getChildBlock('sales.creditmemo.grid', 'grid.export');
- $excelFile = $grid->getExcelFile($fileName);
- return $this->_fileFactory->create($fileName, $excelFile, DirectoryList::VAR_DIR);
- }
-}
diff --git a/app/code/Magento/Sales/Controller/Adminhtml/Invoice/AbstractInvoice/Pdfinvoices.php b/app/code/Magento/Sales/Controller/Adminhtml/Invoice/AbstractInvoice/Pdfinvoices.php
index 12c563f57151d..8753a3f8a4c15 100644
--- a/app/code/Magento/Sales/Controller/Adminhtml/Invoice/AbstractInvoice/Pdfinvoices.php
+++ b/app/code/Magento/Sales/Controller/Adminhtml/Invoice/AbstractInvoice/Pdfinvoices.php
@@ -9,31 +9,51 @@
use Magento\Framework\App\ResponseInterface;
use Magento\Framework\App\Filesystem\DirectoryList;
use Magento\Framework\Model\Resource\Db\Collection\AbstractCollection;
+use Magento\Ui\Component\MassAction\Filter;
+use Magento\Sales\Model\Order\Pdf\Invoice;
+use Magento\Framework\Stdlib\DateTime\DateTime;
+use Magento\Framework\App\Response\Http\FileFactory;
+use Magento\Backend\App\Action\Context;
+use Magento\Sales\Model\Resource\Order\Invoice\CollectionFactory;
abstract class Pdfinvoices extends \Magento\Sales\Controller\Adminhtml\Order\AbstractMassAction
{
/**
- * @var \Magento\Framework\App\Response\Http\FileFactory
+ * @var FileFactory
*/
- protected $_fileFactory;
+ protected $fileFactory;
/**
- * Resource collection
- *
- * @var string
+ * @var DateTime
*/
- protected $collection = 'Magento\Sales\Model\Resource\Order\Invoice\Grid\Collection';
+ protected $dateTime;
/**
- * @param \Magento\Backend\App\Action\Context $context
- * @param \Magento\Framework\App\Response\Http\FileFactory $fileFactory
+ * @var Invoice
+ */
+ protected $pdfInvoice;
+
+ /**
+ * @param Context $context
+ * @param Filter $filter
+ * @param DateTime $dateTime
+ * @param FileFactory $fileFactory
+ * @param Invoice $pdfInvoice
+ * @param CollectionFactory $collectionFactory
*/
public function __construct(
- \Magento\Backend\App\Action\Context $context,
- \Magento\Framework\App\Response\Http\FileFactory $fileFactory
+ Context $context,
+ Filter $filter,
+ DateTime $dateTime,
+ FileFactory $fileFactory,
+ Invoice $pdfInvoice,
+ CollectionFactory $collectionFactory
) {
- $this->_fileFactory = $fileFactory;
- parent::__construct($context);
+ $this->fileFactory = $fileFactory;
+ $this->dateTime = $dateTime;
+ $this->pdfInvoice = $pdfInvoice;
+ $this->collectionFactory = $collectionFactory;
+ parent::__construct($context, $filter);
}
/**
@@ -53,17 +73,9 @@ protected function _isAllowed()
*/
public function massAction(AbstractCollection $collection)
{
- if (!isset($pdf)) {
- $pdf = $this->_objectManager->create('Magento\Sales\Model\Order\Pdf\Invoice')->getPdf($collection);
- } else {
- $pages = $this->_objectManager->create('Magento\Sales\Model\Order\Pdf\Invoice')->getPdf($collection);
- $pdf->pages = array_merge($pdf->pages, $pages->pages);
- }
- $date = $this->_objectManager->get('Magento\Framework\Stdlib\DateTime\DateTime')->date('Y-m-d_H-i-s');
-
- return $this->_fileFactory->create(
- 'invoice' . $date . '.pdf',
- $pdf->render(),
+ return $this->fileFactory->create(
+ sprintf('invoice%s.pdf', $this->dateTime->date('Y-m-d_H-i-s')),
+ $this->pdfInvoice->getPdf($collection)->render(),
DirectoryList::VAR_DIR,
'application/pdf'
);
diff --git a/app/code/Magento/Sales/Controller/Adminhtml/Invoice/ExportCsv.php b/app/code/Magento/Sales/Controller/Adminhtml/Invoice/ExportCsv.php
deleted file mode 100644
index d682c410cfb86..0000000000000
--- a/app/code/Magento/Sales/Controller/Adminhtml/Invoice/ExportCsv.php
+++ /dev/null
@@ -1,65 +0,0 @@
-_fileFactory = $fileFactory;
- parent::__construct($context);
- $this->resultLayoutFactory = $resultLayoutFactory;
- }
-
- /**
- * {@inheritdoc}
- */
- protected function _isAllowed()
- {
- return $this->_authorization->isAllowed('Magento_Sales::sales_invoice');
- }
-
- /**
- * Export invoice grid to CSV format
- *
- * @return ResponseInterface
- */
- public function execute()
- {
- $fileName = 'invoices.csv';
- /** @var \Magento\Backend\Block\Widget\Grid\ExportInterface $exportBlock */
- $exportBlock = $this->resultLayoutFactory->create()
- ->getLayout()
- ->getChildBlock('sales.invoice.grid', 'grid.export');
- return $this->_fileFactory->create(
- $fileName,
- $exportBlock->getCsvFile(),
- DirectoryList::VAR_DIR
- );
- }
-}
diff --git a/app/code/Magento/Sales/Controller/Adminhtml/Invoice/ExportExcel.php b/app/code/Magento/Sales/Controller/Adminhtml/Invoice/ExportExcel.php
deleted file mode 100644
index ab6d4519ffb61..0000000000000
--- a/app/code/Magento/Sales/Controller/Adminhtml/Invoice/ExportExcel.php
+++ /dev/null
@@ -1,64 +0,0 @@
-_fileFactory = $fileFactory;
- parent::__construct($context);
- $this->resultLayoutFactory = $resultLayoutFactory;
- }
-
- /**
- * {@inheritdoc}
- */
- protected function _isAllowed()
- {
- return $this->_authorization->isAllowed('Magento_Sales::sales_invoice');
- }
-
- /**
- * Export invoice grid to Excel XML format
- *
- * @return ResponseInterface
- */
- public function execute()
- {
- $fileName = 'invoices.xml';
- $exportBlock = $this->resultLayoutFactory->create()
- ->getLayout()
- ->getChildBlock('sales.invoice.grid', 'grid.export');
- return $this->_fileFactory->create(
- $fileName,
- $exportBlock->getExcelFile($fileName),
- DirectoryList::VAR_DIR
- );
- }
-}
diff --git a/app/code/Magento/Sales/Controller/Adminhtml/Order.php b/app/code/Magento/Sales/Controller/Adminhtml/Order.php
index 4232fc9173aba..32e3e51051881 100644
--- a/app/code/Magento/Sales/Controller/Adminhtml/Order.php
+++ b/app/code/Magento/Sales/Controller/Adminhtml/Order.php
@@ -6,12 +6,18 @@
namespace Magento\Sales\Controller\Adminhtml;
use Magento\Backend\App\Action;
+use Magento\Sales\Api\OrderManagementInterface;
+use Magento\Sales\Api\OrderRepositoryInterface;
+use Magento\Framework\Exception\NoSuchEntityException;
+use Magento\Framework\Exception\InputException;
+use Psr\Log\LoggerInterface;
/**
* Adminhtml sales orders controller
*
* @author Magento Core Team
* @SuppressWarnings(PHPMD.NumberOfChildren)
+ * @SuppressWarnings(PHPMD.CouplingBetweenObjects)
*/
abstract class Order extends \Magento\Backend\App\Action
{
@@ -59,6 +65,21 @@ abstract class Order extends \Magento\Backend\App\Action
*/
protected $resultRawFactory;
+ /**
+ * @var OrderManagementInterface
+ */
+ protected $orderManagement;
+
+ /**
+ * @var OrderRepositoryInterface
+ */
+ protected $orderRepository;
+
+ /**
+ * @var LoggerInterface
+ */
+ protected $logger;
+
/**
* @param Action\Context $context
* @param \Magento\Framework\Registry $coreRegistry
@@ -68,6 +89,12 @@ abstract class Order extends \Magento\Backend\App\Action
* @param \Magento\Framework\Controller\Result\JsonFactory $resultJsonFactory
* @param \Magento\Framework\View\Result\LayoutFactory $resultLayoutFactory
* @param \Magento\Framework\Controller\Result\RawFactory $resultRawFactory
+ * @param OrderManagementInterface $orderManagement
+ * @param OrderRepositoryInterface $orderRepository
+ * @param LoggerInterface $logger
+ *
+ * @SuppressWarnings(PHPMD.ExcessiveParameterList)
+ * @SuppressWarnings(PHPMD.CouplingBetweenObjects)
*/
public function __construct(
Action\Context $context,
@@ -77,7 +104,10 @@ public function __construct(
\Magento\Framework\View\Result\PageFactory $resultPageFactory,
\Magento\Framework\Controller\Result\JsonFactory $resultJsonFactory,
\Magento\Framework\View\Result\LayoutFactory $resultLayoutFactory,
- \Magento\Framework\Controller\Result\RawFactory $resultRawFactory
+ \Magento\Framework\Controller\Result\RawFactory $resultRawFactory,
+ OrderManagementInterface $orderManagement,
+ OrderRepositoryInterface $orderRepository,
+ LoggerInterface $logger
) {
$this->_coreRegistry = $coreRegistry;
$this->_fileFactory = $fileFactory;
@@ -86,6 +116,9 @@ public function __construct(
$this->resultJsonFactory = $resultJsonFactory;
$this->resultLayoutFactory = $resultLayoutFactory;
$this->resultRawFactory = $resultRawFactory;
+ $this->orderManagement = $orderManagement;
+ $this->orderRepository = $orderRepository;
+ $this->logger = $logger;
parent::__construct($context);
}
@@ -106,14 +139,18 @@ protected function _initAction()
/**
* Initialize order model instance
*
- * @return \Magento\Sales\Model\Order|false
+ * @return \Magento\Sales\Api\Data\OrderInterface|false
*/
protected function _initOrder()
{
$id = $this->getRequest()->getParam('order_id');
- $order = $this->_objectManager->create('Magento\Sales\Model\Order')->load($id);
-
- if (!$order->getId()) {
+ try {
+ $order = $this->orderRepository->get($id);
+ } catch (NoSuchEntityException $e) {
+ $this->messageManager->addError(__('This order no longer exists.'));
+ $this->_actionFlag->set('', self::FLAG_NO_DISPATCH, true);
+ return false;
+ } catch (InputException $e) {
$this->messageManager->addError(__('This order no longer exists.'));
$this->_actionFlag->set('', self::FLAG_NO_DISPATCH, true);
return false;
diff --git a/app/code/Magento/Sales/Controller/Adminhtml/Order/AbstractMassAction.php b/app/code/Magento/Sales/Controller/Adminhtml/Order/AbstractMassAction.php
index fe4f2aeb163b6..08fbda748c577 100644
--- a/app/code/Magento/Sales/Controller/Adminhtml/Order/AbstractMassAction.php
+++ b/app/code/Magento/Sales/Controller/Adminhtml/Order/AbstractMassAction.php
@@ -7,6 +7,10 @@
use Magento\Framework\Model\Resource\Db\Collection\AbstractCollection;
use Magento\Framework\Controller\ResultFactory;
+use Magento\Framework\App\ResponseInterface;
+use Magento\Framework\Controller\ResultInterface;
+use Magento\Backend\App\Action\Context;
+use Magento\Ui\Component\MassAction\Filter;
/**
* Class AbstractMassStatus
@@ -14,21 +18,29 @@
abstract class AbstractMassAction extends \Magento\Backend\App\Action
{
/**
- * Field id
+ * @var string
*/
- const ID_FIELD = 'entity_id';
+ protected $redirectUrl = '*/*/';
/**
- * Redirect url
+ * @var \Magento\Ui\Component\MassAction\Filter
*/
- const REDIRECT_URL = 'sales/order/';
+ protected $filter;
/**
- * Resource collection
- *
- * @var string
+ * @var object
+ */
+ protected $collectionFactory;
+
+ /**
+ * @param Context $context
+ * @param Filter $filter
*/
- protected $collection = 'Magento\Sales\Model\Resource\Order\Grid\Collection';
+ public function __construct(Context $context, Filter $filter)
+ {
+ parent::__construct($context);
+ $this->filter = $filter;
+ }
/**
* Execute action
@@ -38,34 +50,32 @@ abstract class AbstractMassAction extends \Magento\Backend\App\Action
*/
public function execute()
{
- $selected = $this->getRequest()->getParam('selected');
- $excluded = $this->getRequest()->getParam('excluded');
-
- $collection = $this->_objectManager->create($this->collection);
try {
- if (!empty($excluded)) {
- $collection->addFieldToFilter(static::ID_FIELD, ['nin' => $excluded]);
- $this->massAction($collection);
- } elseif (!empty($selected)) {
- $collection->addFieldToFilter(static::ID_FIELD, ['in' => $selected]);
- $this->massAction($collection);
- } else {
- $this->messageManager->addError(__('Please select item(s).'));
- }
+ $collection = $this->filter->getCollection($this->collectionFactory->create());
+ return $this->massAction($collection);
} catch (\Exception $e) {
$this->messageManager->addError($e->getMessage());
+ /** @var \Magento\Backend\Model\View\Result\Redirect $resultRedirect */
+ $resultRedirect = $this->resultFactory->create(ResultFactory::TYPE_REDIRECT);
+ return $resultRedirect->setPath($this->redirectUrl);
}
-
- /** @var \Magento\Backend\Model\View\Result\Redirect $resultRedirect */
- $resultRedirect = $this->resultFactory->create(ResultFactory::TYPE_REDIRECT);
- return $resultRedirect->setPath(static::REDIRECT_URL);
}
+ /**
+ * Return component referer url
+ * TODO: Technical dept referer url should be implement as a part of Action configuration in in appropriate way
+ *
+ * @return null|string
+ */
+ protected function getComponentRefererUrl()
+ {
+ return $this->filter->getComponentRefererUrl()?: 'sales/*/';
+ }
/**
* Set status to collection items
*
* @param AbstractCollection $collection
- * @return void
+ * @return ResponseInterface|ResultInterface
*/
abstract protected function massAction(AbstractCollection $collection);
}
diff --git a/app/code/Magento/Sales/Controller/Adminhtml/Order/Cancel.php b/app/code/Magento/Sales/Controller/Adminhtml/Order/Cancel.php
index bbe955546d34f..78ddf1b55c588 100644
--- a/app/code/Magento/Sales/Controller/Adminhtml/Order/Cancel.php
+++ b/app/code/Magento/Sales/Controller/Adminhtml/Order/Cancel.php
@@ -19,8 +19,7 @@ public function execute()
$resultRedirect = $this->resultRedirectFactory->create();
if ($order) {
try {
- $orderManagement = $this->_objectManager->get('Magento\Sales\Api\OrderManagementInterface');
- $orderManagement->cancel($order->getEntityId());
+ $this->orderManagement->cancel($order->getEntityId());
$this->messageManager->addSuccess(__('You canceled the order.'));
} catch (\Magento\Framework\Exception\LocalizedException $e) {
$this->messageManager->addError($e->getMessage());
diff --git a/app/code/Magento/Sales/Controller/Adminhtml/Order/CommentsHistory.php b/app/code/Magento/Sales/Controller/Adminhtml/Order/CommentsHistory.php
index 42515bde1f868..54774ec719e7d 100644
--- a/app/code/Magento/Sales/Controller/Adminhtml/Order/CommentsHistory.php
+++ b/app/code/Magento/Sales/Controller/Adminhtml/Order/CommentsHistory.php
@@ -7,7 +7,14 @@
namespace Magento\Sales\Controller\Adminhtml\Order;
use Magento\Backend\App\Action;
+use Magento\Sales\Api\OrderManagementInterface;
+use Magento\Sales\Api\OrderRepositoryInterface;
+use Psr\Log\LoggerInterface;
+/**
+ * Class CommentsHistory
+ * @SuppressWarnings(PHPMD.CouplingBetweenObjects)
+ */
class CommentsHistory extends \Magento\Sales\Controller\Adminhtml\Order
{
/**
@@ -24,9 +31,13 @@ class CommentsHistory extends \Magento\Sales\Controller\Adminhtml\Order
* @param \Magento\Framework\Controller\Result\JsonFactory $resultJsonFactory
* @param \Magento\Framework\View\Result\LayoutFactory $resultLayoutFactory
* @param \Magento\Framework\Controller\Result\RawFactory $resultRawFactory
+ * @param OrderManagementInterface $orderManagement
+ * @param OrderRepositoryInterface $orderRepository
+ * @param LoggerInterface $logger
* @param \Magento\Framework\View\LayoutFactory $layoutFactory
*
* @SuppressWarnings(PHPMD.ExcessiveParameterList)
+ * @SuppressWarnings(PHPMD.CouplingBetweenObjects)
*/
public function __construct(
Action\Context $context,
@@ -37,6 +48,9 @@ public function __construct(
\Magento\Framework\Controller\Result\JsonFactory $resultJsonFactory,
\Magento\Framework\View\Result\LayoutFactory $resultLayoutFactory,
\Magento\Framework\Controller\Result\RawFactory $resultRawFactory,
+ OrderManagementInterface $orderManagement,
+ OrderRepositoryInterface $orderRepository,
+ LoggerInterface $logger,
\Magento\Framework\View\LayoutFactory $layoutFactory
) {
$this->layoutFactory = $layoutFactory;
@@ -48,7 +62,10 @@ public function __construct(
$resultPageFactory,
$resultJsonFactory,
$resultLayoutFactory,
- $resultRawFactory
+ $resultRawFactory,
+ $orderManagement,
+ $orderRepository,
+ $logger
);
}
diff --git a/app/code/Magento/Sales/Controller/Adminhtml/Order/Create/Reorder.php b/app/code/Magento/Sales/Controller/Adminhtml/Order/Create/Reorder.php
index 8a6ec65118647..b64cb14c95c39 100644
--- a/app/code/Magento/Sales/Controller/Adminhtml/Order/Create/Reorder.php
+++ b/app/code/Magento/Sales/Controller/Adminhtml/Order/Create/Reorder.php
@@ -15,7 +15,7 @@ public function execute()
$this->_getSession()->clearStorage();
$orderId = $this->getRequest()->getParam('order_id');
$order = $this->_objectManager->create('Magento\Sales\Model\Order')->load($orderId);
- if (!$this->_objectManager->get('Magento\Sales\Helper\Reorder')->canReorder($order)) {
+ if (!$this->_objectManager->get('Magento\Sales\Helper\Reorder')->canReorder($order->getEntityId())) {
return $this->resultForwardFactory->create()->forward('noroute');
}
diff --git a/app/code/Magento/Sales/Controller/Adminhtml/Order/Email.php b/app/code/Magento/Sales/Controller/Adminhtml/Order/Email.php
index cae0ea11baacd..ae1763485bdbc 100644
--- a/app/code/Magento/Sales/Controller/Adminhtml/Order/Email.php
+++ b/app/code/Magento/Sales/Controller/Adminhtml/Order/Email.php
@@ -17,16 +17,20 @@ public function execute()
$order = $this->_initOrder();
if ($order) {
try {
- $orderManagement = $this->_objectManager->create('Magento\Sales\Api\OrderManagementInterface');
- $orderManagement->notify($order->getEntityId());
+ $this->orderManagement->notify($order->getEntityId());
$this->messageManager->addSuccess(__('You sent the order email.'));
} catch (\Magento\Framework\Exception\LocalizedException $e) {
$this->messageManager->addError($e->getMessage());
} catch (\Exception $e) {
$this->messageManager->addError(__('We can\'t send the email order right now.'));
- $this->_objectManager->get('Psr\Log\LoggerInterface')->critical($e);
+ $this->logger->critical($e);
}
- return $this->resultRedirectFactory->create()->setPath('sales/order/view', ['order_id' => $order->getId()]);
+ return $this->resultRedirectFactory->create()->setPath(
+ 'sales/order/view',
+ [
+ 'order_id' => $order->getEntityId()
+ ]
+ );
}
return $this->resultRedirectFactory->create()->setPath('sales/*/');
}
diff --git a/app/code/Magento/Sales/Controller/Adminhtml/Order/ExportCsv.php b/app/code/Magento/Sales/Controller/Adminhtml/Order/ExportCsv.php
deleted file mode 100644
index 6c80caafe4184..0000000000000
--- a/app/code/Magento/Sales/Controller/Adminhtml/Order/ExportCsv.php
+++ /dev/null
@@ -1,28 +0,0 @@
-resultPageFactory->create()
- ->getLayout()
- ->getChildBlock('sales.order.grid', 'grid.export');
- return $this->_fileFactory->create($fileName, $exportBlock->getCsvFile(), DirectoryList::VAR_DIR);
- }
-}
diff --git a/app/code/Magento/Sales/Controller/Adminhtml/Order/ExportExcel.php b/app/code/Magento/Sales/Controller/Adminhtml/Order/ExportExcel.php
deleted file mode 100644
index 9cb3c880464f2..0000000000000
--- a/app/code/Magento/Sales/Controller/Adminhtml/Order/ExportExcel.php
+++ /dev/null
@@ -1,28 +0,0 @@
-resultPageFactory->create()
- ->getLayout()
- ->getChildBlock('sales.order.grid', 'grid.export');
- return $this->_fileFactory->create($fileName, $exportBlock->getExcelFile($fileName), DirectoryList::VAR_DIR);
- }
-}
diff --git a/app/code/Magento/Sales/Controller/Adminhtml/Order/Hold.php b/app/code/Magento/Sales/Controller/Adminhtml/Order/Hold.php
index ba69fe6510059..a03f07f99dd2d 100644
--- a/app/code/Magento/Sales/Controller/Adminhtml/Order/Hold.php
+++ b/app/code/Magento/Sales/Controller/Adminhtml/Order/Hold.php
@@ -18,8 +18,7 @@ public function execute()
$resultRedirect = $this->resultRedirectFactory->create();
if ($order) {
try {
- $orderManagement = $this->_objectManager->get('Magento\Sales\Api\OrderManagementInterface');
- $orderManagement->hold($order->getEntityId());
+ $this->orderManagement->hold($order->getEntityId());
$this->messageManager->addSuccess(__('You put the order on hold.'));
} catch (\Magento\Framework\Exception\LocalizedException $e) {
$this->messageManager->addError($e->getMessage());
diff --git a/app/code/Magento/Sales/Controller/Adminhtml/Order/MassCancel.php b/app/code/Magento/Sales/Controller/Adminhtml/Order/MassCancel.php
index 24330e58bf0d8..46a83b9afb198 100644
--- a/app/code/Magento/Sales/Controller/Adminhtml/Order/MassCancel.php
+++ b/app/code/Magento/Sales/Controller/Adminhtml/Order/MassCancel.php
@@ -6,26 +6,38 @@
namespace Magento\Sales\Controller\Adminhtml\Order;
use Magento\Framework\Model\Resource\Db\Collection\AbstractCollection;
+use Magento\Backend\App\Action\Context;
+use Magento\Ui\Component\MassAction\Filter;
+use Magento\Sales\Model\Resource\Order\CollectionFactory;
class MassCancel extends \Magento\Sales\Controller\Adminhtml\Order\AbstractMassAction
{
+ /**
+ * @param Context $context
+ * @param Filter $filter
+ * @param CollectionFactory $collectionFactory
+ */
+ public function __construct(Context $context, Filter $filter, CollectionFactory $collectionFactory)
+ {
+ parent::__construct($context, $filter);
+ $this->collectionFactory = $collectionFactory;
+ }
+
/**
* Cancel selected orders
*
* @param AbstractCollection $collection
- * @return void
+ * @return \Magento\Backend\Model\View\Result\Redirect
*/
protected function massAction(AbstractCollection $collection)
{
$countCancelOrder = 0;
-
- /** @var \Magento\Sales\Api\OrderManagementInterface $orderManagement */
- $orderManagement = $this->_objectManager->get('Magento\Sales\Api\OrderManagementInterface');
foreach ($collection->getItems() as $order) {
if (!$order->canCancel()) {
continue;
}
- $orderManagement->cancel($order->getEntityId());
+ $order->cancel();
+ $order->save();
$countCancelOrder++;
}
$countNonCancelOrder = $collection->count() - $countCancelOrder;
@@ -39,5 +51,8 @@ protected function massAction(AbstractCollection $collection)
if ($countCancelOrder) {
$this->messageManager->addSuccess(__('We canceled %1 order(s).', $countCancelOrder));
}
+ $resultRedirect = $this->resultRedirectFactory->create();
+ $resultRedirect->setPath($this->getComponentRefererUrl());
+ return $resultRedirect;
}
}
diff --git a/app/code/Magento/Sales/Controller/Adminhtml/Order/MassHold.php b/app/code/Magento/Sales/Controller/Adminhtml/Order/MassHold.php
index cce9ab02eb325..9f660fd61f6cd 100644
--- a/app/code/Magento/Sales/Controller/Adminhtml/Order/MassHold.php
+++ b/app/code/Magento/Sales/Controller/Adminhtml/Order/MassHold.php
@@ -6,9 +6,38 @@
namespace Magento\Sales\Controller\Adminhtml\Order;
use Magento\Framework\Model\Resource\Db\Collection\AbstractCollection;
+use Magento\Backend\App\Action\Context;
+use Magento\Ui\Component\MassAction\Filter;
+use Magento\Sales\Model\Resource\Order\CollectionFactory;
+use Magento\Sales\Api\OrderManagementInterface;
+/**
+ * Class MassHold
+ */
class MassHold extends \Magento\Sales\Controller\Adminhtml\Order\AbstractMassAction
{
+ /**
+ * @var OrderManagementInterface
+ */
+ protected $orderManagement;
+
+ /**
+ * @param Context $context
+ * @param Filter $filter
+ * @param CollectionFactory $collectionFactory
+ * @param OrderManagementInterface $orderManagement
+ */
+ public function __construct(
+ Context $context,
+ Filter $filter,
+ CollectionFactory $collectionFactory,
+ OrderManagementInterface $orderManagement
+ ) {
+ parent::__construct($context, $filter);
+ $this->collectionFactory = $collectionFactory;
+ $this->orderManagement = $orderManagement;
+ }
+
/**
* Hold selected orders
*
@@ -18,12 +47,11 @@ class MassHold extends \Magento\Sales\Controller\Adminhtml\Order\AbstractMassAct
protected function massAction(AbstractCollection $collection)
{
$countHoldOrder = 0;
- $orderManagement = $this->_objectManager->get('Magento\Sales\Api\OrderManagementInterface');
foreach ($collection->getItems() as $order) {
if (!$order->canHold()) {
continue;
}
- $orderManagement->hold($order->getEntityId());
+ $this->orderManagement->hold($order->getEntityId());
$countHoldOrder++;
}
$countNonHoldOrder = $collection->count() - $countHoldOrder;
@@ -39,7 +67,7 @@ protected function massAction(AbstractCollection $collection)
}
$resultRedirect = $this->resultRedirectFactory->create();
- $resultRedirect->setPath('sales/*/');
+ $resultRedirect->setPath($this->getComponentRefererUrl());
return $resultRedirect;
}
}
diff --git a/app/code/Magento/Sales/Controller/Adminhtml/Order/MassUnhold.php b/app/code/Magento/Sales/Controller/Adminhtml/Order/MassUnhold.php
index 307f8dae53735..cdbdf98f37eb0 100644
--- a/app/code/Magento/Sales/Controller/Adminhtml/Order/MassUnhold.php
+++ b/app/code/Magento/Sales/Controller/Adminhtml/Order/MassUnhold.php
@@ -6,13 +6,22 @@
namespace Magento\Sales\Controller\Adminhtml\Order;
use Magento\Framework\Model\Resource\Db\Collection\AbstractCollection;
+use Magento\Backend\App\Action\Context;
+use Magento\Ui\Component\MassAction\Filter;
+use Magento\Sales\Model\Resource\Order\CollectionFactory;
-class MassUnhold extends \Magento\Sales\Controller\Adminhtml\Order\AbstractMassAction
+class MassUnhold extends AbstractMassAction
{
/**
- * @var string
+ * @param Context $context
+ * @param Filter $filter
+ * @param CollectionFactory $collectionFactory
*/
- protected $collection = 'Magento\Sales\Model\Resource\Order\Collection';
+ public function __construct(Context $context, Filter $filter, CollectionFactory $collectionFactory)
+ {
+ parent::__construct($context, $filter);
+ $this->collectionFactory = $collectionFactory;
+ }
/**
* Unhold selected orders
@@ -24,12 +33,14 @@ protected function massAction(AbstractCollection $collection)
{
$countUnHoldOrder = 0;
- $orderManagement = $this->_objectManager->get('Magento\Sales\Api\OrderManagementInterface');
+ /** @var \Magento\Sales\Model\Order $order */
foreach ($collection->getItems() as $order) {
+ $order->load($order->getId());
if (!$order->canUnhold()) {
continue;
}
- $orderManagement->unHold($order->getEntityId());
+ $order->unhold();
+ $order->save();
$countUnHoldOrder++;
}
@@ -49,7 +60,7 @@ protected function massAction(AbstractCollection $collection)
);
}
$resultRedirect = $this->resultRedirectFactory->create();
- $resultRedirect->setPath('sales/*/');
+ $resultRedirect->setPath($this->getComponentRefererUrl());
return $resultRedirect;
}
}
diff --git a/app/code/Magento/Sales/Controller/Adminhtml/Order/Pdfcreditmemos.php b/app/code/Magento/Sales/Controller/Adminhtml/Order/Pdfcreditmemos.php
index 24d9f9d69a654..81da53f4b9f8e 100644
--- a/app/code/Magento/Sales/Controller/Adminhtml/Order/Pdfcreditmemos.php
+++ b/app/code/Magento/Sales/Controller/Adminhtml/Order/Pdfcreditmemos.php
@@ -8,47 +8,83 @@
use Magento\Framework\App\ResponseInterface;
use Magento\Framework\App\Filesystem\DirectoryList;
use Magento\Framework\Model\Resource\Db\Collection\AbstractCollection;
+use Magento\Ui\Component\MassAction\Filter;
+use Magento\Sales\Model\Order\Pdf\Creditmemo;
+use Magento\Framework\Stdlib\DateTime\DateTime;
+use Magento\Framework\App\Response\Http\FileFactory;
+use Magento\Backend\App\Action\Context;
+use Magento\Framework\Controller\ResultInterface;
+use Magento\Sales\Model\Resource\Order\Creditmemo\CollectionFactory;
+use Magento\Sales\Model\Resource\Order\Collection as OrderCollection;
+/**
+ * Class Pdfcreditmemos
+ * @SuppressWarnings(PHPMD.CouplingBetweenObjects)
+ */
class Pdfcreditmemos extends \Magento\Sales\Controller\Adminhtml\Order\AbstractMassAction
{
+ /**
+ * @var FileFactory
+ */
+ protected $fileFactory;
+
+ /**
+ * @var DateTime
+ */
+ protected $dateTime;
+
+ /**
+ * @var Creditmemo
+ */
+ protected $pdfCreditmemo;
+
+ /**
+ * @var CollectionFactory
+ */
+ protected $collectionFactory;
+
+ /**
+ * @param Context $context
+ * @param Filter $filter
+ * @param CollectionFactory $collectionFactory
+ * @param DateTime $dateTime
+ * @param FileFactory $fileFactory
+ * @param Creditmemo $pdfCreditmemo
+ */
+ public function __construct(
+ Context $context,
+ Filter $filter,
+ CollectionFactory $collectionFactory,
+ DateTime $dateTime,
+ FileFactory $fileFactory,
+ Creditmemo $pdfCreditmemo
+ ) {
+ $this->fileFactory = $fileFactory;
+ $this->dateTime = $dateTime;
+ $this->pdfCreditmemo = $pdfCreditmemo;
+ $this->collectionFactory = $collectionFactory;
+ parent::__construct($context, $filter);
+ }
+
/**
* Print credit memos for selected orders
*
* @param AbstractCollection $collection
- * @return ResponseInterface|\Magento\Backend\Model\View\Result\Redirect
+ * @return ResponseInterface|ResultInterface
*/
protected function massAction(AbstractCollection $collection)
{
- $resultRedirect = $this->resultRedirectFactory->create();
- $flag = false;
- /** @var \Magento\Sales\Model\Order $order */
- foreach ($collection->getItems() as $order) {
- $creditmemos = $order->getCreditmemosCollection();
- if ($creditmemos->getSize()) {
- $flag = true;
- if (!isset($pdf)) {
- $pdf = $this->_objectManager->create('Magento\Sales\Model\Order\Pdf\Creditmemo')
- ->getPdf($creditmemos);
- } else {
- $pages = $this->_objectManager->create('Magento\Sales\Model\Order\Pdf\Creditmemo')
- ->getPdf($creditmemos);
- $pdf->pages = array_merge($pdf->pages, $pages->pages);
- }
- }
- }
- if ($flag) {
- $date = $this->_objectManager->get('Magento\Framework\Stdlib\DateTime\DateTime')
- ->date('Y-m-d_H-i-s');
- return $this->_fileFactory->create(
- 'creditmemo' . $date . '.pdf',
- $pdf->render(),
- DirectoryList::VAR_DIR,
- 'application/pdf'
- );
- } else {
+
+ $creditmemoCollection = $this->collectionFactory->create()->setOrderFilter(['in' => $collection->getAllIds()]);
+ if (!$creditmemoCollection->getSize()) {
$this->messageManager->addError(__('There are no printable documents related to selected orders.'));
- $resultRedirect->setPath('sales/*/');
- return $resultRedirect;
+ return $this->resultRedirectFactory->create()->setPath($this->getComponentRefererUrl());
}
+ return $this->fileFactory->create(
+ sprintf('creditmemo%s.pdf', $this->dateTime->date('Y-m-d_H-i-s')),
+ $this->pdfCreditmemo->getPdf($creditmemoCollection->getItems())->render(),
+ DirectoryList::VAR_DIR,
+ 'application/pdf'
+ );
}
}
diff --git a/app/code/Magento/Sales/Controller/Adminhtml/Order/Pdfdocs.php b/app/code/Magento/Sales/Controller/Adminhtml/Order/Pdfdocs.php
index 352abdf5bc265..53dc90c91e2ed 100644
--- a/app/code/Magento/Sales/Controller/Adminhtml/Order/Pdfdocs.php
+++ b/app/code/Magento/Sales/Controller/Adminhtml/Order/Pdfdocs.php
@@ -8,7 +8,22 @@
use Magento\Framework\App\ResponseInterface;
use Magento\Framework\App\Filesystem\DirectoryList;
use Magento\Framework\Model\Resource\Db\Collection\AbstractCollection;
+use Magento\Sales\Model\Order\Pdf\Invoice;
+use Magento\Backend\App\Action\Context;
+use Magento\Framework\App\Response\Http\FileFactory;
+use Magento\Ui\Component\MassAction\Filter;
+use Magento\Sales\Model\Order\Pdf\Shipment;
+use Magento\Sales\Model\Order\Pdf\Creditmemo;
+use Magento\Framework\Stdlib\DateTime\DateTime;
+use Magento\Sales\Model\Resource\Order\CollectionFactory as OrderCollectionFactory;
+use Magento\Sales\Model\Resource\Order\Shipment\CollectionFactory as ShipmentCollectionFactory;
+use Magento\Sales\Model\Resource\Order\Invoice\CollectionFactory as InvoiceCollectionFactory;
+use Magento\Sales\Model\Resource\Order\Creditmemo\CollectionFactory as CreditmemoCollectionFactory;
+/**
+ * Class Pdfdocs
+ * @SuppressWarnings(PHPMD.CouplingBetweenObjects)
+ */
class Pdfdocs extends \Magento\Sales\Controller\Adminhtml\Order\AbstractMassAction
{
/**
@@ -17,15 +32,77 @@ class Pdfdocs extends \Magento\Sales\Controller\Adminhtml\Order\AbstractMassActi
protected $fileFactory;
/**
- * @param \Magento\Backend\App\Action\Context $context
- * @param \Magento\Framework\App\Response\Http\FileFactory $fileFactory
+ * @var Invoice
+ */
+ protected $pdfInvoice;
+
+ /**
+ * @var Shipment
+ */
+ protected $pdfShipment;
+
+ /**
+ * @var Creditmemo
+ */
+ protected $pdfCreditmemo;
+
+ /**
+ * @var DateTime
+ */
+ protected $dateTime;
+
+ /**
+ * @var ShipmentCollectionFactory
+ */
+ protected $shipmentCollectionFactory;
+
+ /**
+ * @var InvoiceCollectionFactory
+ */
+ protected $invoiceCollectionFactory;
+
+ /**
+ * @var CreditmemoCollectionFactory
+ */
+ protected $creditmemoCollectionFactory;
+
+ /**
+ * @param Context $context
+ * @param Filter $filter
+ * @param FileFactory $fileFactory
+ * @param Invoice $pdfInvoice
+ * @param Shipment $pdfShipment
+ * @param Creditmemo $pdfCreditmemo
+ * @param DateTime $dateTime
+ * @param ShipmentCollectionFactory $shipmentCollectionFactory
+ * @param InvoiceCollectionFactory $invoiceCollectionFactory
+ * @param CreditmemoCollectionFactory $creditmemoCollectionFactory
+ * @param OrderCollectionFactory $orderCollectionFactory
+ * @SuppressWarnings(PHPMD.ExcessiveParameterList)
*/
public function __construct(
- \Magento\Backend\App\Action\Context $context,
- \Magento\Framework\App\Response\Http\FileFactory $fileFactory
+ Context $context,
+ Filter $filter,
+ FileFactory $fileFactory,
+ Invoice $pdfInvoice,
+ Shipment $pdfShipment,
+ Creditmemo $pdfCreditmemo,
+ DateTime $dateTime,
+ ShipmentCollectionFactory $shipmentCollectionFactory,
+ InvoiceCollectionFactory $invoiceCollectionFactory,
+ CreditmemoCollectionFactory $creditmemoCollectionFactory,
+ OrderCollectionFactory $orderCollectionFactory
) {
+ $this->pdfInvoice = $pdfInvoice;
+ $this->pdfShipment = $pdfShipment;
+ $this->pdfCreditmemo = $pdfCreditmemo;
$this->fileFactory = $fileFactory;
- parent::__construct($context);
+ $this->dateTime = $dateTime;
+ $this->shipmentCollectionFactory = $shipmentCollectionFactory;
+ $this->invoiceCollectionFactory = $invoiceCollectionFactory;
+ $this->creditmemoCollectionFactory = $creditmemoCollectionFactory;
+ $this->collectionFactory = $orderCollectionFactory;
+ parent::__construct($context, $filter);
}
/**
@@ -38,62 +115,38 @@ public function __construct(
*/
protected function massAction(AbstractCollection $collection)
{
- $resultRedirect = $this->resultRedirectFactory->create();
- $flag = false;
- /** @var \Magento\Sales\Model\Order $order */
- foreach ($collection->getItems() as $order) {
- $invoices = $order->getInvoiceCollection();
- if ($invoices->getSize()) {
- $flag = true;
- if (!isset($pdf)) {
- $pdf = $this->_objectManager->create('Magento\Sales\Model\Order\Pdf\Invoice')
- ->getPdf($invoices);
- } else {
- $pages = $this->_objectManager->create('Magento\Sales\Model\Order\Pdf\Invoice')
- ->getPdf($invoices);
- $pdf->pages = array_merge($pdf->pages, $pages->pages);
- }
- }
-
- $shipments = $order->getShipmentsCollection();
- if ($shipments->getSize()) {
- $flag = true;
- if (!isset($pdf)) {
- $pdf = $this->_objectManager->create('Magento\Sales\Model\Order\Pdf\Shipment')
- ->getPdf($shipments);
- } else {
- $pages = $this->_objectManager->create('Magento\Sales\Model\Order\Pdf\Shipment')
- ->getPdf($shipments);
- $pdf->pages = array_merge($pdf->pages, $pages->pages);
- }
- }
-
- $creditmemos = $order->getCreditmemosCollection();
- if ($creditmemos->getSize()) {
- $flag = true;
- if (!isset($pdf)) {
- $pdf = $this->_objectManager->create('Magento\Sales\Model\Order\Pdf\Creditmemo')
- ->getPdf($creditmemos);
- } else {
- $pages = $this->_objectManager->create('Magento\Sales\Model\Order\Pdf\Creditmemo')
- ->getPdf($creditmemos);
- $pdf->pages = array_merge($pdf->pages, $pages->pages);
- }
- }
+ $orderIds = $collection->getAllIds();
+
+ $shipments = $this->shipmentCollectionFactory->create()->setOrderFilter(['in' => $orderIds]);
+ $invoices = $this->invoiceCollectionFactory->create()->setOrderFilter(['in' => $orderIds]);
+ $creditmemos = $this->creditmemoCollectionFactory->create()->setOrderFilter(['in' => $orderIds]);
+
+ $documents = [];
+ if ($invoices->getSize()) {
+ $documents[] = $this->pdfInvoice->getPdf($invoices);
+ }
+ if ($shipments->getSize()) {
+ $documents[] = $this->pdfShipment->getPdf($shipments);
}
- if ($flag) {
- $date = $this->_objectManager->get('Magento\Framework\Stdlib\DateTime\DateTime')
- ->date('Y-m-d_H-i-s');
- return $this->fileFactory->create(
- 'docs' . $date . '.pdf',
- $pdf->render(),
- DirectoryList::VAR_DIR,
- 'application/pdf'
- );
- } else {
+ if ($creditmemos->getSize()) {
+ $documents[] = $this->pdfCreditmemo->getPdf($creditmemos);
+ }
+
+ if (empty($documents)) {
$this->messageManager->addError(__('There are no printable documents related to selected orders.'));
- $resultRedirect->setPath('sales/*/');
- return $resultRedirect;
+ return $this->resultRedirectFactory->create()->setPath($this->getComponentRefererUrl());
}
+
+ $pdf = array_shift($documents);
+ foreach ($documents as $document) {
+ $pdf->pages = array_merge($pdf->pages, $document->pages);
+ }
+
+ return $this->fileFactory->create(
+ sprintf('docs%s.pdf', $this->dateTime->date('Y-m-d_H-i-s')),
+ $pdf->render(),
+ DirectoryList::VAR_DIR,
+ 'application/pdf'
+ );
}
}
diff --git a/app/code/Magento/Sales/Controller/Adminhtml/Order/Pdfinvoices.php b/app/code/Magento/Sales/Controller/Adminhtml/Order/Pdfinvoices.php
index be03358130a1c..1eb43a64759a7 100644
--- a/app/code/Magento/Sales/Controller/Adminhtml/Order/Pdfinvoices.php
+++ b/app/code/Magento/Sales/Controller/Adminhtml/Order/Pdfinvoices.php
@@ -8,64 +8,78 @@
use Magento\Framework\App\ResponseInterface;
use Magento\Framework\App\Filesystem\DirectoryList;
use Magento\Framework\Model\Resource\Db\Collection\AbstractCollection;
+use Magento\Ui\Component\MassAction\Filter;
+use Magento\Sales\Model\Order\Pdf\Invoice;
+use Magento\Framework\Stdlib\DateTime\DateTime;
+use Magento\Framework\App\Response\Http\FileFactory;
+use Magento\Backend\App\Action\Context;
+use Magento\Framework\Controller\ResultInterface;
+use Magento\Sales\Model\Resource\Order\Invoice\CollectionFactory;
+use Magento\Sales\Model\Resource\Order\Collection as OrderCollection;
class Pdfinvoices extends \Magento\Sales\Controller\Adminhtml\Order\AbstractMassAction
{
/**
- * @var \Magento\Framework\App\Response\Http\FileFactory
+ * @var FileFactory
*/
protected $fileFactory;
/**
- * @param \Magento\Backend\App\Action\Context $context
- * @param \Magento\Framework\App\Response\Http\FileFactory $fileFactory
+ * @var DateTime
+ */
+ protected $dateTime;
+
+ /**
+ * @var Invoice
+ */
+ protected $pdfInvoice;
+
+ /**
+ * @var CollectionFactory
+ */
+ protected $collectionFactory;
+
+ /**
+ * @param Context $context
+ * @param Filter $filter
+ * @param CollectionFactory $collectionFactory
+ * @param DateTime $dateTime
+ * @param FileFactory $fileFactory
+ * @param Invoice $pdfInvoice
*/
public function __construct(
- \Magento\Backend\App\Action\Context $context,
- \Magento\Framework\App\Response\Http\FileFactory $fileFactory
+ Context $context,
+ Filter $filter,
+ CollectionFactory $collectionFactory,
+ DateTime $dateTime,
+ FileFactory $fileFactory,
+ Invoice $pdfInvoice
) {
$this->fileFactory = $fileFactory;
- parent::__construct($context);
+ $this->dateTime = $dateTime;
+ $this->pdfInvoice = $pdfInvoice;
+ $this->collectionFactory = $collectionFactory;
+ parent::__construct($context, $filter);
}
/**
* Print invoices for selected orders
*
* @param AbstractCollection $collection
- * @return ResponseInterface|\Magento\Backend\Model\View\Result\Redirect
+ * @return ResponseInterface|ResultInterface
*/
protected function massAction(AbstractCollection $collection)
{
- $resultRedirect = $this->resultRedirectFactory->create();
- $flag = false;
- /** @var \Magento\Sales\Model\Order $order */
- foreach ($collection->getItems() as $order) {
- $invoices = $order->getInvoiceCollection();
- if ($invoices->getSize() > 0) {
- $flag = true;
- if (!isset($pdf)) {
- $pdf = $this->_objectManager->create('Magento\Sales\Model\Order\Pdf\Invoice')
- ->getPdf($invoices);
- } else {
- $pages = $this->_objectManager->create('Magento\Sales\Model\Order\Pdf\Invoice')
- ->getPdf($invoices);
- $pdf->pages = array_merge($pdf->pages, $pages->pages);
- }
- }
- }
- if ($flag) {
- $date = $this->_objectManager->get('Magento\Framework\Stdlib\DateTime\DateTime')
- ->date('Y-m-d_H-i-s');
- return $this->fileFactory->create(
- 'invoice' . $date . '.pdf',
- $pdf->render(),
- DirectoryList::VAR_DIR,
- 'application/pdf'
- );
- } else {
+ $invoicesCollection = $this->collectionFactory->create()->setOrderFilter(['in' => $collection->getAllIds()]);
+ if (!$invoicesCollection->getSize()) {
$this->messageManager->addError(__('There are no printable documents related to selected orders.'));
- $resultRedirect->setPath('sales/*/');
- return $resultRedirect;
+ return $this->resultRedirectFactory->create()->setPath($this->getComponentRefererUrl());
}
+ return $this->fileFactory->create(
+ sprintf('packingslip%s.pdf', $this->dateTime->date('Y-m-d_H-i-s')),
+ $this->pdfInvoice->getPdf($invoicesCollection->getItems())->render(),
+ DirectoryList::VAR_DIR,
+ 'application/pdf'
+ );
}
}
diff --git a/app/code/Magento/Sales/Controller/Adminhtml/Order/Pdfshipments.php b/app/code/Magento/Sales/Controller/Adminhtml/Order/Pdfshipments.php
index ddcd0677c09ff..4c9b57a55558a 100644
--- a/app/code/Magento/Sales/Controller/Adminhtml/Order/Pdfshipments.php
+++ b/app/code/Magento/Sales/Controller/Adminhtml/Order/Pdfshipments.php
@@ -8,9 +8,66 @@
use Magento\Framework\App\ResponseInterface;
use Magento\Framework\App\Filesystem\DirectoryList;
use Magento\Framework\Model\Resource\Db\Collection\AbstractCollection;
+use Magento\Backend\App\Action\Context;
+use Magento\Framework\App\Response\Http\FileFactory;
+use Magento\Ui\Component\MassAction\Filter;
+use Magento\Sales\Model\Order\Pdf\Shipment;
+use Magento\Framework\Stdlib\DateTime\DateTime;
+use Magento\Sales\Model\Resource\Order\Shipment\CollectionFactory as ShipmentCollectionFactory;
+use Magento\Sales\Model\Resource\Order\CollectionFactory;
+/**
+ * Class Pdfshipments
+ * @SuppressWarnings(PHPMD.CouplingBetweenObjects)
+ */
class Pdfshipments extends \Magento\Sales\Controller\Adminhtml\Order\AbstractMassAction
{
+ /**
+ * @var FileFactory
+ */
+ protected $fileFactory;
+
+ /**
+ * @var DateTime
+ */
+ protected $dateTime;
+
+ /**
+ * @var Shipment
+ */
+ protected $pdfShipment;
+
+ /**
+ * @var ShipmentCollectionFactory
+ */
+ protected $shipmentCollectionFactotory;
+
+ /**
+ * @param Context $context
+ * @param Filter $filter
+ * @param CollectionFactory $collectionFactory
+ * @param DateTime $dateTime
+ * @param FileFactory $fileFactory
+ * @param Shipment $shipment
+ * @param ShipmentCollectionFactory $shipmentCollectionFactory
+ */
+ public function __construct(
+ Context $context,
+ Filter $filter,
+ CollectionFactory $collectionFactory,
+ DateTime $dateTime,
+ FileFactory $fileFactory,
+ Shipment $shipment,
+ ShipmentCollectionFactory $shipmentCollectionFactory
+ ) {
+ $this->fileFactory = $fileFactory;
+ $this->dateTime = $dateTime;
+ $this->pdfShipment = $shipment;
+ $this->collectionFactory = $collectionFactory;
+ $this->shipmentCollectionFactotory = $shipmentCollectionFactory;
+ parent::__construct($context, $filter);
+ }
+
/**
* Print shipments for selected orders
*
@@ -19,36 +76,18 @@ class Pdfshipments extends \Magento\Sales\Controller\Adminhtml\Order\AbstractMas
*/
protected function massAction(AbstractCollection $collection)
{
- $resultRedirect = $this->resultRedirectFactory->create();
- $flag = false;
- /** @var \Magento\Sales\Model\Order $order */
- foreach ($collection->getItems() as $order) {
- $shipments = $order->getShipmentsCollection();
- if ($shipments->getSize()) {
- $flag = true;
- if (!isset($pdf)) {
- $pdf = $this->_objectManager->create('Magento\Sales\Model\Order\Pdf\Shipment')
- ->getPdf($shipments);
- } else {
- $pages = $this->_objectManager->create('Magento\Sales\Model\Order\Pdf\Shipment')
- ->getPdf($shipments);
- $pdf->pages = array_merge($pdf->pages, $pages->pages);
- }
- }
- }
- if ($flag) {
- $date = $this->_objectManager->get('Magento\Framework\Stdlib\DateTime\DateTime')
- ->date('Y-m-d_H-i-s');
- return $this->_fileFactory->create(
- 'packingslip' . $date . '.pdf',
- $pdf->render(),
- DirectoryList::VAR_DIR,
- 'application/pdf'
- );
- } else {
+ $shipmentsCollection = $this->shipmentCollectionFactotory
+ ->create()
+ ->setOrderFilter(['in' => $collection->getAllIds()]);
+ if (!$shipmentsCollection->getSize()) {
$this->messageManager->addError(__('There are no printable documents related to selected orders.'));
- $resultRedirect->setPath('sales/*/');
- return $resultRedirect;
+ return $this->resultRedirectFactory->create()->setPath($this->getComponentRefererUrl());
}
+ return $this->fileFactory->create(
+ sprintf('packingslip%s.pdf', $this->dateTime->date('Y-m-d_H-i-s')),
+ $this->pdfShipment->getPdf($shipmentsCollection->getItems())->render(),
+ DirectoryList::VAR_DIR,
+ 'application/pdf'
+ );
}
}
diff --git a/app/code/Magento/Sales/Controller/Adminhtml/Order/ReviewPayment.php b/app/code/Magento/Sales/Controller/Adminhtml/Order/ReviewPayment.php
index 1b5c239c17835..8a0d64c9bcb6e 100644
--- a/app/code/Magento/Sales/Controller/Adminhtml/Order/ReviewPayment.php
+++ b/app/code/Magento/Sales/Controller/Adminhtml/Order/ReviewPayment.php
@@ -45,7 +45,7 @@ public function execute()
default:
throw new \Exception(sprintf('Action "%s" is not supported.', $action));
}
- $order->save();
+ $this->orderRepository->save($order);
$this->messageManager->addSuccess($message);
} else {
$resultRedirect->setPath('sales/*/');
@@ -55,9 +55,9 @@ public function execute()
$this->messageManager->addError($e->getMessage());
} catch (\Exception $e) {
$this->messageManager->addError(__('We can\'t update the payment right now.'));
- $this->_objectManager->get('Psr\Log\LoggerInterface')->critical($e);
+ $this->logger->critical($e);
}
- $resultRedirect->setPath('sales/order/view', ['order_id' => $order->getId()]);
+ $resultRedirect->setPath('sales/order/view', ['order_id' => $order->getEntityId()]);
return $resultRedirect;
}
diff --git a/app/code/Magento/Sales/Controller/Adminhtml/Order/Unhold.php b/app/code/Magento/Sales/Controller/Adminhtml/Order/Unhold.php
index 186e70709e3ba..7ea8dfbb7a48d 100644
--- a/app/code/Magento/Sales/Controller/Adminhtml/Order/Unhold.php
+++ b/app/code/Magento/Sales/Controller/Adminhtml/Order/Unhold.php
@@ -18,11 +18,10 @@ public function execute()
$resultRedirect = $this->resultRedirectFactory->create();
if ($order) {
try {
- $orderManagement = $this->_objectManager->get('Magento\Sales\Api\OrderManagementInterface');
if (!$order->canUnhold()) {
throw new \Magento\Framework\Exception\LocalizedException(__('Can\'t unhold order.'));
}
- $orderManagement->unhold($order->getEntityId());
+ $this->orderManagement->unhold($order->getEntityId());
$this->messageManager->addSuccess(__('You released the order from holding status.'));
} catch (\Magento\Framework\Exception\LocalizedException $e) {
$this->messageManager->addError($e->getMessage());
diff --git a/app/code/Magento/Sales/Controller/Adminhtml/Order/View.php b/app/code/Magento/Sales/Controller/Adminhtml/Order/View.php
index e4881766b1b04..831538fa21d11 100644
--- a/app/code/Magento/Sales/Controller/Adminhtml/Order/View.php
+++ b/app/code/Magento/Sales/Controller/Adminhtml/Order/View.php
@@ -23,12 +23,12 @@ public function execute()
$resultPage = $this->_initAction();
$resultPage->getConfig()->getTitle()->prepend(__('Orders'));
} catch (\Exception $e) {
- $this->_objectManager->get('Psr\Log\LoggerInterface')->critical($e);
+ $this->logger->critical($e);
$this->messageManager->addError(__('Exception occurred during order load'));
$resultRedirect->setPath('sales/order/index');
return $resultRedirect;
}
- $resultPage->getConfig()->getTitle()->prepend(sprintf("#%s", $order->getRealOrderId()));
+ $resultPage->getConfig()->getTitle()->prepend(sprintf("#%s", $order->getIncrementId()));
return $resultPage;
}
$resultRedirect->setPath('sales/*/');
diff --git a/app/code/Magento/Sales/Controller/Adminhtml/Shipment/AbstractShipment/Pdfshipments.php b/app/code/Magento/Sales/Controller/Adminhtml/Shipment/AbstractShipment/Pdfshipments.php
index 8c0b9baa42114..7a0ee9b827cc0 100644
--- a/app/code/Magento/Sales/Controller/Adminhtml/Shipment/AbstractShipment/Pdfshipments.php
+++ b/app/code/Magento/Sales/Controller/Adminhtml/Shipment/AbstractShipment/Pdfshipments.php
@@ -11,28 +11,49 @@
use Magento\Framework\App\Filesystem\DirectoryList;
use Magento\Framework\App\Response\Http\FileFactory;
use Magento\Framework\Model\Resource\Db\Collection\AbstractCollection;
+use Magento\Ui\Component\MassAction\Filter;
+use Magento\Sales\Model\Order\Pdf\Shipment;
+use Magento\Framework\Stdlib\DateTime\DateTime;
+use Magento\Sales\Model\Resource\Order\Shipment\CollectionFactory;
abstract class Pdfshipments extends \Magento\Sales\Controller\Adminhtml\Order\AbstractMassAction
{
/**
* @var FileFactory
*/
- protected $_fileFactory;
+ protected $fileFactory;
+
/**
- * Resource collection
- *
- * @var string
+ * @var DateTime
*/
- protected $collection = 'Magento\Sales\Model\Resource\Order\Shipment\Grid\Collection';
+ protected $dateTime;
+
+ /**
+ * @var Shipment
+ */
+ protected $pdfShipment;
/**
* @param Context $context
+ * @param Filter $filter
+ * @param DateTime $dateTime
* @param FileFactory $fileFactory
+ * @param Shipment $shipment
+ * @param CollectionFactory $collectionFactory
*/
- public function __construct(Context $context, FileFactory $fileFactory)
- {
- $this->_fileFactory = $fileFactory;
- parent::__construct($context);
+ public function __construct(
+ Context $context,
+ Filter $filter,
+ DateTime $dateTime,
+ FileFactory $fileFactory,
+ Shipment $shipment,
+ CollectionFactory $collectionFactory
+ ) {
+ $this->fileFactory = $fileFactory;
+ $this->dateTime = $dateTime;
+ $this->pdfShipment = $shipment;
+ $this->collectionFactory = $collectionFactory;
+ parent::__construct($context, $filter);
}
/**
@@ -50,16 +71,9 @@ protected function _isAllowed()
*/
public function massAction(AbstractCollection $collection)
{
- if (!isset($pdf)) {
- $pdf = $this->_objectManager->create('Magento\Sales\Model\Order\Pdf\Shipment')->getPdf($collection);
- } else {
- $pages = $this->_objectManager->create('Magento\Sales\Model\Order\Pdf\Shipment')->getPdf($collection);
- $pdf->pages = array_merge($pdf->pages, $pages->pages);
- }
- $date = $this->_objectManager->get('Magento\Framework\Stdlib\DateTime\DateTime')->date('Y-m-d_H-i-s');
- return $this->_fileFactory->create(
- 'packingslip' . $date . '.pdf',
- $pdf->render(),
+ return $this->fileFactory->create(
+ sprintf('packingslip%s.pdf', $this->dateTime->date('Y-m-d_H-i-s')),
+ $this->pdfShipment->getPdf($collection)->render(),
DirectoryList::VAR_DIR,
'application/pdf'
);
diff --git a/app/code/Magento/Sales/Controller/Adminhtml/Shipment/ExportCsv.php b/app/code/Magento/Sales/Controller/Adminhtml/Shipment/ExportCsv.php
deleted file mode 100644
index 301d7fceacf20..0000000000000
--- a/app/code/Magento/Sales/Controller/Adminhtml/Shipment/ExportCsv.php
+++ /dev/null
@@ -1,67 +0,0 @@
-_fileFactory = $fileFactory;
- $this->resultLayoutFactory = $resultLayoutFactory;
- }
-
- /**
- * @return bool
- */
- protected function _isAllowed()
- {
- return $this->_authorization->isAllowed('Magento_Sales::shipment');
- }
-
- /**
- * Export shipment grid to CSV format
- *
- * @return ResponseInterface
- */
- public function execute()
- {
- $fileName = 'shipments.csv';
- /** @var \Magento\Framework\View\Result\Layout $resultLayout */
- $resultLayout = $this->resultLayoutFactory->create();
- $grid = $resultLayout->getLayout()->getChildBlock('sales.shipment.grid', 'grid.export');
- return $this->_fileFactory->create(
- $fileName,
- $grid->getCsvFile(),
- DirectoryList::VAR_DIR
- );
- }
-}
diff --git a/app/code/Magento/Sales/Controller/Adminhtml/Shipment/ExportExcel.php b/app/code/Magento/Sales/Controller/Adminhtml/Shipment/ExportExcel.php
deleted file mode 100644
index 45f47691e9856..0000000000000
--- a/app/code/Magento/Sales/Controller/Adminhtml/Shipment/ExportExcel.php
+++ /dev/null
@@ -1,67 +0,0 @@
-_fileFactory = $fileFactory;
- $this->resultLayoutFactory = $resultLayoutFactory;
- parent::__construct($context);
- }
-
- /**
- * @return bool
- */
- protected function _isAllowed()
- {
- return $this->_authorization->isAllowed('Magento_Sales::shipment');
- }
-
- /**
- * Export shipment grid to Excel XML format
- *
- * @return ResponseInterface
- */
- public function execute()
- {
- $fileName = 'shipments.xml';
- /** @var \Magento\Framework\View\Result\Layout $resultLayout */
- $resultLayout = $this->resultLayoutFactory->create();
- $grid = $resultLayout->getLayout()->getChildBlock('sales.shipment.grid', 'grid.export');
- return $this->_fileFactory->create(
- $fileName,
- $grid->getExcelFile($fileName),
- DirectoryList::VAR_DIR
- );
- }
-}
diff --git a/app/code/Magento/Sales/Helper/Reorder.php b/app/code/Magento/Sales/Helper/Reorder.php
index 56ee37c0e0891..6c735c919ad00 100644
--- a/app/code/Magento/Sales/Helper/Reorder.php
+++ b/app/code/Magento/Sales/Helper/Reorder.php
@@ -18,17 +18,25 @@ class Reorder extends \Magento\Framework\App\Helper\AbstractHelper
/**
* @var \Magento\Customer\Model\Session
*/
- protected $_customerSession;
+ protected $customerSession;
+
+ /**
+ * @var \Magento\Sales\Api\OrderRepositoryInterface
+ */
+ protected $orderRepository;
/**
* @param \Magento\Framework\App\Helper\Context $context
* @param \Magento\Customer\Model\Session $customerSession
+ * @param \Magento\Sales\Api\OrderRepositoryInterface $orderRepository
*/
public function __construct(
\Magento\Framework\App\Helper\Context $context,
- \Magento\Customer\Model\Session $customerSession
+ \Magento\Customer\Model\Session $customerSession,
+ \Magento\Sales\Api\OrderRepositoryInterface $orderRepository
) {
- $this->_customerSession = $customerSession;
+ $this->orderRepository = $orderRepository;
+ $this->customerSession = $customerSession;
parent::__construct(
$context
);
@@ -57,15 +65,18 @@ public function isAllowed($store = null)
}
/**
- * @param \Magento\Sales\Model\Order $order
+ * Check is it possible to reorder
+ *
+ * @param int $orderId
* @return bool
*/
- public function canReorder(\Magento\Sales\Model\Order $order)
+ public function canReorder($orderId)
{
+ $order = $this->orderRepository->get($orderId);
if (!$this->isAllowed($order->getStore())) {
return false;
}
- if ($this->_customerSession->isLoggedIn()) {
+ if ($this->customerSession->isLoggedIn()) {
return $order->canReorder();
} else {
return true;
diff --git a/app/code/Magento/Sales/Model/Order.php b/app/code/Magento/Sales/Model/Order.php
index 87dffadfa8dfd..e7982a26035c1 100755
--- a/app/code/Magento/Sales/Model/Order.php
+++ b/app/code/Magento/Sales/Model/Order.php
@@ -1397,13 +1397,13 @@ public function addPayment(Payment $payment)
}
/**
- * @param Payment $payment
+ * @param \Magento\Sales\Api\Data\OrderPaymentInterface $payment
* @return Payment
*/
- public function setPayment(Payment $payment)
+ public function setPayment(\Magento\Sales\Api\Data\OrderPaymentInterface $payment)
{
- if (!$this->getIsMultiPayment() && ($old = $this->getPayment())) {
- $payment->setId($old->getId());
+ if (!$this->getIsMultiPayment() && ($previousPayment = $this->getPayment())) {
+ $payment->setEntityId($previousPayment->getEntityId());
}
$this->addPayment($payment);
return $payment;
diff --git a/app/code/Magento/Sales/Model/Order/Builder.php b/app/code/Magento/Sales/Model/Order/Builder.php
deleted file mode 100644
index f0c2e25e4cdb4..0000000000000
--- a/app/code/Magento/Sales/Model/Order/Builder.php
+++ /dev/null
@@ -1,387 +0,0 @@
-orderFactory = $orderFactory;
- }
-
- /**
- * @param Customer $customer
- * @return $this
- */
- public function setCustomer(Customer $customer)
- {
- $this->customer = $customer;
- return $this;
- }
-
- /**
- * @param Address $address
- * @return $this
- */
- public function setShippingAddress(Address $address)
- {
- $this->shippingAddress = $address;
- return $this;
- }
-
- /**
- * @param Address $address
- * @return $this
- */
- public function setBillingAddress(Address $address)
- {
- $this->billingAddress = $address;
- return $this;
- }
-
- /**
- * @param int $quoteId
- * @return $this
- */
- public function setQuoteId($quoteId)
- {
- $this->quoteId = $quoteId;
- return $this;
- }
-
- /**
- * @param array $appliedRuleIds
- * @return $this
- */
- public function setAppliedRuleIds($appliedRuleIds)
- {
- $this->appliedRuleIds = $appliedRuleIds;
- return $this;
- }
-
- /**
- * @param int $isVirtual
- * @return $this
- */
- public function setIsVirtual($isVirtual)
- {
- $this->isVirtual = $isVirtual;
- return $this;
- }
-
- /**
- * @param string $remoteIp
- * @return $this
- */
- public function setRemoteIp($remoteIp)
- {
- $this->remoteIp = $remoteIp;
- return $this;
- }
-
- /**
- * @param string $baseSubtotal
- * @return $this
- */
- public function setBaseSubtotal($baseSubtotal)
- {
- $this->baseSubtotal = $baseSubtotal;
- return $this;
- }
-
- /**
- * @param string $subtotal
- * @return $this
- */
- public function setSubtotal($subtotal)
- {
- $this->subtotal = $subtotal;
- return $this;
- }
-
- /**
- * @param string $baseGrandTotal
- * @return $this
- */
- public function setBaseGrandTotal($baseGrandTotal)
- {
- $this->baseGrandTotal = $baseGrandTotal;
- return $this;
- }
-
- /**
- * @param string $grandTotal
- * @return $this
- */
- public function setGrandTotal($grandTotal)
- {
- $this->grandTotal = $grandTotal;
- return $this;
- }
-
- /**
- * @param string $baseCurrencyCode
- * @return $this
- */
- public function setBaseCurrencyCode($baseCurrencyCode)
- {
- $this->baseCurrencyCode = $baseCurrencyCode;
- return $this;
- }
-
- /**
- * @param string $globalCurrencyCode
- * @return $this
- */
- public function setGlobalCurrencyCode($globalCurrencyCode)
- {
- $this->globalCurrencyCode = $globalCurrencyCode;
- return $this;
- }
-
- /**
- * @param string $storeCurrencyCode
- * @return $this
- */
- public function setStoreCurrencyCode($storeCurrencyCode)
- {
- $this->storeCurrencyCode = $storeCurrencyCode;
- return $this;
- }
-
- /**
- * @param int $storeId
- * @return $this
- */
- public function setStoreId($storeId)
- {
- $this->storeId = $storeId;
- return $this;
- }
-
- /**
- * @param string $storeToBaseRate
- * @return $this
- */
- public function setStoreToBaseRate($storeToBaseRate)
- {
- $this->storeToBaseRate = $storeToBaseRate;
- return $this;
- }
-
- /**
- * @param string $baseToGlobalRate
- * @return $this
- */
- public function setBaseToGlobalRate($baseToGlobalRate)
- {
- $this->baseToGlobalRate = $baseToGlobalRate;
- return $this;
- }
-
- /**
- * @param string $couponCode
- * @return $this
- */
- public function setCouponCode($couponCode)
- {
- $this->couponCode = $couponCode;
- return $this;
- }
-
- /**
- * @param Item[] $items
- * @return $this
- */
- public function setItems($items)
- {
- $this->items = $items;
- return $this;
- }
-
- /**
- * @param Payment[] $payments
- * @return $this
- */
- public function setPayments($payments)
- {
- $this->payments = $payments;
- return $this;
- }
-
- /**
- * @return \Magento\Sales\Model\Order
- * @throws \Exception
- */
- public function create()
- {
- /**@var $order \Magento\Sales\Model\Order */
- $order = $this->orderFactory->create([
- 'data' => [
- 'quote_id' => $this->quoteId,
- 'applied_rule_ids' => $this->appliedRuleIds,
- 'is_virtual' => $this->isVirtual,
- 'remote_ip' => $this->remoteIp,
- 'base_subtotal' => $this->baseSubtotal,
- 'subtotal' => $this->subtotal,
- 'base_grand_total' => $this->baseGrandTotal,
- 'grand_total' => $this->grandTotal,
- 'base_currency_code' => $this->baseCurrencyCode,
- 'global_currency_code' => $this->globalCurrencyCode,
- 'store_currency_code' => $this->storeCurrencyCode,
- 'store_id' => $this->storeId,
- 'store_to_base_rate' => $this->storeToBaseRate,
- 'base_to_global_rate' => $this->baseToGlobalRate,
- 'coupon_code' => $this->couponCode,
- 'customer_dob' => $this->customer->getDob(),
- 'customer_email' => $this->customer->getEmail(),
- 'customer_firstname' => $this->customer->getFirstName(),
- 'customer_gender' => $this->customer->getGender(),
- 'customer_group_id' => $this->customer->getGroupId(),
- 'customer_id' => $this->customer->getId(),
- 'customer_is_guest' => $this->customer->getIsGuest(),
- 'customer_lastname' => $this->customer->getLastName(),
- 'customer_middlename' => $this->customer->getMiddleName(),
- 'customer_note' => $this->customer->getNote(),
- 'customer_note_notify' => $this->customer->getNoteNotify(),
- 'customer_prefix' => $this->customer->getPrefix(),
- 'customer_suffix' => $this->customer->getSuffix(),
- 'customer_taxvat' => $this->customer->getTaxvat(),
- ],
- ]);
- $order->setBillingAddress($this->billingAddress)
- ->setShippingAddress($this->shippingAddress);
- foreach ($this->items as $item) {
- if ($item instanceof Item) {
- $order->addItem($item);
- } else {
- throw new \InvalidArgumentException('Cannot add item, instance of wrong type is given');
- }
- }
- foreach ($this->payments as $payment) {
- if ($payment instanceof Payment) {
- $order->addPayment($payment);
- } else {
- throw new \InvalidArgumentException('Cannot add payment, instance of wrong type is given');
- }
- }
- return $order;
- }
-}
diff --git a/app/code/Magento/Sales/Model/Order/Customer.php b/app/code/Magento/Sales/Model/Order/Customer.php
deleted file mode 100644
index 87fb453e710f7..0000000000000
--- a/app/code/Magento/Sales/Model/Order/Customer.php
+++ /dev/null
@@ -1,241 +0,0 @@
-customerDob = $customerDob;
- $this->customerEmail = $customerEmail;
- $this->customerFirstName = $customerFirstName;
- $this->customerGender = $customerGender;
- $this->customerGroupId = $customerGroupId;
- $this->customerId = $customerId;
- $this->customerIsGuest = $customerIsGuest;
- $this->customerLastName = $customerLastName;
- $this->customerMiddleName = $customerMiddleName;
- $this->customerNote = $customerNote;
- $this->customerNoteNotify = $customerNoteNotify;
- $this->customerPrefix = $customerPrefix;
- $this->customerSuffix = $customerSuffix;
- $this->customerTaxvat = $customerTaxvat;
- }
-
- /**
- * @return string
- */
- public function getDob()
- {
- return $this->customerDob;
- }
-
- /**
- * @return string
- */
- public function getEmail()
- {
- return $this->customerEmail;
- }
-
- /**
- * @return string
- */
- public function getFirstName()
- {
- return $this->customerFirstName;
- }
-
- /**
- * @return string
- */
- public function getGender()
- {
- return $this->customerGender;
- }
-
- /**
- * @return string
- */
- public function getGroupId()
- {
- return $this->customerGroupId;
- }
-
- /**
- * @return string
- */
- public function getId()
- {
- return $this->customerId;
- }
-
- /**
- * @return string
- */
- public function getIsGuest()
- {
- return $this->customerIsGuest;
- }
-
- /**
- * @return string
- */
- public function getLastName()
- {
- return $this->customerLastName;
- }
-
- /**
- * @return string
- */
- public function getMiddleName()
- {
- return $this->customerMiddleName;
- }
-
- /**
- * @return string
- */
- public function getNote()
- {
- return $this->customerNote;
- }
-
- /**
- * @return string
- */
- public function getNoteNotify()
- {
- return $this->customerNoteNotify;
- }
-
- /**
- * @return string
- */
- public function getPrefix()
- {
- return $this->customerPrefix;
- }
-
- /**
- * @return string
- */
- public function getSuffix()
- {
- return $this->customerSuffix;
- }
-
- /**
- * @return string
- */
- public function getTaxvat()
- {
- return $this->customerTaxvat;
- }
-}
diff --git a/app/code/Magento/Sales/Model/Order/Customer/Builder.php b/app/code/Magento/Sales/Model/Order/Customer/Builder.php
deleted file mode 100644
index 9106e71fad825..0000000000000
--- a/app/code/Magento/Sales/Model/Order/Customer/Builder.php
+++ /dev/null
@@ -1,260 +0,0 @@
-objectManager = $objectManager;
- }
-
- /**
- * @param string $customerDob
- * @return \Magento\Sales\Model\Order\Customer\Builder
- */
- public function setDob($customerDob)
- {
- $this->customerDob = $customerDob;
- return $this;
- }
-
- /**
- * @param string $customerEmail
- * @return \Magento\Sales\Model\Order\Customer\Builder
- */
- public function setEmail($customerEmail)
- {
- $this->customerEmail = $customerEmail;
- return $this;
- }
-
- /**
- * @param string $customerFirstName
- * @return \Magento\Sales\Model\Order\Customer\Builder
- */
- public function setFirstName($customerFirstName)
- {
- $this->customerFirstName = $customerFirstName;
- return $this;
- }
-
- /**
- * @param string $customerGender
- * @return \Magento\Sales\Model\Order\Customer\Builder
- */
- public function setGender($customerGender)
- {
- $this->customerGender = $customerGender;
- return $this;
- }
-
- /**
- * @param int $customerGroupId
- * @return \Magento\Sales\Model\Order\Customer\Builder
- */
- public function setGroupId($customerGroupId)
- {
- $this->customerGroupId = $customerGroupId;
- return $this;
- }
-
- /**
- * @param int $customerId
- * @return \Magento\Sales\Model\Order\Customer\Builder
- */
- public function setId($customerId)
- {
- $this->customerId = $customerId;
- return $this;
- }
-
- /**
- * @param int $customerIsGuest
- * @return \Magento\Sales\Model\Order\Customer\Builder
- */
- public function setIsGuest($customerIsGuest)
- {
- $this->customerIsGuest = $customerIsGuest;
- return $this;
- }
-
- /**
- * @param string $customerLastName
- * @return \Magento\Sales\Model\Order\Customer\Builder
- */
- public function setLastName($customerLastName)
- {
- $this->customerLastName = $customerLastName;
- return $this;
- }
-
- /**
- * @param string $customerMiddleName
- * @return \Magento\Sales\Model\Order\Customer\Builder
- */
- public function setMiddleName($customerMiddleName)
- {
- $this->customerMiddleName = $customerMiddleName;
- return $this;
- }
-
- /**
- * @param string $customerNote
- * @return \Magento\Sales\Model\Order\Customer\Builder
- */
- public function setNote($customerNote)
- {
- $this->customerNote = $customerNote;
- return $this;
- }
-
- /**
- * @param int $customerNoteNotify
- * @return \Magento\Sales\Model\Order\Customer\Builder
- */
- public function setNoteNotify($customerNoteNotify)
- {
- $this->customerNoteNotify = $customerNoteNotify;
- return $this;
- }
-
- /**
- * @param string $customerPrefix
- * @return \Magento\Sales\Model\Order\Customer\Builder
- */
- public function setPrefix($customerPrefix)
- {
- $this->customerPrefix = $customerPrefix;
- return $this;
- }
-
- /**
- * @param string $customerSuffix
- * @return \Magento\Sales\Model\Order\Customer\Builder
- */
- public function setSuffix($customerSuffix)
- {
- $this->customerSuffix = $customerSuffix;
- return $this;
- }
-
- /**
- * @param string $customerTaxvat
- * @return \Magento\Sales\Model\Order\Customer\Builder
- */
- public function setTaxvat($customerTaxvat)
- {
- $this->customerTaxvat = $customerTaxvat;
- return $this;
- }
-
- /**
- * @return \Magento\Sales\Model\Order\Customer
- */
- public function create()
- {
- return $this->objectManager->create('Magento\Sales\Model\Order\Customer', [
- 'customerDob' => $this->customerDob,
- 'customerEmail' => $this->customerEmail,
- 'customerFirstName' => $this->customerFirstName,
- 'customerGender' => $this->customerGender,
- 'customerGroupId' => $this->customerGroupId,
- 'customerId' => $this->customerId,
- 'customerIsGuest' => $this->customerIsGuest,
- 'customerLastName' => $this->customerLastName,
- 'customerMiddleName' => $this->customerMiddleName,
- 'customerNote' => $this->customerNote,
- 'customerNoteNotify' => $this->customerNoteNotify,
- 'customerPrefix' => $this->customerPrefix,
- 'customerSuffix' => $this->customerSuffix,
- 'customerTaxvat' => $this->customerTaxvat
- ]);
- }
-}
diff --git a/app/code/Magento/Sales/Model/Order/Customer/Management.php b/app/code/Magento/Sales/Model/Order/CustomerManagement.php
similarity index 96%
rename from app/code/Magento/Sales/Model/Order/Customer/Management.php
rename to app/code/Magento/Sales/Model/Order/CustomerManagement.php
index 8944df974d221..0a5b3ee6ccbf3 100644
--- a/app/code/Magento/Sales/Model/Order/Customer/Management.php
+++ b/app/code/Magento/Sales/Model/Order/CustomerManagement.php
@@ -3,11 +3,14 @@
* Copyright © 2015 Magento. All rights reserved.
* See COPYING.txt for license details.
*/
-namespace Magento\Sales\Model\Order\Customer;
+namespace Magento\Sales\Model\Order;
use Magento\Framework\Exception\AlreadyExistsException;
-class Management implements \Magento\Sales\Api\OrderCustomerManagementInterface
+/**
+ * Class CustomerManagement
+ */
+class CustomerManagement implements \Magento\Sales\Api\OrderCustomerManagementInterface
{
/**
* @var \Magento\Customer\Api\AccountManagementInterface
diff --git a/app/code/Magento/Sales/Model/Order/Pdf/Invoice.php b/app/code/Magento/Sales/Model/Order/Pdf/Invoice.php
index 954c6c1d3c263..5482bc01322a5 100644
--- a/app/code/Magento/Sales/Model/Order/Pdf/Invoice.php
+++ b/app/code/Magento/Sales/Model/Order/Pdf/Invoice.php
@@ -5,6 +5,8 @@
*/
namespace Magento\Sales\Model\Order\Pdf;
+use Magento\Sales\Model\Resource\Order\Invoice\Collection;
+
/**
* Sales Order Invoice PDF model
* @SuppressWarnings(PHPMD.CouplingBetweenObjects)
@@ -110,7 +112,7 @@ protected function _drawHeader(\Zend_Pdf_Page $page)
/**
* Return PDF document
*
- * @param array $invoices
+ * @param array|Collection $invoices
* @return \Zend_Pdf
*/
public function getPdf($invoices = [])
diff --git a/app/code/Magento/Sales/Model/Order/Pdf/Shipment.php b/app/code/Magento/Sales/Model/Order/Pdf/Shipment.php
index dc97fc8153830..168f7c327aecc 100644
--- a/app/code/Magento/Sales/Model/Order/Pdf/Shipment.php
+++ b/app/code/Magento/Sales/Model/Order/Pdf/Shipment.php
@@ -104,7 +104,7 @@ protected function _drawHeader(\Zend_Pdf_Page $page)
/**
* Return PDF document
*
- * @param array $shipments
+ * @param \Magento\Sales\Model\Order\Shipment[] $shipments
* @return \Zend_Pdf
*/
public function getPdf($shipments = [])
diff --git a/app/code/Magento/Sales/Model/OrderRepository.php b/app/code/Magento/Sales/Model/OrderRepository.php
index d04a2d7005f09..e7993f850fe53 100644
--- a/app/code/Magento/Sales/Model/OrderRepository.php
+++ b/app/code/Magento/Sales/Model/OrderRepository.php
@@ -56,14 +56,14 @@ public function __construct(
public function get($id)
{
if (!$id) {
- throw new InputException('Id required');
+ throw new InputException(__('Id required'));
}
if (!isset($this->registry[$id])) {
/** @var \Magento\Sales\Api\Data\OrderInterface $entity */
$entity = $this->metadata->getNewInstance();
$this->metadata->getMapper()->load($entity, $id);
if (!$entity->getEntityId()) {
- throw new NoSuchEntityException('Requested entity doesn\'t exist');
+ throw new NoSuchEntityException(__('Requested entity doesn\'t exist'));
}
$this->registry[$id] = $entity;
}
diff --git a/app/code/Magento/Sales/Model/Resource/Grid.php b/app/code/Magento/Sales/Model/Resource/Grid.php
index f4dbb4d49b304..5c0ff84007435 100644
--- a/app/code/Magento/Sales/Model/Resource/Grid.php
+++ b/app/code/Magento/Sales/Model/Resource/Grid.php
@@ -144,7 +144,11 @@ protected function getGridOriginSelect()
}
$columns = [];
foreach ($this->columns as $key => $value) {
- $columns[$key] = new \Zend_Db_Expr((string) $value);
+ if ($value instanceof \Zend_Db_Expr) {
+ $columns[$key] = $value;
+ } else {
+ $columns[$key] = new \Zend_Db_Expr($value);
+ }
}
$select->columns($columns);
return $select;
diff --git a/app/code/Magento/Sales/Model/Resource/Grid/Collection.php b/app/code/Magento/Sales/Model/Resource/Grid/Collection.php
new file mode 100644
index 0000000000000..57d2d31060dcf
--- /dev/null
+++ b/app/code/Magento/Sales/Model/Resource/Grid/Collection.php
@@ -0,0 +1,151 @@
+_eventPrefix = $eventPrefix;
+ $this->_eventObject = $eventObject;
+ $this->_init($model, $resourceModel);
+ $this->setMainTable($mainTable);
+ parent::__construct(
+ $entityFactory,
+ $logger,
+ $fetchStrategy,
+ $eventManager,
+ $connection,
+ $resource
+ );
+ }
+
+ /**
+ * @return AggregationInterface
+ */
+ public function getAggregations()
+ {
+ return $this->aggregations;
+ }
+
+ /**
+ * @param AggregationInterface $aggregations
+ * @return $this
+ */
+ public function setAggregations($aggregations)
+ {
+ $this->aggregations = $aggregations;
+ }
+
+
+ /**
+ * Retrieve all ids for collection
+ * Backward compatibility with EAV collection
+ *
+ * @param int $limit
+ * @param int $offset
+ * @return array
+ */
+ public function getAllIds($limit = null, $offset = null)
+ {
+ return $this->getConnection()->fetchCol($this->_getAllIdsSelect($limit, $offset), $this->_bindParams);
+ }
+
+ /**
+ * Get search criteria.
+ *
+ * @return \Magento\Framework\Api\SearchCriteriaInterface|null
+ */
+ public function getSearchCriteria()
+ {
+ return null;
+ }
+
+ /**
+ * Set search criteria.
+ *
+ * @param \Magento\Framework\Api\SearchCriteriaInterface $searchCriteria
+ * @return $this
+ * @SuppressWarnings(PHPMD.UnusedFormalParameter)
+ */
+ public function setSearchCriteria(\Magento\Framework\Api\SearchCriteriaInterface $searchCriteria = null)
+ {
+ return $this;
+ }
+
+ /**
+ * Get total count.
+ *
+ * @return int
+ */
+ public function getTotalCount()
+ {
+ return $this->getSize();
+ }
+
+ /**
+ * Set total count.
+ *
+ * @param int $totalCount
+ * @return $this
+ * @SuppressWarnings(PHPMD.UnusedFormalParameter)
+ */
+ public function setTotalCount($totalCount)
+ {
+ return $this;
+ }
+
+ /**
+ * Set items list.
+ *
+ * @param \Magento\Framework\Api\ExtensibleDataInterface[] $items
+ * @return $this
+ * @SuppressWarnings(PHPMD.UnusedFormalParameter)
+ */
+ public function setItems(array $items = null)
+ {
+ return $this;
+ }
+}
diff --git a/app/code/Magento/Sales/Model/Resource/Order/Collection.php b/app/code/Magento/Sales/Model/Resource/Order/Collection.php
index f5a3f3b7b813e..be70c20b24992 100644
--- a/app/code/Magento/Sales/Model/Resource/Order/Collection.php
+++ b/app/code/Magento/Sales/Model/Resource/Order/Collection.php
@@ -15,6 +15,11 @@
*/
class Collection extends AbstractCollection implements OrderSearchResultInterface
{
+ /**
+ * @var string
+ */
+ protected $_idFieldName = 'entity_id';
+
/**
* Event prefix
*
diff --git a/app/code/Magento/Sales/Model/Resource/Order/Collection/AbstractCollection.php b/app/code/Magento/Sales/Model/Resource/Order/Collection/AbstractCollection.php
index 4e9d402839f71..392a6600dd839 100644
--- a/app/code/Magento/Sales/Model/Resource/Order/Collection/AbstractCollection.php
+++ b/app/code/Magento/Sales/Model/Resource/Order/Collection/AbstractCollection.php
@@ -58,7 +58,7 @@ public function getSalesOrder()
/**
* Add order filter
*
- * @param int|\Magento\Sales\Model\Order $order
+ * @param int|\Magento\Sales\Model\Order|array $order
* @return $this
*/
public function setOrderFilter($order)
diff --git a/app/code/Magento/Sales/Model/Resource/Order/Creditmemo/Collection.php b/app/code/Magento/Sales/Model/Resource/Order/Creditmemo/Collection.php
index 2059ca2046576..ca6a64f6ae482 100644
--- a/app/code/Magento/Sales/Model/Resource/Order/Creditmemo/Collection.php
+++ b/app/code/Magento/Sales/Model/Resource/Order/Creditmemo/Collection.php
@@ -15,6 +15,13 @@
*/
class Collection extends AbstractCollection implements CreditmemoSearchResultInterface
{
+ /**
+ * Id field name
+ *
+ * @var string
+ */
+ protected $_idFieldName = 'entity_id';
+
/**
* Event prefix
*
diff --git a/app/code/Magento/Sales/Model/Resource/Order/Creditmemo/Grid/Collection.php b/app/code/Magento/Sales/Model/Resource/Order/Creditmemo/Grid/Collection.php
deleted file mode 100644
index 7db54682b380f..0000000000000
--- a/app/code/Magento/Sales/Model/Resource/Order/Creditmemo/Grid/Collection.php
+++ /dev/null
@@ -1,39 +0,0 @@
-
- */
-class Collection extends \Magento\Sales\Model\Resource\Order\Creditmemo\Collection
-{
- /**
- * Event prefix
- *
- * @var string
- */
- protected $_eventPrefix = 'sales_order_creditmemo_grid_collection';
-
- /**
- * Event object
- *
- * @var string
- */
- protected $_eventObject = 'order_creditmemo_grid_collection';
-
- /**
- * Model initialization
- *
- * @return void
- */
- protected function _construct()
- {
- parent::_construct();
- $this->setMainTable('sales_creditmemo_grid');
- }
-}
diff --git a/app/code/Magento/Sales/Model/Resource/Order/Creditmemo/Order/Grid/Collection.php b/app/code/Magento/Sales/Model/Resource/Order/Creditmemo/Order/Grid/Collection.php
deleted file mode 100644
index 0c794de75eca3..0000000000000
--- a/app/code/Magento/Sales/Model/Resource/Order/Creditmemo/Order/Grid/Collection.php
+++ /dev/null
@@ -1,72 +0,0 @@
-
- */
-class Collection extends \Magento\Sales\Model\Resource\Order\Creditmemo\Grid\Collection
-{
- /**
- * @var \Magento\Framework\Registry
- */
- protected $registryManager;
-
- /**
- * @param \Magento\Framework\Data\Collection\EntityFactoryInterface $entityFactory
- * @param \Psr\Log\LoggerInterface $logger
- * @param \Magento\Framework\Data\Collection\Db\FetchStrategyInterface $fetchStrategy
- * @param \Magento\Framework\Event\ManagerInterface $eventManager
- * @param \Magento\Framework\Registry $registryManager
- * @param \Magento\Framework\Model\Resource\Db\VersionControl\Snapshot $entitySnapshot
- * @param null $connection
- * @param \Magento\Framework\Model\Resource\Db\AbstractDb $resource
- */
- public function __construct(
- \Magento\Framework\Data\Collection\EntityFactoryInterface $entityFactory,
- \Psr\Log\LoggerInterface $logger,
- \Magento\Framework\Data\Collection\Db\FetchStrategyInterface $fetchStrategy,
- \Magento\Framework\Event\ManagerInterface $eventManager,
- \Magento\Framework\Model\Resource\Db\VersionControl\Snapshot $entitySnapshot,
- \Magento\Framework\Registry $registryManager,
- \Magento\Framework\DB\Adapter\AdapterInterface $connection = null,
- \Magento\Framework\Model\Resource\Db\AbstractDb $resource = null
- ) {
- $this->registryManager = $registryManager;
- parent::__construct(
- $entityFactory,
- $logger,
- $fetchStrategy,
- $eventManager,
- $entitySnapshot,
- $connection,
- $resource
- );
- }
-
- /**
- * Retrieve order model instance
- *
- * @return \Magento\Sales\Model\Order
- */
- public function getOrder()
- {
- return $this->registryManager->registry('current_order');
- }
-
- /**
- * Apply sorting and filtering to collection
- *
- * @return $this
- */
- protected function _initSelect()
- {
- parent::_initSelect()->setOrderFilter($this->getOrder());
- return $this;
- }
-}
diff --git a/app/code/Magento/Sales/Model/Resource/Order/Grid/Collection.php b/app/code/Magento/Sales/Model/Resource/Order/Grid/Collection.php
deleted file mode 100644
index 5ed0b75ef7a66..0000000000000
--- a/app/code/Magento/Sales/Model/Resource/Order/Grid/Collection.php
+++ /dev/null
@@ -1,95 +0,0 @@
-
- */
-class Collection extends \Magento\Sales\Model\Resource\Order\Collection
-{
- /**
- * Event prefix
- *
- * @var string
- */
- protected $_eventPrefix = 'sales_order_grid_collection';
-
- /**
- * Event object
- *
- * @var string
- */
- protected $_eventObject = 'order_grid_collection';
-
- /**
- * Customer mode flag
- *
- * @var bool
- */
- protected $_customerModeFlag = false;
-
- /**
- * Model initialization
- *
- * @return void
- */
- protected function _construct()
- {
- parent::_construct();
- $this->setMainTable('sales_order_grid');
- }
-
- /**
- * Get SQL for get record count
- *
- * @return \Magento\Framework\DB\Select
- */
- public function getSelectCountSql()
- {
- if ($this->getIsCustomerMode()) {
- $this->_renderFilters();
-
- $unionSelect = clone $this->getSelect();
-
- $unionSelect->reset(\Magento\Framework\DB\Select::ORDER);
- $unionSelect->reset(\Magento\Framework\DB\Select::LIMIT_COUNT);
- $unionSelect->reset(\Magento\Framework\DB\Select::LIMIT_OFFSET);
-
- $countSelect = clone $this->getSelect();
- $countSelect->reset();
- $countSelect->from(['a' => $unionSelect], 'COUNT(*)');
- } else {
- $countSelect = parent::getSelectCountSql();
- }
-
- return $countSelect;
- }
-
- /**
- * Set customer mode flag value
- *
- * @param bool $value
- * @return $this
- */
- public function setIsCustomerMode($value)
- {
- $this->_customerModeFlag = (bool)$value;
- return $this;
- }
-
- /**
- * Get customer mode flag value
- *
- * @return bool
- * @SuppressWarnings(PHPMD.BooleanGetMethodName)
- */
- public function getIsCustomerMode()
- {
- return $this->_customerModeFlag;
- }
-}
diff --git a/app/code/Magento/Sales/Model/Resource/Order/Grid/Sql/Concat.php b/app/code/Magento/Sales/Model/Resource/Order/Grid/Sql/Concat.php
deleted file mode 100644
index 5a40a3fcb049f..0000000000000
--- a/app/code/Magento/Sales/Model/Resource/Order/Grid/Sql/Concat.php
+++ /dev/null
@@ -1,50 +0,0 @@
-columns = $columns;
- $this->separator = $separator;
- }
-
- /**
- * @return string
- */
- public function __toString()
- {
- $columns = [];
- foreach ($this->columns as $key => $column) {
- $columns[$key] = sprintf("ifnull(%s, '')", $column);
- }
- return sprintf(
- 'trim(concat(%s))',
- implode(
- sprintf(", '%s' ,", $this->separator),
- $columns
- )
- );
- }
-}
diff --git a/app/code/Magento/Sales/Model/Resource/Order/Grid/Sql/SubSelect.php b/app/code/Magento/Sales/Model/Resource/Order/Grid/Sql/SubSelect.php
deleted file mode 100644
index b588c47bda30e..0000000000000
--- a/app/code/Magento/Sales/Model/Resource/Order/Grid/Sql/SubSelect.php
+++ /dev/null
@@ -1,101 +0,0 @@
-resource = $resource;
- $this->connectionName = $connectionName;
- $this->table = $table;
- $this->columns = $columns;
- $this->originColumn = $originColumn;
- $this->targetColumn = $targetColumn;
- }
-
- /**
- * @return string
- */
- public function __toString()
- {
- $select = $this->getConnection()->select()->from(
- $this->resource->getTableName($this->table),
- array_values($this->columns)
- )->where(
- sprintf('`%s` = %s', $this->originColumn, $this->targetColumn)
- )->limit(1);
- return sprintf('(%s)', $select);
- }
-
- /**
- * Returns connection
- *
- * @return AdapterInterface
- */
- protected function getConnection()
- {
- if (!$this->connection) {
- $this->connection = $this->resource->getConnection($this->connectionName);
- }
- return $this->connection;
- }
-}
diff --git a/app/code/Magento/Sales/Model/Resource/Order/Grid/StatusesArray.php b/app/code/Magento/Sales/Model/Resource/Order/Grid/StatusesArray.php
deleted file mode 100644
index ee14b65c2d47c..0000000000000
--- a/app/code/Magento/Sales/Model/Resource/Order/Grid/StatusesArray.php
+++ /dev/null
@@ -1,36 +0,0 @@
-_statusCollectionFactory = $statusCollectionFactory;
- }
-
- /**
- * Return option array
- *
- * @return array
- */
- public function toOptionArray()
- {
- $statuses = $this->_statusCollectionFactory->create()->toOptionHash();
- return $statuses;
- }
-}
diff --git a/app/code/Magento/Sales/Model/Resource/Order/Invoice/Collection.php b/app/code/Magento/Sales/Model/Resource/Order/Invoice/Collection.php
index 7248f5b13190a..a8bb205da49af 100644
--- a/app/code/Magento/Sales/Model/Resource/Order/Invoice/Collection.php
+++ b/app/code/Magento/Sales/Model/Resource/Order/Invoice/Collection.php
@@ -15,6 +15,13 @@
*/
class Collection extends AbstractCollection implements InvoiceSearchResultInterface
{
+ /**
+ * Id field name
+ *
+ * @var string
+ */
+ protected $_idFieldName = 'entity_id';
+
/**
* Event prefix
*
diff --git a/app/code/Magento/Sales/Model/Resource/Order/Invoice/Grid/Collection.php b/app/code/Magento/Sales/Model/Resource/Order/Invoice/Grid/Collection.php
deleted file mode 100644
index e8ec35930f11f..0000000000000
--- a/app/code/Magento/Sales/Model/Resource/Order/Invoice/Grid/Collection.php
+++ /dev/null
@@ -1,39 +0,0 @@
-
- */
-class Collection extends \Magento\Sales\Model\Resource\Order\Invoice\Collection
-{
- /**
- * Event prefix
- *
- * @var string
- */
- protected $_eventPrefix = 'sales_order_invoice_grid_collection';
-
- /**
- * Event object
- *
- * @var string
- */
- protected $_eventObject = 'order_invoice_grid_collection';
-
- /**
- * Model initialization
- *
- * @return void
- */
- protected function _construct()
- {
- parent::_construct();
- $this->setMainTable('sales_invoice_grid');
- }
-}
diff --git a/app/code/Magento/Sales/Model/Resource/Order/Invoice/Orders/Grid/Collection.php b/app/code/Magento/Sales/Model/Resource/Order/Invoice/Orders/Grid/Collection.php
deleted file mode 100644
index 3e9bb8a7ad065..0000000000000
--- a/app/code/Magento/Sales/Model/Resource/Order/Invoice/Orders/Grid/Collection.php
+++ /dev/null
@@ -1,68 +0,0 @@
-registryManager = $registryManager;
- parent::__construct(
- $entityFactory,
- $logger,
- $fetchStrategy,
- $eventManager,
- $entitySnapshot,
- $connection,
- $resource
- );
- }
-
- /**
- * Retrieve order model instance
- *
- * @return \Magento\Sales\Model\Order
- */
- public function getOrder()
- {
- return $this->registryManager->registry('current_order');
- }
-
- /**
- * Apply sorting and filtering to collection
- *
- * @return $this
- */
- protected function _initSelect()
- {
- parent::_initSelect();
- $this->setOrderFilter($this->getOrder());
- return $this;
- }
-}
diff --git a/app/code/Magento/Sales/Model/Resource/Order/Shipment/Collection.php b/app/code/Magento/Sales/Model/Resource/Order/Shipment/Collection.php
index ccdefda10fd30..63744b59dca9f 100644
--- a/app/code/Magento/Sales/Model/Resource/Order/Shipment/Collection.php
+++ b/app/code/Magento/Sales/Model/Resource/Order/Shipment/Collection.php
@@ -15,6 +15,11 @@
*/
class Collection extends AbstractCollection implements ShipmentSearchResultInterface
{
+ /**
+ * @var string
+ */
+ protected $_idFieldName = 'entity_id';
+
/**
* Event prefix
*
diff --git a/app/code/Magento/Sales/Model/Resource/Order/Shipment/Grid/Collection.php b/app/code/Magento/Sales/Model/Resource/Order/Shipment/Grid/Collection.php
deleted file mode 100644
index cae68ec151da9..0000000000000
--- a/app/code/Magento/Sales/Model/Resource/Order/Shipment/Grid/Collection.php
+++ /dev/null
@@ -1,39 +0,0 @@
-
- */
-class Collection extends \Magento\Sales\Model\Resource\Order\Shipment\Collection
-{
- /**
- * Event prefix
- *
- * @var string
- */
- protected $_eventPrefix = 'sales_order_shipment_grid_collection';
-
- /**
- * Event object
- *
- * @var string
- */
- protected $_eventObject = 'order_shipment_grid_collection';
-
- /**
- * Model initialization
- *
- * @return void
- */
- protected function _construct()
- {
- parent::_construct();
- $this->setMainTable('sales_shipment_grid');
- }
-}
diff --git a/app/code/Magento/Sales/Model/Resource/Order/Shipment/Order/Grid/Collection.php b/app/code/Magento/Sales/Model/Resource/Order/Shipment/Order/Grid/Collection.php
deleted file mode 100644
index e57f863368298..0000000000000
--- a/app/code/Magento/Sales/Model/Resource/Order/Shipment/Order/Grid/Collection.php
+++ /dev/null
@@ -1,73 +0,0 @@
-
- */
-class Collection extends \Magento\Sales\Model\Resource\Order\Shipment\Grid\Collection
-{
- /**
- * @var \Magento\Framework\Registry
- */
- protected $registryManager;
-
- /**
- * @param \Magento\Framework\Data\Collection\EntityFactoryInterface $entityFactory
- * @param \Psr\Log\LoggerInterface $logger
- * @param \Magento\Framework\Data\Collection\Db\FetchStrategyInterface $fetchStrategy
- * @param \Magento\Framework\Event\ManagerInterface $eventManager
- * @param \Magento\Framework\Model\Resource\Db\VersionControl\Snapshot $entitySnapshot
- * @param \Magento\Framework\Registry $registryManager
- * @param null $connection
- * @param \Magento\Framework\Model\Resource\Db\AbstractDb $resource
- */
- public function __construct(
- \Magento\Framework\Data\Collection\EntityFactoryInterface $entityFactory,
- \Psr\Log\LoggerInterface $logger,
- \Magento\Framework\Data\Collection\Db\FetchStrategyInterface $fetchStrategy,
- \Magento\Framework\Event\ManagerInterface $eventManager,
- \Magento\Framework\Model\Resource\Db\VersionControl\Snapshot $entitySnapshot,
- \Magento\Framework\Registry $registryManager,
- \Magento\Framework\DB\Adapter\AdapterInterface $connection = null,
- \Magento\Framework\Model\Resource\Db\AbstractDb $resource = null
- ) {
- $this->registryManager = $registryManager;
- parent::__construct(
- $entityFactory,
- $logger,
- $fetchStrategy,
- $eventManager,
- $entitySnapshot,
- $connection,
- $resource
- );
- }
-
- /**
- * Retrieve order model instance
- *
- * @return \Magento\Sales\Model\Order
- */
- public function getOrder()
- {
- return $this->registryManager->registry('current_order');
- }
-
- /**
- * Apply sorting and filtering to collection
- *
- * @return $this
- */
- protected function _initSelect()
- {
- parent::_initSelect();
- $this->setOrderFilter($this->getOrder());
- return $this;
- }
-}
diff --git a/app/code/Magento/Sales/Test/Unit/Block/Adminhtml/Order/GridTest.php b/app/code/Magento/Sales/Test/Unit/Block/Adminhtml/Order/GridTest.php
deleted file mode 100644
index 2a3ddf1b44011..0000000000000
--- a/app/code/Magento/Sales/Test/Unit/Block/Adminhtml/Order/GridTest.php
+++ /dev/null
@@ -1,81 +0,0 @@
-requestMock = $this->getMockBuilder('Magento\Framework\App\RequestInterface')
- ->disableOriginalConstructor()
- ->setMethods(['has'])
- ->getMockForAbstractClass();
- $this->contextMock = $this->getMockBuilder('Magento\Backend\Block\Template\Context')
- ->disableOriginalConstructor()
- ->getMock();
- $this->contextMock->expects($this->any())
- ->method('getRequest')
- ->willReturn($this->requestMock);
- $arguments = [
- 'context' => $this->contextMock
- ];
- $helper = new \Magento\Framework\TestFramework\Unit\Helper\ObjectManager($this);
- /** @var \Magento\Sales\Block\Adminhtml\Order\Grid $block */
- $this->block = $helper->getObject('Magento\Sales\Block\Adminhtml\Order\Grid', $arguments);
- }
-
- public function testPrepareCollection()
- {
- $collectionMock = $this->getMockBuilder('Magento\Sales\Model\Resource\Order\Grid\Collection')
- ->disableOriginalConstructor()
- ->getMock();
- $this->requestMock->expects($this->any())
- ->method('has')
- ->withAnyParameters()
- ->willReturn(false);
- $layoutMock = $this->getMockBuilder('Magento\Framework\View\LayoutInterface')
- ->disableOriginalConstructor()
- ->getMock();
-
- $blockMock = $this->getMockBuilder('Magento\Framework\View\Element\AbstractBlock')
- ->disableOriginalConstructor()
- ->setMethods(['getLayout'])
- ->getMockForAbstractClass();
- $blockMock->expects($this->any())
- ->method('getLayout')
- ->willReturn($layoutMock);
-
- $layoutMock->expects($this->any())
- ->method('getBlock')
- ->willReturn($blockMock);
- $layoutMock->expects($this->any())
- ->method('getChildName')
- ->willReturn($blockMock);
- $this->block->setData('id', 1);
- $this->block->setLayout($layoutMock);
- $this->block->setCollection($collectionMock);
- $this->assertEquals($collectionMock, $this->block->getPreparedCollection());
- }
-}
diff --git a/app/code/Magento/Sales/Test/Unit/Controller/Adminhtml/Order/EmailTest.php b/app/code/Magento/Sales/Test/Unit/Controller/Adminhtml/Order/EmailTest.php
index fe36332d13983..73396196f9723 100644
--- a/app/code/Magento/Sales/Test/Unit/Controller/Adminhtml/Order/EmailTest.php
+++ b/app/code/Magento/Sales/Test/Unit/Controller/Adminhtml/Order/EmailTest.php
@@ -13,7 +13,7 @@
/**
* Class EmailTest
- *
+ * @SuppressWarnings(PHPMD.CouplingBetweenObjects)
* @package Magento\Sales\Controller\Adminhtml\Order
*/
class EmailTest extends \PHPUnit_Framework_TestCase
@@ -68,6 +68,26 @@ class EmailTest extends \PHPUnit_Framework_TestCase
*/
protected $helper;
+ /**
+ * @var \Magento\Sales\Api\OrderManagementInterface|\PHPUnit_Framework_MockObject_MockObject
+ */
+ protected $orderManagementMock;
+
+ /**
+ * @var \Magento\Sales\Api\OrderRepositoryInterface|\PHPUnit_Framework_MockObject_MockObject
+ */
+ protected $orderRepositoryMock;
+
+ /**
+ * @var \Psr\Log\LoggerInterface|\PHPUnit_Framework_MockObject_MockObject
+ */
+ protected $loggerMock;
+
+ /**
+ * @var \Magento\Sales\Api\Data\OrderInterface|\PHPUnit_Framework_MockObject_MockObject
+ */
+ protected $orderMock;
+
public function setUp()
{
$objectManagerHelper = new ObjectManagerHelper($this);
@@ -88,6 +108,12 @@ public function setUp()
'',
false
);
+ $this->orderManagementMock = $this->getMockBuilder('Magento\Sales\Api\OrderManagementInterface')
+ ->getMockForAbstractClass();
+ $this->orderRepositoryMock = $this->getMockBuilder('Magento\Sales\Api\OrderRepositoryInterface')
+ ->getMockForAbstractClass();
+ $this->loggerMock = $this->getMockBuilder('Psr\Log\LoggerInterface')
+ ->getMockForAbstractClass();
$resultRedirectFactory = $this->getMock(
'Magento\Backend\Model\View\Result\RedirectFactory',
['create'],
@@ -104,13 +130,6 @@ public function setUp()
);
$this->request = $this->getMockBuilder('Magento\Framework\App\Request\Http')
->disableOriginalConstructor()->getMock();
- $this->objectManager = $this->getMock(
- 'Magento\Framework\ObjectManager\ObjectManager',
- ['create'],
- [],
- '',
- false
- );
$this->messageManager = $this->getMock(
'Magento\Framework\Message\Manager',
['addSuccess', 'addError'],
@@ -118,6 +137,9 @@ public function setUp()
'',
false
);
+
+ $this->orderMock = $this->getMockBuilder('Magento\Sales\Api\Data\OrderInterface')
+ ->getMockForAbstractClass();
$this->session = $this->getMock('Magento\Backend\Model\Session', ['setIsUrlNotice'], [], '', false);
$this->actionFlag = $this->getMock('Magento\Framework\App\ActionFlag', ['get', 'set'], [], '', false);
$this->helper = $this->getMock('\Magento\Backend\Helper\Data', ['getUrl'], [], '', false);
@@ -138,7 +160,10 @@ public function setUp()
[
'context' => $this->context,
'request' => $this->request,
- 'response' => $this->response
+ 'response' => $this->response,
+ 'orderManagement' => $this->orderManagementMock,
+ 'orderRepository' => $this->orderRepositoryMock,
+ 'logger' => $this->loggerMock
]
);
}
@@ -146,35 +171,21 @@ public function setUp()
public function testEmail()
{
$orderId = 10000031;
- $orderClassName = 'Magento\Sales\Model\Order';
- $orderNotifierClassName = 'Magento\Sales\Api\OrderManagementInterface';
- $order = $this->getMock($orderClassName, ['load', 'getId', '__wakeup'], [], '', false);
- $cmNotifier = $this->getMockBuilder('Magento\Sales\Api\OrderManagementInterface')
- ->disableOriginalConstructor()
- ->getMock();
-
$this->request->expects($this->once())
->method('getParam')
->with('order_id')
->will($this->returnValue($orderId));
- $this->objectManager->expects($this->at(0))
- ->method('create')
- ->with($orderClassName)
- ->will($this->returnValue($order));
- $order->expects($this->once())
- ->method('load')
+ $this->orderRepositoryMock->expects($this->once())
+ ->method('get')
->with($orderId)
- ->will($this->returnSelf());
- $order->expects($this->atLeastOnce())
- ->method('getId')
+ ->willReturn($this->orderMock);
+ $this->orderMock->expects($this->atLeastOnce())
+ ->method('getEntityId')
->will($this->returnValue($orderId));
- $this->objectManager->expects($this->at(1))
- ->method('create')
- ->with($orderNotifierClassName)
- ->will($this->returnValue($cmNotifier));
- $cmNotifier->expects($this->once())
+ $this->orderManagementMock->expects($this->once())
->method('notify')
- ->will($this->returnValue(true));
+ ->with($orderId)
+ ->willReturn(true);
$this->messageManager->expects($this->once())
->method('addSuccess')
->with('You sent the order email.');
@@ -192,21 +203,16 @@ public function testEmail()
public function testEmailNoOrderId()
{
- $orderClassName = 'Magento\Sales\Model\Order';
- $order = $this->getMock($orderClassName, ['load', 'getId', '__wakeup'], [], '', false);
$this->request->expects($this->once())
->method('getParam')
->with('order_id')
->will($this->returnValue(null));
-
- $this->objectManager->expects($this->at(0))
- ->method('create')
- ->with($orderClassName)
- ->will($this->returnValue($order));
- $order->expects($this->once())
- ->method('load')
+ $this->orderRepositoryMock->expects($this->once())
+ ->method('get')
->with(null)
- ->will($this->returnSelf());
+ ->willThrowException(
+ new \Magento\Framework\Exception\NoSuchEntityException(__('Requested entity doesn\'t exist'))
+ );
$this->messageManager->expects($this->once())
->method('addError')
->with('This order no longer exists.');
diff --git a/app/code/Magento/Sales/Test/Unit/Controller/Adminhtml/Order/MassCancelTest.php b/app/code/Magento/Sales/Test/Unit/Controller/Adminhtml/Order/MassCancelTest.php
index f26c096c20ae6..0359eed52b0d9 100644
--- a/app/code/Magento/Sales/Test/Unit/Controller/Adminhtml/Order/MassCancelTest.php
+++ b/app/code/Magento/Sales/Test/Unit/Controller/Adminhtml/Order/MassCancelTest.php
@@ -71,56 +71,27 @@ class MassCancelTest extends \PHPUnit_Framework_TestCase
protected $orderMock;
/**
- * @var \PHPUnit_Framework_MockObject_MockObject
+ * @var \Magento\Sales\Model\Resource\Order\Collection|\PHPUnit_Framework_MockObject_MockObject
*/
protected $orderCollectionMock;
/**
- * @var \PHPUnit_Framework_MockObject_MockObject
+ * @var \Magento\Sales\Model\Resource\Order\CollectionFactory|\PHPUnit_Framework_MockObject_MockObject
*/
- protected $orderManagement;
+ protected $orderCollectionFactoryMock;
/**
- * @return void
- * @SuppressWarnings(PHPMD.ExcessiveMethodLength)
+ * @var \Magento\Ui\Component\MassAction\Filter|\PHPUnit_Framework_MockObject_MockObject
*/
+ protected $filterMock;
+
public function setUp()
{
$objectManagerHelper = new ObjectManagerHelper($this);
- $this->contextMock = $this->getMock(
- 'Magento\Backend\App\Action\Context',
- [
- 'getRequest',
- 'getResponse',
- 'getMessageManager',
- 'getRedirect',
- 'getObjectManager',
- 'getSession',
- 'getActionFlag',
- 'getHelper',
- 'getResultRedirectFactory',
- 'getResultFactory'
- ],
- [],
- '',
- false
- );
- $resultRedirectFactory = $this->getMock(
- 'Magento\Backend\Model\View\Result\RedirectFactory',
- ['create'],
- [],
- '',
- false
- );
- $this->responseMock = $this->getMock(
- 'Magento\Framework\App\ResponseInterface',
- ['setRedirect', 'sendResponse'],
- [],
- '',
- false
- );
- $this->requestMock = $this->getMockBuilder('Magento\Framework\App\Request\Http')
- ->disableOriginalConstructor()->getMock();
+ $this->contextMock = $this->getMock('Magento\Backend\App\Action\Context', [], [], '', false);
+ $this->messageManagerMock = $this->getMock('Magento\Framework\Message\Manager', [], [], '', false);
+ $this->responseMock = $this->getMock('Magento\Framework\App\ResponseInterface', [], [], '', false);
+ $this->requestMock = $this->getMock('Magento\Framework\App\Request\Http', [], [], '', false);
$this->objectManagerMock = $this->getMock(
'Magento\Framework\ObjectManager\ObjectManager',
[],
@@ -128,9 +99,10 @@ public function setUp()
'',
false
);
- $this->messageManagerMock = $this->getMock(
- 'Magento\Framework\Message\Manager',
- ['addSuccess', 'addError'],
+
+ $resultRedirectFactory = $this->getMock(
+ 'Magento\Backend\Model\View\Result\RedirectFactory',
+ [],
[],
'',
false
@@ -140,6 +112,12 @@ public function setUp()
->disableOriginalConstructor()
->getMock();
+ $resourceCollection = 'Magento\Sales\Model\Resource\Order\CollectionFactory';
+ $this->orderCollectionFactoryMock = $this->getMockBuilder($resourceCollection)
+ ->disableOriginalConstructor()
+ ->setMethods(['create'])
+ ->getMock();
+
$this->sessionMock = $this->getMock('Magento\Backend\Model\Session', ['setIsUrlNotice'], [], '', false);
$this->actionFlagMock = $this->getMock('Magento\Framework\App\ActionFlag', ['get', 'set'], [], '', false);
$this->helperMock = $this->getMock('\Magento\Backend\Helper\Data', ['getUrl'], [], '', false);
@@ -165,26 +143,26 @@ public function setUp()
$this->contextMock->expects($this->once())->method('getSession')->willReturn($this->sessionMock);
$this->contextMock->expects($this->once())->method('getActionFlag')->willReturn($this->actionFlagMock);
$this->contextMock->expects($this->once())->method('getHelper')->willReturn($this->helperMock);
- $this->contextMock
- ->expects($this->once())
+ $this->contextMock->expects($this->once())
->method('getResultRedirectFactory')
->willReturn($resultRedirectFactory);
$this->contextMock->expects($this->any())
->method('getResultFactory')
->willReturn($resultFactoryMock);
-
- $this->orderManagement = $this->getMockBuilder('Magento\Sales\Api\OrderManagementInterface')
- ->disableOriginalConstructor()
- ->getMock();
- $this->objectManagerMock->expects($this->any())
- ->method('get')
- ->with('Magento\Sales\Api\OrderManagementInterface')
- ->willReturn($this->orderManagement);
-
+ $this->filterMock = $this->getMock('Magento\Ui\Component\MassAction\Filter', [], [], '', false);
+ $this->filterMock->expects($this->once())
+ ->method('getCollection')
+ ->with($this->orderCollectionMock)
+ ->willReturn($this->orderCollectionMock);
+ $this->orderCollectionFactoryMock->expects($this->once())
+ ->method('create')
+ ->willReturn($this->orderCollectionMock);
$this->massAction = $objectManagerHelper->getObject(
'Magento\Sales\Controller\Adminhtml\Order\MassCancel',
[
- 'context' => $this->contextMock
+ 'context' => $this->contextMock,
+ 'filter' => $this->filterMock,
+ 'collectionFactory' => $this->orderCollectionFactoryMock
]
);
}
@@ -193,48 +171,28 @@ public function setUp()
* Test for selected orders
* Two orders, only $order1 can be canceled
*/
- public function testExecuteTwoOrderCanceled()
+ public function testExecuteCanCancelOneOrder()
{
- $selected = [1, 2];
- $countOrders = count($selected);
-
$order1 = $this->getMockBuilder('Magento\Sales\Model\Order')
->disableOriginalConstructor()
->getMock();
$order2 = $this->getMockBuilder('Magento\Sales\Model\Order')
->disableOriginalConstructor()
->getMock();
+ $orders = [$order1, $order2];
+ $countOrders = count($orders);
- $this->requestMock->expects($this->at(0))
- ->method('getParam')
- ->with('selected')
- ->willReturn($selected);
-
- $this->requestMock->expects($this->at(1))
- ->method('getParam')
- ->with('excluded')
- ->willReturn([]);
-
- $this->objectManagerMock->expects($this->once())
- ->method('create')
- ->with('Magento\Sales\Model\Resource\Order\Grid\Collection')
- ->willReturn($this->orderCollectionMock);
- $this->orderCollectionMock->expects($this->once())
- ->method('addFieldToFilter')
- ->with(\Magento\Sales\Controller\Adminhtml\Order\MassCancel::ID_FIELD, ['in' => $selected]);
$this->orderCollectionMock->expects($this->any())
->method('getItems')
- ->willReturn([$order1, $order2]);
+ ->willReturn($orders);
- $this->orderManagement->expects($this->at(0))
- ->method('cancel')
- ->with(1);
$order1->expects($this->once())
->method('canCancel')
->willReturn(true);
$order1->expects($this->once())
- ->method('getEntityId')
- ->willReturn(1);
+ ->method('cancel');
+ $order1->expects($this->once())
+ ->method('save');
$this->orderCollectionMock->expects($this->once())
->method('count')
@@ -252,6 +210,11 @@ public function testExecuteTwoOrderCanceled()
->method('addSuccess')
->with('We canceled 1 order(s).');
+ $this->resultRedirectMock->expects($this->once())
+ ->method('setPath')
+ ->with('sales/*/')
+ ->willReturnSelf();
+
$this->massAction->execute();
}
@@ -259,11 +222,8 @@ public function testExecuteTwoOrderCanceled()
* Test for excluded orders
* Two orders could't be canceled
*/
- public function testExcludedOrderCannotBeCanceled()
+ public function testExcludedCannotCancelOrders()
{
- $excluded = [1, 2];
- $countOrders = count($excluded);
-
$order1 = $this->getMockBuilder('Magento\Sales\Model\Order')
->disableOriginalConstructor()
->getMock();
@@ -271,23 +231,9 @@ public function testExcludedOrderCannotBeCanceled()
->disableOriginalConstructor()
->getMock();
- $this->requestMock->expects($this->at(0))
- ->method('getParam')
- ->with('selected')
- ->willReturn([]);
-
- $this->requestMock->expects($this->at(1))
- ->method('getParam')
- ->with('excluded')
- ->willReturn($excluded);
+ $orders = [$order1, $order2];
+ $countOrders = count($orders);
- $this->objectManagerMock->expects($this->once())
- ->method('create')
- ->with('Magento\Sales\Model\Resource\Order\Grid\Collection')
- ->willReturn($this->orderCollectionMock);
- $this->orderCollectionMock->expects($this->once())
- ->method('addFieldToFilter')
- ->with(\Magento\Sales\Controller\Adminhtml\Order\MassCancel::ID_FIELD, ['nin' => $excluded]);
$this->orderCollectionMock->expects($this->any())
->method('getItems')
->willReturn([$order1, $order2]);
@@ -308,19 +254,10 @@ public function testExcludedOrderCannotBeCanceled()
->method('addError')
->with('You cannot cancel the order(s).');
- $this->massAction->execute();
- }
-
- public function testNoExcludedNoSelectedOrders()
- {
- $this->objectManagerMock->expects($this->once())
- ->method('create')
- ->with('Magento\Sales\Model\Resource\Order\Grid\Collection')
- ->willReturn($this->orderCollectionMock);
-
- $this->messageManagerMock->expects($this->once())
- ->method('addError')
- ->with('Please select item(s).');
+ $this->resultRedirectMock->expects($this->once())
+ ->method('setPath')
+ ->with('sales/*/')
+ ->willReturnSelf();
$this->massAction->execute();
}
@@ -330,44 +267,21 @@ public function testNoExcludedNoSelectedOrders()
*/
public function testException()
{
- $selected = [1];
$exception = new \Exception('Can not cancel');
$order1 = $this->getMockBuilder('Magento\Sales\Model\Order')
->disableOriginalConstructor()
->getMock();
-
- $this->requestMock->expects($this->at(0))
- ->method('getParam')
- ->with('selected')
- ->willReturn($selected);
-
- $this->requestMock->expects($this->at(1))
- ->method('getParam')
- ->with('excluded')
- ->willReturn([]);
-
- $this->objectManagerMock->expects($this->once())
- ->method('create')
- ->with('Magento\Sales\Model\Resource\Order\Grid\Collection')
- ->willReturn($this->orderCollectionMock);
- $this->orderCollectionMock->expects($this->once())
- ->method('addFieldToFilter')
- ->with(\Magento\Sales\Controller\Adminhtml\Order\MassCancel::ID_FIELD, ['in' => $selected]);
$this->orderCollectionMock->expects($this->any())
->method('getItems')
->willReturn([$order1]);
- $this->orderManagement->expects($this->once())
- ->method('cancel')
- ->with(1)
- ->willThrowException($exception);
$order1->expects($this->once())
->method('canCancel')
->willReturn(true);
$order1->expects($this->once())
- ->method('getEntityId')
- ->willReturn(1);
+ ->method('cancel')
+ ->willThrowException($exception);
$this->messageManagerMock->expects($this->once())
->method('addError')
diff --git a/app/code/Magento/Sales/Test/Unit/Controller/Adminhtml/Order/MassHoldTest.php b/app/code/Magento/Sales/Test/Unit/Controller/Adminhtml/Order/MassHoldTest.php
index d74b5139766b9..9e7f392b3ecf8 100644
--- a/app/code/Magento/Sales/Test/Unit/Controller/Adminhtml/Order/MassHoldTest.php
+++ b/app/code/Magento/Sales/Test/Unit/Controller/Adminhtml/Order/MassHoldTest.php
@@ -71,74 +71,57 @@ class MassHoldTest extends \PHPUnit_Framework_TestCase
protected $orderMock;
/**
- * @var \PHPUnit_Framework_MockObject_MockObject
+ * @var \Magento\Sales\Model\Resource\Order\Collection|\PHPUnit_Framework_MockObject_MockObject
*/
protected $orderCollectionMock;
/**
- * @var \PHPUnit_Framework_MockObject_MockObject
+ * @var \Magento\Sales\Model\Resource\Order\CollectionFactory|\PHPUnit_Framework_MockObject_MockObject
*/
- protected $orderManagement;
+ protected $orderCollectionFactoryMock;
/**
- * @return void
- * @SuppressWarnings(PHPMD.ExcessiveMethodLength)
+ * @var \Magento\Ui\Component\MassAction\Filter|\PHPUnit_Framework_MockObject_MockObject
*/
+ protected $filterMock;
+
+ /**
+ * @var \Magento\Sales\Api\OrderManagementInterface|\PHPUnit_Framework_MockObject_MockObject
+ */
+ protected $orderManagementMock;
+
public function setUp()
{
$objectManagerHelper = new ObjectManagerHelper($this);
- $this->contextMock = $this->getMock(
- 'Magento\Backend\App\Action\Context',
- [
- 'getRequest',
- 'getResponse',
- 'getMessageManager',
- 'getRedirect',
- 'getObjectManager',
- 'getSession',
- 'getActionFlag',
- 'getHelper',
- 'getResultRedirectFactory',
- 'getResultFactory'
- ],
- [],
- '',
- false
- );
+ $this->orderManagementMock = $this->getMockBuilder('Magento\Sales\Api\OrderManagementInterface')
+ ->getMockForAbstractClass();
+ $this->contextMock = $this->getMock('Magento\Backend\App\Action\Context', [], [], '', false);
$resultRedirectFactory = $this->getMock(
'Magento\Backend\Model\View\Result\RedirectFactory',
- ['create'],
[],
- '',
- false
- );
- $this->responseMock = $this->getMock(
- 'Magento\Framework\App\ResponseInterface',
- ['setRedirect', 'sendResponse'],
[],
'',
false
);
+ $this->responseMock = $this->getMock('Magento\Framework\App\ResponseInterface', [], [], '', false);
$this->requestMock = $this->getMockBuilder('Magento\Framework\App\Request\Http')
->disableOriginalConstructor()->getMock();
$this->objectManagerMock = $this->getMock(
'Magento\Framework\ObjectManager\ObjectManager',
- [],
- [],
- '',
- false
- );
- $this->messageManagerMock = $this->getMock(
- 'Magento\Framework\Message\Manager',
- ['addSuccess', 'addError'],
+ ['create'],
[],
'',
false
);
+ $this->messageManagerMock = $this->getMock('Magento\Framework\Message\Manager', [], [], '', false);
$this->orderCollectionMock = $this->getMockBuilder('Magento\Sales\Model\Resource\Order\Collection')
->disableOriginalConstructor()
->getMock();
-
+ $orderCollection = 'Magento\Sales\Model\Resource\Order\CollectionFactory';
+ $this->orderCollectionFactoryMock = $this->getMockBuilder($orderCollection)
+ ->disableOriginalConstructor()
+ ->setMethods(['create'])
+ ->getMock();
$redirectMock = $this->getMockBuilder('Magento\Backend\Model\View\Result\Redirect')
->disableOriginalConstructor()
->getMock();
@@ -172,26 +155,28 @@ public function setUp()
->method('getResultFactory')
->willReturn($resultFactoryMock);
- $this->orderManagement = $this->getMockBuilder('Magento\Sales\Api\OrderManagementInterface')
- ->disableOriginalConstructor()
- ->getMock();
- $this->objectManagerMock->expects($this->any())
- ->method('get')
- ->with('Magento\Sales\Api\OrderManagementInterface')
- ->willReturn($this->orderManagement);
+ $this->filterMock = $this->getMock('Magento\Ui\Component\MassAction\Filter', [], [], '', false);
+ $this->filterMock->expects($this->once())
+ ->method('getCollection')
+ ->with($this->orderCollectionMock)
+ ->willReturn($this->orderCollectionMock);
+ $this->orderCollectionFactoryMock->expects($this->once())
+ ->method('create')
+ ->willReturn($this->orderCollectionMock);
+
$this->massAction = $objectManagerHelper->getObject(
'Magento\Sales\Controller\Adminhtml\Order\MassHold',
[
'context' => $this->contextMock,
+ 'filter' => $this->filterMock,
+ 'collectionFactory' => $this->orderCollectionFactoryMock,
+ 'orderManagement' => $this->orderManagementMock
]
);
}
- public function testExecuteTwoOrdersPutOnHold()
+ public function testExecuteOneOrderPutOnHold()
{
- $selected = [1, 2];
- $countOrders = count($selected);
-
$order1 = $this->getMockBuilder('Magento\Sales\Model\Order')
->disableOriginalConstructor()
->getMock();
@@ -199,37 +184,18 @@ public function testExecuteTwoOrdersPutOnHold()
->disableOriginalConstructor()
->getMock();
- $this->requestMock->expects($this->at(0))
- ->method('getParam')
- ->with('selected')
- ->willReturn($selected);
-
- $this->requestMock->expects($this->at(1))
- ->method('getParam')
- ->with('excluded')
- ->willReturn([]);
+ $orders = [$order1, $order2];
+ $countOrders = count($orders);
- $this->objectManagerMock->expects($this->once())
- ->method('create')
- ->with('Magento\Sales\Model\Resource\Order\Grid\Collection')
- ->willReturn($this->orderCollectionMock);
- $this->orderCollectionMock->expects($this->once())
- ->method('addFieldToFilter')
- ->with(\Magento\Sales\Controller\Adminhtml\Order\MassCancel::ID_FIELD, ['in' => $selected]);
$this->orderCollectionMock->expects($this->any())
->method('getItems')
- ->willReturn([$order1, $order2]);
+ ->willReturn($orders);
- $this->orderManagement->expects($this->once())
- ->method('hold')
- ->with(1);
$order1->expects($this->once())
->method('canHold')
->willReturn(true);
- $order1->expects($this->once())
- ->method('getEntityId')
- ->willReturn(1);
-
+ $this->orderManagementMock->expects($this->once())
+ ->method('hold');
$this->orderCollectionMock->expects($this->once())
->method('count')
->willReturn($countOrders);
@@ -254,11 +220,8 @@ public function testExecuteTwoOrdersPutOnHold()
$this->massAction->execute();
}
- public function testExecuteOneOrderCannotBePutOnHold()
+ public function testExecuteNoOrdersPutOnHold()
{
- $excluded = [1, 2];
- $countOrders = count($excluded);
-
$order1 = $this->getMockBuilder('Magento\Sales\Model\Order')
->disableOriginalConstructor()
->getMock();
@@ -266,26 +229,12 @@ public function testExecuteOneOrderCannotBePutOnHold()
->disableOriginalConstructor()
->getMock();
- $this->requestMock->expects($this->at(0))
- ->method('getParam')
- ->with('selected')
- ->willReturn([]);
-
- $this->requestMock->expects($this->at(1))
- ->method('getParam')
- ->with('excluded')
- ->willReturn($excluded);
+ $orders = [$order1, $order2];
+ $countOrders = count($orders);
- $this->objectManagerMock->expects($this->once())
- ->method('create')
- ->with('Magento\Sales\Model\Resource\Order\Grid\Collection')
- ->willReturn($this->orderCollectionMock);
- $this->orderCollectionMock->expects($this->once())
- ->method('addFieldToFilter')
- ->with(\Magento\Sales\Controller\Adminhtml\Order\MassCancel::ID_FIELD, ['nin' => $excluded]);
$this->orderCollectionMock->expects($this->any())
->method('getItems')
- ->willReturn([$order1, $order2]);
+ ->willReturn($orders);
$order1->expects($this->once())
->method('canHold')
diff --git a/app/code/Magento/Sales/Test/Unit/Controller/Adminhtml/Order/MassUnholdTest.php b/app/code/Magento/Sales/Test/Unit/Controller/Adminhtml/Order/MassUnholdTest.php
index cec2ba1b5ae99..dd43b7ac2c570 100644
--- a/app/code/Magento/Sales/Test/Unit/Controller/Adminhtml/Order/MassUnholdTest.php
+++ b/app/code/Magento/Sales/Test/Unit/Controller/Adminhtml/Order/MassUnholdTest.php
@@ -71,54 +71,32 @@ class MassUnholdTest extends \PHPUnit_Framework_TestCase
protected $orderMock;
/**
- * @var \PHPUnit_Framework_MockObject_MockObject
+ * @var \Magento\Sales\Model\Resource\Order\Collection|\PHPUnit_Framework_MockObject_MockObject
*/
protected $orderCollectionMock;
/**
- * @var \PHPUnit_Framework_MockObject_MockObject
+ * @var \Magento\Sales\Model\Resource\Order\CollectionFactory|\PHPUnit_Framework_MockObject_MockObject
*/
- protected $orderManagement;
+ protected $orderCollectionFactoryMock;
/**
- * @return void
- * @SuppressWarnings(PHPMD.ExcessiveMethodLength)
+ * @var \Magento\Ui\Component\MassAction\Filter|\PHPUnit_Framework_MockObject_MockObject
*/
+ protected $filterMock;
+
public function setUp()
{
$objectManagerHelper = new ObjectManagerHelper($this);
- $this->contextMock = $this->getMock(
- 'Magento\Backend\App\Action\Context',
- [
- 'getRequest',
- 'getResponse',
- 'getMessageManager',
- 'getRedirect',
- 'getObjectManager',
- 'getSession',
- 'getActionFlag',
- 'getHelper',
- 'getResultRedirectFactory',
- 'getResultFactory'
- ],
- [],
- '',
- false
- );
+ $this->contextMock = $this->getMock('Magento\Backend\App\Action\Context', [], [], '', false);
$resultRedirectFactory = $this->getMock(
'Magento\Backend\Model\View\Result\RedirectFactory',
- ['create'],
[],
- '',
- false
- );
- $this->responseMock = $this->getMock(
- 'Magento\Framework\App\ResponseInterface',
- ['setRedirect', 'sendResponse'],
[],
'',
false
);
+ $this->responseMock = $this->getMock('Magento\Framework\App\ResponseInterface', [], [], '', false);
$this->requestMock = $this->getMockBuilder('Magento\Framework\App\Request\Http')
->disableOriginalConstructor()->getMock();
$this->objectManagerMock = $this->getMock(
@@ -128,18 +106,16 @@ public function setUp()
'',
false
);
- $this->messageManagerMock = $this->getMock(
- 'Magento\Framework\Message\Manager',
- ['addSuccess', 'addError'],
- [],
- '',
- false
- );
+ $this->messageManagerMock = $this->getMock('Magento\Framework\Message\Manager', [], [], '', false);
$this->orderCollectionMock = $this->getMockBuilder('Magento\Sales\Model\Resource\Order\Collection')
->disableOriginalConstructor()
->getMock();
-
+ $orderCollection = 'Magento\Sales\Model\Resource\Order\CollectionFactory';
+ $this->orderCollectionFactoryMock = $this->getMockBuilder($orderCollection)
+ ->disableOriginalConstructor()
+ ->setMethods(['create'])
+ ->getMock();
$this->sessionMock = $this->getMock('Magento\Backend\Model\Session', ['setIsUrlNotice'], [], '', false);
$this->actionFlagMock = $this->getMock('Magento\Framework\App\ActionFlag', ['get', 'set'], [], '', false);
$this->helperMock = $this->getMock('\Magento\Backend\Helper\Data', ['getUrl'], [], '', false);
@@ -173,28 +149,27 @@ public function setUp()
->method('getResultFactory')
->willReturn($resultFactoryMock);
- $this->orderManagement = $this->getMockBuilder('Magento\Sales\Api\OrderManagementInterface')
- ->disableOriginalConstructor()
- ->getMock();
-
- $this->objectManagerMock->expects($this->any())
- ->method('get')
- ->with('Magento\Sales\Api\OrderManagementInterface')
- ->willReturn($this->orderManagement);
+ $this->filterMock = $this->getMock('Magento\Ui\Component\MassAction\Filter', [], [], '', false);
+ $this->filterMock->expects($this->once())
+ ->method('getCollection')
+ ->with($this->orderCollectionMock)
+ ->willReturn($this->orderCollectionMock);
+ $this->orderCollectionFactoryMock->expects($this->once())
+ ->method('create')
+ ->willReturn($this->orderCollectionMock);
$this->massAction = $objectManagerHelper->getObject(
'Magento\Sales\Controller\Adminhtml\Order\MassUnhold',
[
'context' => $this->contextMock,
+ 'filter' => $this->filterMock,
+ 'collectionFactory' => $this->orderCollectionFactoryMock
]
);
}
- public function testExecuteTwoOrdersReleasedFromHold()
+ public function testExecuteOneOrdersReleasedFromHold()
{
- $selected = [1, 2];
- $countOrders = count($selected);
-
$order1 = $this->getMockBuilder('Magento\Sales\Model\Order')
->disableOriginalConstructor()
->getMock();
@@ -202,41 +177,23 @@ public function testExecuteTwoOrdersReleasedFromHold()
->disableOriginalConstructor()
->getMock();
- $this->requestMock->expects($this->at(0))
- ->method('getParam')
- ->with('selected')
- ->willReturn($selected);
-
- $this->requestMock->expects($this->at(1))
- ->method('getParam')
- ->with('excluded')
- ->willReturn([]);
+ $orders = [$order1, $order2];
- $this->objectManagerMock->expects($this->once())
- ->method('create')
- ->with('Magento\Sales\Model\Resource\Order\Collection')
- ->willReturn($this->orderCollectionMock);
- $this->orderCollectionMock->expects($this->once())
- ->method('addFieldToFilter')
- ->with(\Magento\Sales\Controller\Adminhtml\Order\MassCancel::ID_FIELD, ['in' => $selected]);
$this->orderCollectionMock->expects($this->any())
->method('getItems')
- ->willReturn([$order1, $order2]);
-
- $this->orderManagement->expects($this->once())
- ->method('unHold')
- ->with(1);
+ ->willReturn($orders);
$order1->expects($this->once())
->method('canUnhold')
->willReturn(true);
$order1->expects($this->once())
- ->method('getEntityId')
- ->willReturn(1);
+ ->method('unhold');
+ $order1->expects($this->once())
+ ->method('save');
$this->orderCollectionMock->expects($this->once())
->method('count')
- ->willReturn($countOrders);
+ ->willReturn(count($orders));
$order2->expects($this->once())
->method('canUnhold')
@@ -258,11 +215,8 @@ public function testExecuteTwoOrdersReleasedFromHold()
$this->massAction->execute();
}
- public function testExecuteOneOrderWhereNotReleasedFromHold()
+ public function testExecuteNoReleasedOrderFromHold()
{
- $excluded = [1, 2];
- $countOrders = count($excluded);
-
$order1 = $this->getMockBuilder('Magento\Sales\Model\Order')
->disableOriginalConstructor()
->getMock();
@@ -270,26 +224,11 @@ public function testExecuteOneOrderWhereNotReleasedFromHold()
->disableOriginalConstructor()
->getMock();
- $this->requestMock->expects($this->at(0))
- ->method('getParam')
- ->with('selected')
- ->willReturn([]);
+ $orders = [$order1, $order2];
- $this->requestMock->expects($this->at(1))
- ->method('getParam')
- ->with('excluded')
- ->willReturn($excluded);
-
- $this->objectManagerMock->expects($this->once())
- ->method('create')
- ->with('Magento\Sales\Model\Resource\Order\Collection')
- ->willReturn($this->orderCollectionMock);
- $this->orderCollectionMock->expects($this->once())
- ->method('addFieldToFilter')
- ->with(\Magento\Sales\Controller\Adminhtml\Order\MassCancel::ID_FIELD, ['nin' => $excluded]);
$this->orderCollectionMock->expects($this->any())
->method('getItems')
- ->willReturn([$order1, $order2]);
+ ->willReturn($orders);
$order1->expects($this->once())
->method('canUnhold')
@@ -297,7 +236,7 @@ public function testExecuteOneOrderWhereNotReleasedFromHold()
$this->orderCollectionMock->expects($this->once())
->method('count')
- ->willReturn($countOrders);
+ ->willReturn(count($orders));
$order2->expects($this->once())
->method('canUnhold')
diff --git a/app/code/Magento/Sales/Test/Unit/Controller/Adminhtml/Order/ReviewPaymentTest.php b/app/code/Magento/Sales/Test/Unit/Controller/Adminhtml/Order/ReviewPaymentTest.php
index 1f53e7b02b597..866c083c049a9 100755
--- a/app/code/Magento/Sales/Test/Unit/Controller/Adminhtml/Order/ReviewPaymentTest.php
+++ b/app/code/Magento/Sales/Test/Unit/Controller/Adminhtml/Order/ReviewPaymentTest.php
@@ -18,10 +18,7 @@ class ReviewPaymentTest extends \PHPUnit_Framework_TestCase
/** @var \Magento\Backend\App\Action\Context| \PHPUnit_Framework_MockObject_MockObject */
protected $contextMock;
- /** @var \Magento\Framework\ObjectManager\ObjectManager|\PHPUnit_Framework_MockObject_MockObject */
- protected $objectManagerMock;
-
- /** @var \Magento\Sales\Model\Order |\PHPUnit_Framework_MockObject_MockObject */
+ /** @var \Magento\Sales\Api\Data\OrderInterface|\PHPUnit_Framework_MockObject_MockObject */
protected $orderMock;
/** @var \Magento\Backend\Model\View\Result\RedirectFactory | \PHPUnit_Framework_MockObject_MockObject*/
@@ -39,6 +36,21 @@ class ReviewPaymentTest extends \PHPUnit_Framework_TestCase
/** @var \Magento\Framework\Message\Manager|\PHPUnit_Framework_MockObject_MockObject */
protected $messageManagerMock;
+ /**
+ * @var \Magento\Sales\Api\OrderManagementInterface|\PHPUnit_Framework_MockObject_MockObject
+ */
+ protected $orderManagementMock;
+
+ /**
+ * @var \Magento\Sales\Api\OrderRepositoryInterface|\PHPUnit_Framework_MockObject_MockObject
+ */
+ protected $orderRepositoryMock;
+
+ /**
+ * @var \Psr\Log\LoggerInterface|\PHPUnit_Framework_MockObject_MockObject
+ */
+ protected $loggerMock;
+
protected function setUp()
{
$this->contextMock = $this->getMock(
@@ -58,7 +70,15 @@ protected function setUp()
'',
false
);
-
+ $this->orderManagementMock = $this->getMockBuilder('Magento\Sales\Api\OrderManagementInterface')
+ ->getMockForAbstractClass();
+ $this->orderRepositoryMock = $this->getMockBuilder('Magento\Sales\Api\OrderRepositoryInterface')
+ ->getMockForAbstractClass();
+ $this->loggerMock = $this->getMockBuilder('Psr\Log\LoggerInterface')
+ ->getMockForAbstractClass();
+ $this->orderMock = $this->getMockBuilder('Magento\Sales\Api\Data\OrderInterface')
+ ->setMethods(['getPayment'])
+ ->getMockForAbstractClass();
$this->messageManagerMock = $this->getMock(
'Magento\Framework\Message\Manager',
['addSuccess', 'addError'],
@@ -83,23 +103,6 @@ protected function setUp()
false
);
- $this->orderMock = $this->getMock(
- 'Magento\Sales\Model\Order',
- ['load', 'getId', 'getPayment', 'save'],
- [],
- '',
- false
- );
-
- $this->objectManagerMock = $this->getMock(
- 'Magento\Framework\ObjectManager\ObjectManager',
- ['create'],
- [],
- '',
- false
- );
-
-
$this->resultRedirectMock = $this->getMock(
'Magento\Backend\Model\View\Result\Redirect',
['setPath'],
@@ -111,8 +114,6 @@ protected function setUp()
$this->requestMock = $this->getMockBuilder('Magento\Framework\App\Request\Http')
->setMethods(['getParam'])
->disableOriginalConstructor()->getMock();
-
- $this->contextMock->expects($this->once())->method('getObjectManager')->willReturn($this->objectManagerMock);
$this->contextMock->expects($this->once())->method('getRequest')->willReturn($this->requestMock);
$this->contextMock->expects($this->once())->method('getMessageManager')->willReturn($this->messageManagerMock);
$this->contextMock->expects($this->once())
@@ -122,7 +123,9 @@ protected function setUp()
$this->reviewPayment = (new \Magento\Framework\TestFramework\Unit\Helper\ObjectManager($this))->getObject(
'Magento\Sales\Controller\Adminhtml\Order\ReviewPayment',
[
- 'context' => $this->contextMock
+ 'context' => $this->contextMock,
+ 'orderManager' => $this->orderManagementMock,
+ 'orderRepository' => $this->orderRepositoryMock
]
);
}
@@ -138,13 +141,17 @@ public function testExecuteUpdateAction()
$this->resultRedirectFactoryMock->expects($this->once())->method('create')
->willReturn($this->resultRedirectMock);
- $this->objectManagerMock->expects($this->once())->method('create')->with('Magento\Sales\Model\Order')
- ->willReturn($this->orderMock);
- $this->orderMock->expects($this->once())->method('load')->with($orderId)->willReturn($this->orderMock);
- $this->orderMock->expects($this->any())->method('getId')->willReturn($orderId);
+ $this->orderRepositoryMock->expects($this->once())
+ ->method('get')
+ ->with($orderId)
+ ->willReturn($this->orderMock);
+ $this->orderMock->expects($this->any())->method('getEntityId')->willReturn($orderId);
$this->orderMock->expects($this->any())->method('getPayment')->willReturn($this->paymentMock);
- $this->orderMock->expects($this->once())->method('save')->willReturnSelf();
+ $this->orderRepositoryMock->expects($this->once())
+ ->method('save')
+ ->with($this->orderMock)
+ ->willReturnSelf();
$this->paymentMock->expects($this->once())->method('update');
$this->paymentMock->expects($this->any())->method('getIsTransactionApproved')->willReturn(true);
diff --git a/app/code/Magento/Sales/Test/Unit/Controller/Adminhtml/Order/ViewTest.php b/app/code/Magento/Sales/Test/Unit/Controller/Adminhtml/Order/ViewTest.php
index b10539c45a0db..3037e323da0ce 100644
--- a/app/code/Magento/Sales/Test/Unit/Controller/Adminhtml/Order/ViewTest.php
+++ b/app/code/Magento/Sales/Test/Unit/Controller/Adminhtml/Order/ViewTest.php
@@ -8,6 +8,7 @@
/**
* @covers \Magento\Sales\Controller\Adminhtml\Order\View
* @SuppressWarnings(PHPMD.CouplingBetweenObjects)
+ * @SuppressWarnings(PHPMD.TooManyFields)
*/
class ViewTest extends \PHPUnit_Framework_TestCase
{
@@ -86,8 +87,24 @@ class ViewTest extends \PHPUnit_Framework_TestCase
*/
protected $loggerMock;
+ /**
+ * @var \Magento\Sales\Api\OrderManagementInterface|\PHPUnit_Framework_MockObject_MockObject
+ */
+ protected $orderManagementMock;
+
+ /**
+ * @var \Magento\Sales\Api\OrderRepositoryInterface|\PHPUnit_Framework_MockObject_MockObject
+ */
+ protected $orderRepositoryMock;
+
public function setUp()
{
+ $this->orderManagementMock = $this->getMockBuilder('Magento\Sales\Api\OrderManagementInterface')
+ ->getMockForAbstractClass();
+ $this->orderRepositoryMock = $this->getMockBuilder('Magento\Sales\Api\OrderRepositoryInterface')
+ ->getMockForAbstractClass();
+ $this->loggerMock = $this->getMockBuilder('Psr\Log\LoggerInterface')
+ ->getMockForAbstractClass();
$this->requestMock = $this->getMockBuilder('Magento\Framework\App\RequestInterface')
->getMock();
$this->objectManagerMock = $this->getMockBuilder('Magento\Framework\ObjectManagerInterface')
@@ -123,8 +140,6 @@ public function setUp()
$this->resultRedirectMock = $this->getMockBuilder('Magento\Backend\Model\View\Result\Redirect')
->disableOriginalConstructor()
->getMock();
- $this->loggerMock = $this->getMockBuilder('Psr\Log\LoggerInterface')
- ->getMock();
$objectManager = new \Magento\Framework\TestFramework\Unit\Helper\ObjectManager($this);
$this->context = $objectManager->getObject(
@@ -143,7 +158,10 @@ public function setUp()
'context' => $this->context,
'coreRegistry' => $this->coreRegistryMock,
'resultPageFactory' => $this->resultPageFactoryMock,
- 'resultRedirectFactory' => $this->resultRedirectFactoryMock
+ 'resultRedirectFactory' => $this->resultRedirectFactoryMock,
+ 'orderManagement' => $this->orderManagementMock,
+ 'orderRepository' => $this->orderRepositoryMock,
+ 'logger' => $this->loggerMock
]
);
}
@@ -167,7 +185,7 @@ public function testExecute()
->method('getTitle')
->willReturn($this->pageTitleMock);
$this->orderMock->expects($this->atLeastOnce())
- ->method('getRealOrderId')
+ ->method('getIncrementId')
->willReturn($id);
$this->pageTitleMock->expects($this->exactly(2))
->method('prepend')
@@ -188,7 +206,18 @@ public function testExecute()
*/
public function testExecuteNoOrder()
{
- $this->initOrder();
+ $orderIdParam = 111;
+
+ $this->requestMock->expects($this->atLeastOnce())
+ ->method('getParam')
+ ->with('order_id')
+ ->willReturn($orderIdParam);
+ $this->orderRepositoryMock->expects($this->once())
+ ->method('get')
+ ->with($orderIdParam)
+ ->willThrowException(
+ new \Magento\Framework\Exception\NoSuchEntityException(__('Requested entity doesn\'t exist'))
+ );
$this->initOrderFail();
$this->prepareRedirect();
$this->setPath('sales/*/');
@@ -213,10 +242,6 @@ public function testGlobalException()
$this->resultPageFactoryMock->expects($this->once())
->method('create')
->willThrowException($exception);
- $this->objectManagerMock->expects($this->once())
- ->method('get')
- ->with('Psr\Log\LoggerInterface')
- ->willReturn($this->loggerMock);
$this->loggerMock->expects($this->once())
->method('critical')
->with($exception);
@@ -240,24 +265,17 @@ protected function initOrder()
->method('getParam')
->with('order_id')
->willReturn($orderIdParam);
- $this->objectManagerMock->expects($this->once())
- ->method('create')
- ->with('Magento\Sales\Model\Order')
- ->willReturn($this->orderMock);
- $this->orderMock->expects($this->once())
- ->method('load')
+ $this->orderRepositoryMock->expects($this->once())
+ ->method('get')
->with($orderIdParam)
- ->willReturnSelf();
+ ->willReturn($this->orderMock);
}
/**
- * @param int $orderId
+ * init Order Success
*/
- protected function initOrderSuccess($orderId)
+ protected function initOrderSuccess()
{
- $this->orderMock->expects($this->atLeastOnce())
- ->method('getId')
- ->willReturn($orderId);
$this->coreRegistryMock->expects($this->exactly(2))
->method('register')
->withConsecutive(
@@ -268,9 +286,6 @@ protected function initOrderSuccess($orderId)
protected function initOrderFail()
{
- $this->orderMock->expects($this->atLeastOnce())
- ->method('getId')
- ->willReturn(null);
$this->messageManagerMock->expects($this->once())
->method('addError')
->with('This order no longer exists.')
diff --git a/app/code/Magento/Sales/Test/Unit/Helper/ReorderTest.php b/app/code/Magento/Sales/Test/Unit/Helper/ReorderTest.php
index 0c46eb0207282..d67ae1d63a08f 100644
--- a/app/code/Magento/Sales/Test/Unit/Helper/ReorderTest.php
+++ b/app/code/Magento/Sales/Test/Unit/Helper/ReorderTest.php
@@ -35,6 +35,11 @@ class ReorderTest extends \PHPUnit_Framework_TestCase
*/
protected $customerSessionMock;
+ /**
+ * @var \Magento\Sales\Api\OrderRepositoryInterface|\PHPUnit_Framework_MockObject_MockObject
+ */
+ protected $repositoryMock;
+
/**
* @return void
*/
@@ -55,9 +60,12 @@ protected function setUp()
->disableOriginalConstructor()
->getMock();
+ $this->repositoryMock = $this->getMockBuilder('Magento\Sales\Api\OrderRepositoryInterface')
+ ->getMockForAbstractClass();
$this->helper = new \Magento\Sales\Helper\Reorder(
$contextMock,
- $this->customerSessionMock
+ $this->customerSessionMock,
+ $this->repositoryMock
);
$this->storeParam = $this->getMockBuilder('Magento\Sales\Model\Store')
@@ -131,7 +139,11 @@ protected function setupScopeConfigMock($returnValue)
public function testCanReorderStoreNotAllowed()
{
$this->setupOrderMock(false);
- $this->assertFalse($this->helper->canReorder($this->orderMock));
+ $this->repositoryMock->expects($this->once())
+ ->method('get')
+ ->with(1)
+ ->willReturn($this->orderMock);
+ $this->assertFalse($this->helper->canReorder(1));
}
/**
@@ -146,8 +158,11 @@ public function testCanReorderCustomerNotLoggedIn()
$this->customerSessionMock->expects($this->once())
->method('isLoggedIn')
->will($this->returnValue(false));
-
- $this->assertTrue($this->helper->canReorder($this->orderMock));
+ $this->repositoryMock->expects($this->once())
+ ->method('get')
+ ->with(1)
+ ->willReturn($this->orderMock);
+ $this->assertTrue($this->helper->canReorder(1));
}
/**
@@ -168,8 +183,11 @@ public function testCanReorderCustomerLoggedInAndOrderCanReorder($orderCanReorde
$this->orderMock->expects($this->once())
->method('canReorder')
->will($this->returnValue($orderCanReorder));
-
- $this->assertEquals($orderCanReorder, $this->helper->canReorder($this->orderMock));
+ $this->repositoryMock->expects($this->once())
+ ->method('get')
+ ->with(1)
+ ->willReturn($this->orderMock);
+ $this->assertEquals($orderCanReorder, $this->helper->canReorder(1));
}
/**
diff --git a/app/code/Magento/Sales/Test/Unit/Model/Order/Customer/BuilderTest.php b/app/code/Magento/Sales/Test/Unit/Model/Order/Customer/BuilderTest.php
deleted file mode 100644
index b7d3ac881228f..0000000000000
--- a/app/code/Magento/Sales/Test/Unit/Model/Order/Customer/BuilderTest.php
+++ /dev/null
@@ -1,160 +0,0 @@
-objectManagerMock = $this->getMock('Magento\Framework\ObjectManagerInterface');
-
- $this->builder = new \Magento\Sales\Model\Order\Customer\Builder($this->objectManagerMock);
- }
-
- /**
- * Run test setDob method
- */
- public function testSetDob()
- {
- $this->assertEquals($this->builder, $this->builder->setDob('dob'));
- }
-
- /**
- * Run test setEmail method
- */
- public function testSetEmail()
- {
- $this->assertEquals($this->builder, $this->builder->setEmail('email'));
- }
-
- /**
- * Run test setFirstName method
- */
- public function testSetFirstName()
- {
- $this->assertEquals($this->builder, $this->builder->setFirstName('first_name'));
- }
-
- /**
- * Run test setGender method
- */
- public function testSetGender()
- {
- $this->assertEquals($this->builder, $this->builder->setGender('gender'));
- }
-
- /**
- * Run test setGroupId method
- */
- public function testSetGroupId()
- {
- $this->assertEquals($this->builder, $this->builder->setGroupId('group_id'));
- }
-
- /**
- * Run test setId method
- */
- public function testSetId()
- {
- $this->assertEquals($this->builder, $this->builder->setId('id'));
- }
-
- /**
- * Run test setIsGuest method
- */
- public function testSetIsGuest()
- {
- $this->assertEquals($this->builder, $this->builder->setIsGuest('is_guest'));
- }
-
- /**
- * Run test setLastName method
- */
- public function testSetLastName()
- {
- $this->assertEquals($this->builder, $this->builder->setLastName('last_name'));
- }
-
- /**
- * Run test setMiddleName method
- */
- public function testSetMiddleName()
- {
- $this->assertEquals($this->builder, $this->builder->setMiddleName('middle_name'));
- }
-
- /**
- * Run test setNote method
- */
- public function testSetNote()
- {
- $this->assertEquals($this->builder, $this->builder->setNote('note'));
- }
-
- /**
- * Run test setNoteNotify method
- */
- public function testSetNoteNotify()
- {
- $this->assertEquals($this->builder, $this->builder->setNoteNotify('note_notify'));
- }
-
- /**
- * Run test setPrefix method
- */
- public function testSetPrefix()
- {
- $this->assertEquals($this->builder, $this->builder->setPrefix('prefix'));
- }
-
- /**
- * Run test setSuffix method
- */
- public function testSetSuffix()
- {
- $this->assertEquals($this->builder, $this->builder->setSuffix('suffix'));
- }
-
- /**
- * Run test setTaxvat method
- */
- public function testSetTaxvat()
- {
- $this->assertEquals($this->builder, $this->builder->setTaxvat('taxvat'));
- }
-
- /**
- * Run test create method
- */
- public function testCreate()
- {
- $customerMock = $this->getMock(
- 'Magento\Sales\Model\Order\Customer',
- [],
- [],
- '',
- false
- );
- $this->objectManagerMock->expects($this->once())
- ->method('create')
- ->will($this->returnValue($customerMock));
-
- $this->assertEquals($customerMock, $this->builder->create());
- }
-}
diff --git a/app/code/Magento/Sales/Test/Unit/Model/Order/Customer/ManagementTest.php b/app/code/Magento/Sales/Test/Unit/Model/Order/CustomerManagementTest.php
similarity index 96%
rename from app/code/Magento/Sales/Test/Unit/Model/Order/Customer/ManagementTest.php
rename to app/code/Magento/Sales/Test/Unit/Model/Order/CustomerManagementTest.php
index f7f64f25d4127..62ab12af42dda 100644
--- a/app/code/Magento/Sales/Test/Unit/Model/Order/Customer/ManagementTest.php
+++ b/app/code/Magento/Sales/Test/Unit/Model/Order/CustomerManagementTest.php
@@ -3,12 +3,12 @@
* Copyright © 2015 Magento. All rights reserved.
* See COPYING.txt for license details.
*/
-namespace Magento\Sales\Test\Unit\Model\Order\Customer;
+namespace Magento\Sales\Test\Unit\Model\Order;
/**
* Class BuilderTest
*/
-class ManagementTest extends \PHPUnit_Framework_TestCase
+class CustomerManagementTest extends \PHPUnit_Framework_TestCase
{
/**
* @var \PHPUnit_Framework_MockObject_MockObject
@@ -41,7 +41,7 @@ class ManagementTest extends \PHPUnit_Framework_TestCase
protected $regionFactory;
/**
- * @var \Magento\Sales\Model\Order\Customer\Management
+ * @var \Magento\Sales\Model\Order\CustomerManagement
*/
protected $service;
@@ -72,7 +72,7 @@ protected function setUp()
);
$this->orderRepository = $this->getMock('\Magento\Sales\Api\OrderRepositoryInterface');
- $this->service = new \Magento\Sales\Model\Order\Customer\Management(
+ $this->service = new \Magento\Sales\Model\Order\CustomerManagement(
$this->objectCopyService,
$this->accountManagement,
$this->customerFactory,
diff --git a/app/code/Magento/Sales/Test/Unit/Model/Order/CustomerTest.php b/app/code/Magento/Sales/Test/Unit/Model/Order/CustomerTest.php
deleted file mode 100644
index 938d894805101..0000000000000
--- a/app/code/Magento/Sales/Test/Unit/Model/Order/CustomerTest.php
+++ /dev/null
@@ -1,247 +0,0 @@
-objectManager = new \Magento\Framework\TestFramework\Unit\Helper\ObjectManager($this);
- }
-
- /**
- * Run test getDob method
- *
- * @param array $parameters
- * @dataProvider providerCustomerData
- */
- public function testGetDob(array $parameters)
- {
- /** @var \Magento\Sales\Model\Order\Customer $customer */
- $customer = $this->objectManager->getObject('Magento\Sales\Model\Order\Customer', $parameters);
-
- $this->assertEquals($parameters['customerDob'], $customer->getDob());
- }
-
- /**
- * Run test getEmail method
- *
- * @param array $parameters
- * @dataProvider providerCustomerData
- */
- public function testGetEmail(array $parameters)
- {
- /** @var \Magento\Sales\Model\Order\Customer $customer */
- $customer = $this->objectManager->getObject('Magento\Sales\Model\Order\Customer', $parameters);
-
- $this->assertEquals($parameters['customerEmail'], $customer->getEmail());
- }
-
- /**
- * Run test getFirstName method
- *
- * @param array $parameters
- * @dataProvider providerCustomerData
- */
- public function testGetFirstName(array $parameters)
- {
- /** @var \Magento\Sales\Model\Order\Customer $customer */
- $customer = $this->objectManager->getObject('Magento\Sales\Model\Order\Customer', $parameters);
-
- $this->assertEquals($parameters['customerFirstName'], $customer->getFirstName());
- }
-
- /**
- * Run test getGender method
- *
- * @param array $parameters
- * @dataProvider providerCustomerData
- */
- public function testGetGender(array $parameters)
- {
- /** @var \Magento\Sales\Model\Order\Customer $customer */
- $customer = $this->objectManager->getObject('Magento\Sales\Model\Order\Customer', $parameters);
-
- $this->assertEquals($parameters['customerGender'], $customer->getGender());
- }
-
- /**
- * Run test getGroupId method
- *
- * @param array $parameters
- * @dataProvider providerCustomerData
- */
- public function testGetGroupId(array $parameters)
- {
- /** @var \Magento\Sales\Model\Order\Customer $customer */
- $customer = $this->objectManager->getObject('Magento\Sales\Model\Order\Customer', $parameters);
-
- $this->assertEquals($parameters['customerGroupId'], $customer->getGroupId());
- }
-
- /**
- * Run test getId method
- *
- * @param array $parameters
- * @dataProvider providerCustomerData
- */
- public function testGetId(array $parameters)
- {
- /** @var \Magento\Sales\Model\Order\Customer $customer */
- $customer = $this->objectManager->getObject('Magento\Sales\Model\Order\Customer', $parameters);
-
- $this->assertEquals($parameters['customerId'], $customer->getId());
- }
-
- /**
- * Run test getIsGuest method
- *
- * @param array $parameters
- * @dataProvider providerCustomerData
- */
- public function testGetIsGuest(array $parameters)
- {
- /** @var \Magento\Sales\Model\Order\Customer $customer */
- $customer = $this->objectManager->getObject('Magento\Sales\Model\Order\Customer', $parameters);
-
- $this->assertEquals($parameters['customerIsGuest'], $customer->getIsGuest());
- }
-
- /**
- * Run test getLastName method
- *
- * @param array $parameters
- * @dataProvider providerCustomerData
- */
- public function testGetLastName(array $parameters)
- {
- /** @var \Magento\Sales\Model\Order\Customer $customer */
- $customer = $this->objectManager->getObject('Magento\Sales\Model\Order\Customer', $parameters);
-
- $this->assertEquals($parameters['customerLastName'], $customer->getLastName());
- }
-
- /**
- * Run test getMiddleName method
- *
- * @param array $parameters
- * @dataProvider providerCustomerData
- */
- public function testGetMiddleName(array $parameters)
- {
- /** @var \Magento\Sales\Model\Order\Customer $customer */
- $customer = $this->objectManager->getObject('Magento\Sales\Model\Order\Customer', $parameters);
-
- $this->assertEquals($parameters['customerMiddleName'], $customer->getMiddleName());
- }
-
- /**
- * Run test getNote method
- *
- * @param array $parameters
- * @dataProvider providerCustomerData
- */
- public function testGetNote(array $parameters)
- {
- /** @var \Magento\Sales\Model\Order\Customer $customer */
- $customer = $this->objectManager->getObject('Magento\Sales\Model\Order\Customer', $parameters);
-
- $this->assertEquals($parameters['customerNote'], $customer->getNote());
- }
-
- /**
- * Run test getNoteNotify method
- *
- * @param array $parameters
- * @dataProvider providerCustomerData
- */
- public function testGetNoteNotify(array $parameters)
- {
- /** @var \Magento\Sales\Model\Order\Customer $customer */
- $customer = $this->objectManager->getObject('Magento\Sales\Model\Order\Customer', $parameters);
-
- $this->assertEquals($parameters['customerNoteNotify'], $customer->getNoteNotify());
- }
-
- /**
- * Run test getPrefix method
- *
- * @param array $parameters
- * @dataProvider providerCustomerData
- */
- public function testGetPrefix(array $parameters)
- {
- /** @var \Magento\Sales\Model\Order\Customer $customer */
- $customer = $this->objectManager->getObject('Magento\Sales\Model\Order\Customer', $parameters);
-
- $this->assertEquals($parameters['customerPrefix'], $customer->getPrefix());
- }
-
- /**
- * Run test getSuffix method
- *
- * @param array $parameters
- * @dataProvider providerCustomerData
- */
- public function testGetSuffix(array $parameters)
- {
- /** @var \Magento\Sales\Model\Order\Customer $customer */
- $customer = $this->objectManager->getObject('Magento\Sales\Model\Order\Customer', $parameters);
-
- $this->assertEquals($parameters['customerSuffix'], $customer->getSuffix());
- }
-
- /**
- * Run test getTaxvat method
- *
- * @param array $parameters
- * @dataProvider providerCustomerData
- */
- public function testGetTaxvat(array $parameters)
- {
- /** @var \Magento\Sales\Model\Order\Customer $customer */
- $customer = $this->objectManager->getObject('Magento\Sales\Model\Order\Customer', $parameters);
-
- $this->assertEquals($parameters['customerTaxvat'], $customer->getTaxvat());
- }
-
- /**
- * Data to insert into constructor of the test object
- *
- * @return array
- */
- public function providerCustomerData()
- {
- return [
- [
- [
- 'customerDob' => 'customer_dob',
- 'customerEmail' => 'customer_email',
- 'customerFirstName' => 'customer_first_name',
- 'customerGender' => 'customer_gender',
- 'customerGroupId' => 'customer_group_id',
- 'customerId' => 'customer_id',
- 'customerIsGuest' => 'customer_is_guest',
- 'customerLastName' => 'customer_last_name',
- 'customerMiddleName' => 'customer_middle_name',
- 'customerNote' => 'customer_note',
- 'customerNoteNotify' => 'customer_note_notify',
- 'customerPrefix' => 'customer_prefix',
- 'customerSuffix' => 'customer_suffix',
- 'customerTaxvat' => 'customer_taxvat',
- ],
- ]
- ];
- }
-}
diff --git a/app/code/Magento/Sales/Test/Unit/Model/Order/DataProviderTest,php b/app/code/Magento/Sales/Test/Unit/Model/Order/DataProviderTest,php
deleted file mode 100644
index d16ed34395e13..0000000000000
--- a/app/code/Magento/Sales/Test/Unit/Model/Order/DataProviderTest,php
+++ /dev/null
@@ -1,206 +0,0 @@
-collectionFactoryMock = $this->getMockBuilder(
- 'Magento\Sales\Model\Resource\Order\Grid\CollectionFactory'
- )
- ->disableOriginalConstructor()
- ->setMethods(['create'])
- ->getMock();
- $this->collectionMock = $this->getMockBuilder('Magento\Sales\Model\Resource\Order\Grid\Collection')
- ->disableOriginalConstructor()
- ->getMock();
-
- $this->collectionFactoryMock->expects($this->once())
- ->method('create')
- ->willReturn($this->collectionMock);
-
- $this->dataProvider = new \Magento\Sales\Model\Order\DataProvider(
- 'data-provider-name',
- 'entity_id',
- 'entity_id',
- $this->collectionFactoryMock,
- [
- 'fieldSet' => [
- 'fields' => [
- 'field' => null
- ]
- ]
- ],
- [
- 'config' => []
- ]
- );
- }
-
- public function testGetName()
- {
- $this->assertEquals($this->dataProvider->getName(), 'data-provider-name');
- }
-
- public function testGetPrimaryFieldName()
- {
- $this->assertEquals($this->dataProvider->getPrimaryFieldName(), 'entity_id');
- }
-
- public function testGetRequestFieldName()
- {
- $this->assertEquals($this->dataProvider->getRequestFieldName(), 'entity_id');
- }
-
- public function testGetMeta()
- {
- $this->assertEquals(
- $this->dataProvider->getMeta(),
- [
- 'fieldSet' => [
- 'fields' => [
- 'field' => null
- ]
- ]
- ]
- );
- }
-
- public function testGetFieldSetMetaInfo()
- {
- $this->assertEquals(
- $this->dataProvider->getFieldSetMetaInfo('fieldSet'),
- [
- 'fields' => [
- 'field' => null
- ]
- ]
- );
- }
-
- public function testGetFieldsMetaInfo()
- {
- $this->assertEquals(
- $this->dataProvider->getFieldsMetaInfo('fieldSet'),
- [
- 'field' => null
- ]
- );
- }
-
- public function testGetFieldMetaInfo()
- {
- $this->assertEquals(
- $this->dataProvider->getFieldMetaInfo('fieldSet', 'field'),
- []
- );
- }
-
- public function testAddFilter()
- {
- $this->collectionMock->expects($this->once())
- ->method('addFieldToFilter')
- ->with('field', ['condition' => 1])
- ->willReturnSelf();
- $this->dataProvider->addFilter('field', ['condition' => 1]);
- }
-
- public function testAddField()
- {
- $this->collectionMock->expects($this->once())
- ->method('addFieldToSelect')
- ->with('field', 'alias')
- ->willReturnSelf();
- $this->dataProvider->addField('field', 'alias');
- }
-
- public function testAddOrder()
- {
- $this->collectionMock->expects($this->once())
- ->method('addOrder')
- ->with('field', 'DESC')
- ->willReturnSelf();
- $this->dataProvider->addOrder('field', 'DESC');
- }
-
- public function testSetLimit()
- {
- $this->collectionMock->expects($this->once())
- ->method('setPageSize')
- ->with(10)
- ->willReturnSelf();
- $this->collectionMock->expects($this->once())
- ->method('setCurPage')
- ->with(10)
- ->willReturnSelf();
- $this->dataProvider->setLimit(10, 10);
- }
-
- public function testRemoveField()
- {
- $this->collectionMock->expects($this->once())
- ->method('removeFieldFromSelect')
- ->with('field', 'alias')
- ->willReturnSelf();
- $this->dataProvider->removeField('field', 'alias');
- }
-
- public function testRemoveAllFields()
- {
- $this->collectionMock->expects($this->once())
- ->method('removeAllFieldsFromSelect')
- ->willReturnSelf();
- $this->dataProvider->removeAllFields();
- }
-
- public function testGetData()
- {
- $this->collectionMock->expects($this->once())
- ->method('toArray')
- ->willReturn(['data' => 'data']);
- $this->assertEquals(
- $this->dataProvider->getData(),
- ['data' => 'data']
- );
- }
-
- public function testCount()
- {
- $this->collectionMock->expects($this->once())
- ->method('count')
- ->willReturn(1);
- $this->assertEquals(1, $this->dataProvider->count());
- }
-
- public function testGetConfigData()
- {
- $this->assertEquals(
- [],
- $this->dataProvider->getConfigData()
- );
- }
-}
diff --git a/app/code/Magento/Sales/etc/di.xml b/app/code/Magento/Sales/etc/di.xml
index 48b8ace07b2a3..adaeb021711d2 100755
--- a/app/code/Magento/Sales/etc/di.xml
+++ b/app/code/Magento/Sales/etc/di.xml
@@ -466,61 +466,104 @@
-
+
- - sales_order.customer_firstname
- - sales_order.customer_lastname
+ -
+
- sales_order
+ - customer_firstname
+
+ -
+
- sales_order
+ - customer_lastname
+
-
+
- - sales_shipping_address.firstname
- - sales_shipping_address.lastname
+ -
+
- sales_shipping_address
+ - firstname
+
+ -
+
- sales_shipping_address
+ - lastname
+
-
+
- - sales_billing_address.firstname
- - sales_billing_address.lastname
+ -
+
- sales_billing_address
+ - firstname
+
+ -
+
- sales_billing_address
+ - lastname
+
-
+
- - sales_shipping_address.street
- - sales_shipping_address.city
- - sales_shipping_address.region
- - sales_shipping_address.postcode
+ -
+
- sales_shipping_address
+ - street
+
+ -
+
- sales_shipping_address
+ - city
+
+ -
+
- sales_shipping_address
+ - region
+
+ -
+
- sales_shipping_address
+ - postcode
+
,
-
+
- - sales_billing_address.street
- - sales_billing_address.city
- - sales_billing_address.region
- - sales_billing_address.postcode
+ -
+
- sales_billing_address
+ - street
+
+ -
+
- sales_billing_address
+ - city
+
+ -
+
- sales_billing_address
+ - region
+
+ -
+
- sales_billing_address
+ - postcode
+
,
-
+
- sales_read
- sales_order_payment
-
- - method
+ sales_order_payment
+ method
+
+ -
+
- sales_order
+ - entity_id
+
- parent_id
- sales_order.entity_id
@@ -533,43 +576,74 @@
-
+
- Magento\Framework\View\Element\UiComponent\DataProvider\RegularFilter
- Magento\Framework\View\Element\UiComponent\DataProvider\FulltextFilter
+
+
+
+
+ - Magento\Sales\Model\Resource\Order\Grid\Collection
+ - Magento\Sales\Model\Resource\Order\Invoice\Grid\Collection
+ - Magento\Sales\Model\Resource\Order\Shipment\Grid\Collection
+ - Magento\Sales\Model\Resource\Order\Creditmemo\Grid\Collection
+ - Magento\Sales\Model\Resource\Order\Invoice\Orders\Grid\Collection
+ - Magento\Sales\Model\Resource\Order\Shipment\Order\Grid\Collection
+ - Magento\Sales\Model\Resource\Order\Creditmemo\Order\Grid\Collection
+
+
+
+
+
+ Magento\Framework\App\State\Proxy
+
+
+
+
+ sales_order_grid
+ Magento\Sales\Model\Resource\Order
+
-
+
- Magento\Sales\Model\Resource\Order\Grid\Collection
- SalesGirdFilterPool
+ sales_invoice_grid
+ Magento\Sales\Model\Resource\Order\Invoice
-
+
- Magento\Sales\Model\Resource\Order\Invoice\Grid\Collection
- SalesGirdFilterPool
+ sales_shipment_grid
+ Magento\Sales\Model\Resource\Order\Shipment
-
+
- Magento\Sales\Model\Resource\Order\Shipment\Grid\Collection
- SalesGirdFilterPool
+ sales_creditmemo_grid
+ Magento\Sales\Model\Resource\Order\Creditmemo
-
+
- Magento\Sales\Model\Resource\Order\Creditmemo\Grid\Collection
- SalesGirdFilterPool
+ sales_invoice_grid
+ Magento\Sales\Model\Resource\Order\Invoice
-
+
- Magento\Framework\App\State\Proxy
+ sales_shipment_grid
+ Magento\Sales\Model\Resource\Order\Shipment
-
+
+
+
+ sales_creditmemo_grid
+ Magento\Sales\Model\Resource\Order\Creditmemo
+
+
Magento\Sales\Model\Resource\Order
diff --git a/app/code/Magento/Sales/view/adminhtml/layout/sales_creditmemo_grid_block.xml b/app/code/Magento/Sales/view/adminhtml/layout/sales_creditmemo_grid_block.xml
deleted file mode 100644
index e4cb20d646cbe..0000000000000
--- a/app/code/Magento/Sales/view/adminhtml/layout/sales_creditmemo_grid_block.xml
+++ /dev/null
@@ -1,158 +0,0 @@
-
-
-
-
-
-
-
- sales_creditmemo_grid
- Magento\Sales\Model\Resource\Order\Creditmemo\Grid\Collection
- true
- created_at
- DESC
-
- 1
-
-
-
-
- entity_id
- creditmemo_ids
- false
-
- -
-
- PDF Credit Memos
- - sales/creditmemo/pdfcreditmemos
-
-
-
-
-
-
-
- -
-
- */*/exportCsv
- - CSV
-
- -
-
- */*/exportExcel
- - Excel XML
-
-
-
-
-
-
- sales_creditmemo_grid
-
- - Magento\Sales\Model\Order\Grid\Row\UrlGenerator
- - sales/creditmemo/view
- -
-
- getId
-
-
-
-
-
- Credit Memo
- text
- increment_id
- real_creditmemo_id
- col-memo-number
- col-memo-number
-
-
-
-
- Created
- datetime
- created_at
- created_at
- col-period
- col-period
-
-
-
-
- Order
- text
- order_increment_id
- order_increment_id
- col-order-number
- col-order-number
-
-
-
-
- Order Date
- datetime
- order_created_at
- order_created_at
- col-period
- col-period
-
-
-
-
- billing_name
- Bill-to Name
- billing_name
- col-bill-to-name
- col-bill-to-name
-
-
-
-
- state
- Status
- options
- state
-
- col-status
- col-status
-
-
-
-
- base_grand_total
- Refunded
- currency
- order_currency_code
- 1
- base_grand_total
- col-refunded
- col-refunded
-
-
-
-
- action
- Action
- action
- getId
- false
- false
- true
-
- -
-
- View
- -
-
- sales/creditmemo/view
-
- - creditmemo_id
-
-
- col-actions
- col-actions
-
-
-
-
-
-
-
diff --git a/app/code/Magento/Sales/view/adminhtml/layout/sales_invoice_grid_block.xml b/app/code/Magento/Sales/view/adminhtml/layout/sales_invoice_grid_block.xml
deleted file mode 100644
index 2525c2c4c1430..0000000000000
--- a/app/code/Magento/Sales/view/adminhtml/layout/sales_invoice_grid_block.xml
+++ /dev/null
@@ -1,159 +0,0 @@
-
-
-
-
-
-
-
- sales_invoice_grid
- Magento\Sales\Model\Resource\Order\Invoice\Grid\Collection
- true
- created_at
- DESC
- true
-
- 1
-
-
-
-
- entity_id
- invoice_ids
- false
-
- -
-
- PDF Invoices
- - sales/invoice/pdfinvoices
-
-
-
-
-
-
-
- -
-
- */*/exportCsv
- - CSV
-
- -
-
- */*/exportExcel
- - Excel XML
-
-
-
-
-
-
- sales_invoice_grid
-
- - Magento\Sales\Model\Order\Invoice\Grid\Row\UrlGenerator
- - sales/invoice/view
- -
-
- getId
-
-
-
-
-
- Invoice
- text
- increment_id
- increment_id
- col-invoice-number
- col-invoice-number
-
-
-
-
- Invoice Date
- datetime
- created_at
- created_at
- col-period
- col-period
-
-
-
-
- Order
- text
- order_increment_id
- order_increment_id
- col-order-number
- col-order-number
-
-
-
-
- Order Date
- datetime
- order_created_at
- order_created_at
- col-period
- col-period
-
-
-
-
- billing_name
- Bill-to Name
- billing_name
- col-bill-to-name
- col-bill-to-name
-
-
-
-
- state
- Status
- options
- state
-
- col-status
- col-status
-
-
-
-
- grand_total
- Amount
- currency
- order_currency_code
- grand_total
- col-gtpurchased
- col-gtpurchased
- right
-
-
-
-
- action
- Action
- action
- getId
- false
- false
- true
-
- -
-
- View
- -
-
- sales/invoice/view
-
- - invoice_id
-
-
- col-actions
- col-actions
-
-
-
-
-
-
-
diff --git a/app/code/Magento/Sales/view/adminhtml/layout/sales_order_grid_block.xml b/app/code/Magento/Sales/view/adminhtml/layout/sales_order_grid_block.xml
deleted file mode 100644
index 2af914b40b228..0000000000000
--- a/app/code/Magento/Sales/view/adminhtml/layout/sales_order_grid_block.xml
+++ /dev/null
@@ -1,206 +0,0 @@
-
-
-
-
-
-
-
- sales_order_grid
- Magento\Sales\Model\Resource\Order\Grid\Collection
- true
- created_at
- DESC
- 1
-
- 1
-
-
-
-
- entity_id
- order_ids
- 0
-
- Magento\Sales\Model\Order\Grid\Massaction\ItemsUpdater
- -
-
- Cancel
- - sales/order/massCancel
-
- -
-
- Hold
- - sales/order/massHold
-
- -
-
- Unhold
- - sales/order/massUnhold
-
- -
-
- Print Invoices
- - sales/order/pdfinvoices
-
- -
-
- Print Packing Slips
- - sales/order/pdfshipments
-
- -
-
- Print Credit Memos
- - sales/order/pdfcreditmemos
-
- -
-
- Print All
- - sales/order/pdfdocs
-
- -
-
- Print Shipping Labels
- - adminhtml/order_shipment/massPrintShippingLabel
-
-
-
-
-
-
-
- -
-
- sales/*/exportCsv
- - CSV
-
- -
-
- sales/*/exportExcel
- - Excel XML
-
-
-
-
-
-
- sales_order_grid
-
- - Magento\Sales\Model\Order\Grid\Row\UrlGenerator
- - sales/order/view
- -
-
- getId
-
-
-
-
-
- Order
- text
- increment_id
- real_order_id
- col-order-number
- col-order-number
-
-
-
-
- Purchase Point
- store
- 1
- 1
- store_id
- store_id
- col-from-store
- col-from-store
-
-
-
-
- Purchased
- datetime
- created_at
- created_at
- col-period
- col-period
-
-
-
-
- billing_name
- Bill-to Name
- billing_name
- col-name
- col-name
-
-
-
-
- shipping_name
- Ship-to Name
- shipping_name
- col-name
- col-name
-
-
-
-
- base_grand_total
- Grand Total (Base)
- currency
- base_currency_code
- 1
- base_grand_total
- col-gtbase
- col-gtbase
-
-
-
-
- grand_total
- Grand Total (Purchased)
- currency
- order_currency_code
- 1
- grand_total
- col-gtpurchased
- col-gtpurchased
-
-
-
-
- status
- Status
- options
- order_currency_code
- status
-
- col-status
- col-status
-
-
-
-
- action
- Action
- action
- getId
- 0
- 0
- stores
- 1
-
- -
-
- View
- -
-
- sales/order/view
-
- - order_id
-
-
- col-actions
- col-actions
-
-
-
-
-
-
-
-
-
-
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 f0c99ecaf4464..8702286537943 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
@@ -6,10 +6,7 @@
*/
-->
-
-
-
@@ -75,5 +72,14 @@
+
+
+
+
+
+
+
+
+