diff --git a/app/code/Magento/Cms/Model/Block/DataProvider.php b/app/code/Magento/Cms/Model/Block/DataProvider.php index 61c11908668dff9b2b6bf479dcad651697621c6d..e46e487af7936b67f09afe4430bd6b27e34452a0 100644 --- a/app/code/Magento/Cms/Model/Block/DataProvider.php +++ b/app/code/Magento/Cms/Model/Block/DataProvider.php @@ -8,6 +8,7 @@ namespace Magento\Cms\Model\Block; use Magento\Cms\Model\Resource\Block\Collection; use Magento\Cms\Model\Resource\Block\CollectionFactory; use Magento\Framework\View\Element\UiComponent\DataProvider\DataProviderInterface; +use Magento\Framework\View\Element\UiComponent\DataProvider\FilterPool; /** * Class DataProvider @@ -48,11 +49,17 @@ class DataProvider implements DataProviderInterface */ protected $data = []; + /** + * @var FilterPool + */ + protected $filterPool; + /** * @param string $name * @param string $primaryFieldName * @param string $requestFieldName * @param CollectionFactory $collectionFactory + * @param FilterPool $filterPool * @param array $meta * @param array $data */ @@ -61,6 +68,7 @@ class DataProvider implements DataProviderInterface $primaryFieldName, $requestFieldName, CollectionFactory $collectionFactory, + FilterPool $filterPool, array $meta = [], array $data = [] ) { @@ -68,6 +76,7 @@ class DataProvider implements DataProviderInterface $this->primaryFieldName = $primaryFieldName; $this->requestFieldName = $requestFieldName; $this->collection = $collectionFactory->create(); + $this->filterPool = $filterPool; $this->meta = $meta; $this->data = $data; } @@ -145,9 +154,9 @@ class DataProvider implements DataProviderInterface /** * @inheritdoc */ - public function addFilter($field, $condition = null) + public function addFilter($condition, $field = null, $type = 'regular') { - $this->collection->addFieldToFilter($field, $condition); + $this->filterPool->registerNewFilter($condition, $field, $type); } /** @@ -216,6 +225,7 @@ class DataProvider implements DataProviderInterface */ public function getData() { + $this->filterPool->applyFilters($this->collection); return $this->collection->toArray(); } @@ -226,6 +236,7 @@ class DataProvider implements DataProviderInterface */ 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 index cc3bbf6750caa3820ec1aee59db8322c89c24e87..7fc1177c90cb7bf8638a91f22f944d44612b1634 100644 --- a/app/code/Magento/Cms/Model/Page/DataProvider.php +++ b/app/code/Magento/Cms/Model/Page/DataProvider.php @@ -8,6 +8,7 @@ namespace Magento\Cms\Model\Page; use Magento\Cms\Model\Resource\Page\Collection; use Magento\Cms\Model\Resource\Page\CollectionFactory; use Magento\Framework\View\Element\UiComponent\DataProvider\DataProviderInterface; +use Magento\Framework\View\Element\UiComponent\DataProvider\FilterPool; /** * Class DataProvider @@ -57,11 +58,17 @@ class DataProvider implements DataProviderInterface */ protected $data = []; + /** + * @var FilterPool + */ + protected $filterPool; + /** * @param string $name * @param string $primaryFieldName * @param string $requestFieldName * @param CollectionFactory $collectionFactory + * @param FilterPool $filterPool * @param array $meta * @param array $data */ @@ -70,13 +77,14 @@ class DataProvider implements DataProviderInterface $primaryFieldName, $requestFieldName, CollectionFactory $collectionFactory, + FilterPool $filterPool, array $meta = [], array $data = [] ) { $this->name = $name; $this->primaryFieldName = $primaryFieldName; $this->requestFieldName = $requestFieldName; - + $this->filterPool = $filterPool; $this->collection = $collectionFactory->create(); $this->collection->setFirstStoreFlag(true); $this->meta = $meta; @@ -156,9 +164,9 @@ class DataProvider implements DataProviderInterface /** * @inheritdoc */ - public function addFilter($field, $condition = null) + public function addFilter($condition, $field = null, $type = 'regular') { - $this->collection->addFieldToFilter($field, $condition); + $this->filterPool->registerNewFilter($condition, $field, $type); } /** @@ -227,6 +235,7 @@ class DataProvider implements DataProviderInterface */ public function getData() { + $this->filterPool->applyFilters($this->collection); return $this->collection->toArray(); } @@ -237,6 +246,7 @@ class DataProvider implements DataProviderInterface */ public function count() { + $this->filterPool->applyFilters($this->collection); return $this->collection->count(); } diff --git a/app/code/Magento/Cms/Setup/UpgradeSchema.php b/app/code/Magento/Cms/Setup/UpgradeSchema.php new file mode 100644 index 0000000000000000000000000000000000000000..a4811055a0796b7639b52f41206a2569edf538e5 --- /dev/null +++ b/app/code/Magento/Cms/Setup/UpgradeSchema.php @@ -0,0 +1,52 @@ +<?php +/** + * Copyright © 2015 Magento. All rights reserved. + * See COPYING.txt for license details. + */ + +namespace Magento\Cms\Setup; + +use Magento\Framework\DB\Adapter\AdapterInterface; +use Magento\Framework\Setup\UpgradeSchemaInterface; +use Magento\Framework\Setup\ModuleContextInterface; +use Magento\Framework\Setup\SchemaSetupInterface; + +/** + * @codeCoverageIgnore + */ +class UpgradeSchema implements UpgradeSchemaInterface +{ + /** + * {@inheritdoc} + * @SuppressWarnings(PHPMD.ExcessiveMethodLength) + * @SuppressWarnings(PHPMD.CyclomaticComplexity) + * @SuppressWarnings(PHPMD.NPathComplexity) + */ + public function upgrade(SchemaSetupInterface $setup, ModuleContextInterface $context) + { + $installer = $setup; + $connection = $installer->getConnection(); + if (version_compare($context->getVersion(), '2.0.1') < 0) { + $connection->addIndex( + $installer->getTable('cms_page'), + $setup->getIdxName( + $installer->getTable('cms_page'), + ['title', 'meta_keywords', 'meta_description', 'identifier', 'content'], + AdapterInterface::INDEX_TYPE_FULLTEXT + ), + ['title', 'meta_keywords', 'meta_description', 'identifier', 'content'], + AdapterInterface::INDEX_TYPE_FULLTEXT + ); + $connection->addIndex( + $installer->getTable('cms_block'), + $setup->getIdxName( + $installer->getTable('cms_block'), + ['title', 'identifier', 'content'], + AdapterInterface::INDEX_TYPE_FULLTEXT + ), + ['title', 'identifier', 'content'], + AdapterInterface::INDEX_TYPE_FULLTEXT + ); + } + } +} diff --git a/app/code/Magento/Cms/Ui/DataProvider/Block/Row/Actions.php b/app/code/Magento/Cms/Ui/DataProvider/Block/Row/Actions.php deleted file mode 100644 index ed4f5370f1737be78cdec41348555c9648aa192b..0000000000000000000000000000000000000000 --- a/app/code/Magento/Cms/Ui/DataProvider/Block/Row/Actions.php +++ /dev/null @@ -1,53 +0,0 @@ -<?php -/** - * Copyright © 2015 Magento. All rights reserved. - * See COPYING.txt for license details. - */ -namespace Magento\Cms\Ui\DataProvider\Block\Row; - -use Magento\Framework\UrlInterface; -use Magento\Ui\Component\Listing\RowInterface; - -/** - * Class Actions - */ -class Actions implements RowInterface -{ - /** - * Url path - */ - const URL_PATH = 'cms/block/edit'; - - /** - * @var UrlInterface - */ - protected $urlBuilder; - - /** - * @param UrlInterface $urlBuilder - */ - public function __construct(UrlInterface $urlBuilder) - { - $this->urlBuilder = $urlBuilder; - } - - /** - * Get data - * - * @param array $rowData - * @param array $rowActionConfig - * @return array - */ - public function getData(array $rowData, array $rowActionConfig = []) - { - return [ - 'edit' => [ - 'href' => $this->urlBuilder->getUrl( - isset($rowActionConfig['url_path']) ? $rowActionConfig['url_path'] : static::URL_PATH, - ['block_id' => $rowData['block_id']] - ), - 'label' => __('Edit'), - ] - ]; - } -} diff --git a/app/code/Magento/Cms/Ui/DataProvider/Page/Row/Actions.php b/app/code/Magento/Cms/Ui/DataProvider/Page/Row/Actions.php deleted file mode 100644 index 644812f14bb6287df4a1efa7e910a752062db12d..0000000000000000000000000000000000000000 --- a/app/code/Magento/Cms/Ui/DataProvider/Page/Row/Actions.php +++ /dev/null @@ -1,73 +0,0 @@ -<?php -/** - * Copyright © 2015 Magento. All rights reserved. - * See COPYING.txt for license details. - */ -namespace Magento\Cms\Ui\DataProvider\Page\Row; - -use Magento\Cms\Block\Adminhtml\Page\Grid\Renderer\Action\UrlBuilder; -use Magento\Framework\UrlInterface; -use Magento\Ui\Component\Listing\RowInterface; - -/** - * Class Actions - */ -class Actions implements RowInterface -{ - /** - * Url path - */ - const URL_PATH = 'cms/page/edit'; - - /** - * @var UrlBuilder - */ - protected $actionUrlBuilder; - - /** - * @var UrlInterface - */ - protected $urlBuilder; - - /** - * Constructor - * - * @param UrlBuilder $actionUrlBuilder - * @param UrlInterface $urlBuilder - */ - public function __construct(UrlBuilder $actionUrlBuilder, UrlInterface $urlBuilder) - { - $this->urlBuilder = $urlBuilder; - $this->actionUrlBuilder = $actionUrlBuilder; - } - - /** - * Get data - * - * @param array $rowData - * @param array $rowActionConfig - * @return array - */ - public function getData(array $rowData, array $rowActionConfig = []) - { - return [ - 'edit' => [ - 'href' => $this->urlBuilder->getUrl( - isset($rowActionConfig['url_path']) ? $rowActionConfig['url_path'] : static::URL_PATH, - ['page_id' => $rowData['page_id']] - ), - 'label' => __('Edit'), - 'hidden' => true, - - ], - 'preview' => [ - 'href' => $this->actionUrlBuilder->getUrl( - $rowData['identifier'], - isset($rowData['_first_store_id']) ? $rowData['_first_store_id'] : null, - isset($rowData['store_code']) ? $rowData['store_code'] : null - ), - 'label' => __('Preview'), - ] - ]; - } -} diff --git a/app/code/Magento/Cms/etc/di.xml b/app/code/Magento/Cms/etc/di.xml index d25ddfd399e02b299b8cc9be0c901fe03b795f3d..ae53723ea07a3982292f365c79cc2f63a1610e71 100644 --- a/app/code/Magento/Cms/etc/di.xml +++ b/app/code/Magento/Cms/etc/di.xml @@ -56,4 +56,24 @@ </argument> </arguments> </type> + <virtualType name="CmsGirdFilterPool" type="Magento\Framework\View\Element\UiComponent\DataProvider\FilterPool"> + <arguments> + <argument name="appliers" xsi:type="array"> + <item name="regular" xsi:type="object">Magento\Framework\View\Element\UiComponent\DataProvider\RegularFilter</item> + <item name="fulltext" xsi:type="object">Magento\Framework\View\Element\UiComponent\DataProvider\FulltextFilter</item> + </argument> + </arguments> + </virtualType> + <virtualType name="PageGridDataProvider" type="Magento\Framework\View\Element\UiComponent\DataProvider\DataProvider"> + <arguments> + <argument name="collection" xsi:type="object" shared="false">Magento\Cms\Model\Resource\Page\Collection</argument> + <argument name="filterPool" xsi:type="object" shared="false">CmsGirdFilterPool</argument> + </arguments> + </virtualType> + <virtualType name="BlockGridDataProvider" type="Magento\Framework\View\Element\UiComponent\DataProvider\DataProvider"> + <arguments> + <argument name="collection" xsi:type="object" shared="false">Magento\Cms\Model\Resource\Block\Collection</argument> + <argument name="filterPool" xsi:type="object" shared="false">CmsGirdFilterPool</argument> + </arguments> + </virtualType> </config> diff --git a/app/code/Magento/Cms/etc/module.xml b/app/code/Magento/Cms/etc/module.xml index 9103575c3a6b146e2e8fa1559ac1eeb91fd4625c..4303db7c6ae4c4a306c09bf1cb65877e48f153b4 100644 --- a/app/code/Magento/Cms/etc/module.xml +++ b/app/code/Magento/Cms/etc/module.xml @@ -6,7 +6,7 @@ */ --> <config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../../../../../lib/internal/Magento/Framework/Module/etc/module.xsd"> - <module name="Magento_Cms" setup_version="2.0.0"> + <module name="Magento_Cms" setup_version="2.0.1"> <sequence> <module name="Magento_Store"/> <module name="Magento_Theme"/> diff --git a/app/code/Magento/Cms/view/adminhtml/ui_component/cms_block_listing.xml b/app/code/Magento/Cms/view/adminhtml/ui_component/cms_block_listing.xml index 93cacfe15afec6b72d635500e792dfefd0c8de95..c1e9dad73c7438d212ce1700b630e5ffc80df55f 100644 --- a/app/code/Magento/Cms/view/adminhtml/ui_component/cms_block_listing.xml +++ b/app/code/Magento/Cms/view/adminhtml/ui_component/cms_block_listing.xml @@ -23,7 +23,7 @@ </argument> <dataSource name="cms_block_listing_data_source"> <argument name="dataProvider" xsi:type="configurableObject"> - <argument name="class" xsi:type="string">Magento\Cms\Model\Block\DataProvider</argument> + <argument name="class" xsi:type="string">BlockGridDataProvider</argument> <argument name="name" xsi:type="string">cms_block_listing_data_source</argument> <argument name="primaryFieldName" xsi:type="string">block_id</argument> <argument name="requestFieldName" xsi:type="string">id</argument> @@ -69,7 +69,7 @@ </item> </argument> </container> - <container name="search"> + <filterSearch name="fulltext"> <argument name="data" xsi:type="array"> <item name="config" xsi:type="array"> <item name="component" xsi:type="string">Magento_Ui/js/grid/search/search</item> @@ -82,7 +82,7 @@ </item> </item> </argument> - </container> + </filterSearch> <filters name="listing_filters"> <argument name="data" xsi:type="array"> <item name="config" xsi:type="array"> 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 49ecf18d2f302b1f35cb3c855f0fd3db5b94a7ab..06396855cc8eaefb8843dfd1bcda5f669a35b116 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 @@ -23,7 +23,7 @@ </argument> <dataSource name="cms_page_listing_data_source"> <argument name="dataProvider" xsi:type="configurableObject"> - <argument name="class" xsi:type="string">Magento\Cms\Model\Page\DataProvider</argument> + <argument name="class" xsi:type="string">PageGridDataProvider</argument> <argument name="name" xsi:type="string">cms_page_listing_data_source</argument> <argument name="primaryFieldName" xsi:type="string">block_id</argument> <argument name="requestFieldName" xsi:type="string">id</argument> @@ -69,7 +69,7 @@ </item> </argument> </container> - <container name="search"> + <filterSearch name="fulltext"> <argument name="data" xsi:type="array"> <item name="config" xsi:type="array"> <item name="component" xsi:type="string">Magento_Ui/js/grid/search/search</item> @@ -82,7 +82,7 @@ </item> </item> </argument> - </container> + </filterSearch> <filters name="listing_filters"> <argument name="data" xsi:type="array"> <item name="config" xsi:type="array"> diff --git a/app/code/Magento/Customer/Model/Customer/DataProvider.php b/app/code/Magento/Customer/Model/Customer/DataProvider.php index 777a78cb6fa05508712a9c07f4b8f7775ec45029..ef9437174edc3ad1b8aaa053c1243e4ba344e8d0 100644 --- a/app/code/Magento/Customer/Model/Customer/DataProvider.php +++ b/app/code/Magento/Customer/Model/Customer/DataProvider.php @@ -13,6 +13,7 @@ use Magento\Ui\DataProvider\EavValidationRules; use Magento\Customer\Model\Resource\Customer\Collection; use Magento\Framework\View\Element\UiComponent\DataProvider\DataProviderInterface; use Magento\Customer\Model\Resource\Customer\CollectionFactory as CustomerCollectionFactory; +use Magento\Framework\View\Element\UiComponent\DataProvider\FilterPool; /** * Class DataProvider @@ -46,6 +47,11 @@ class DataProvider implements DataProviderInterface */ protected $eavConfig; + /** + * @var FilterPool + */ + protected $filterPool; + /** * @var array */ @@ -103,6 +109,7 @@ class DataProvider implements DataProviderInterface * @param EavValidationRules $eavValidationRules * @param CustomerCollectionFactory $customerCollectionFactory * @param Config $eavConfig + * @param FilterPool $filterPool * @param array $meta * @param array $data */ @@ -113,6 +120,7 @@ class DataProvider implements DataProviderInterface EavValidationRules $eavValidationRules, CustomerCollectionFactory $customerCollectionFactory, Config $eavConfig, + FilterPool $filterPool, array $meta = [], array $data = [] ) { @@ -123,6 +131,7 @@ class DataProvider implements DataProviderInterface $this->collection = $customerCollectionFactory->create(); $this->collection->addAttributeToSelect('*'); $this->eavConfig = $eavConfig; + $this->filterPool = $filterPool; $this->meta = $meta; $this->meta['customer']['fields'] = $this->getAttributesMeta( $this->eavConfig->getEntityType('customer') @@ -212,9 +221,9 @@ class DataProvider implements DataProviderInterface /** * @inheritdoc */ - public function addFilter($field, $condition = null) + public function addFilter($condition, $field = null, $type = 'regular') { - $this->collection->addFieldToFilter($field, $condition); + $this->filterPool->registerNewFilter($condition, $field, $type); } /** @@ -288,7 +297,7 @@ class DataProvider implements DataProviderInterface if (isset($this->loadedData)) { return $this->loadedData; } - + $this->filterPool->applyFilters($this->collection); $items = $this->collection->getItems(); /** @var Customer $customer */ foreach ($items as $customer) { @@ -319,6 +328,7 @@ class DataProvider implements DataProviderInterface */ public function count() { + $this->filterPool->applyFilters($this->collection); return $this->collection->count(); } diff --git a/app/code/Magento/Customer/Ui/Component/Listing/Column/Group/Options.php b/app/code/Magento/Customer/Ui/Component/Listing/Column/Group/Options.php new file mode 100644 index 0000000000000000000000000000000000000000..75ef85805d9dfe3f6aea3a34255273a37c5b4db0 --- /dev/null +++ b/app/code/Magento/Customer/Ui/Component/Listing/Column/Group/Options.php @@ -0,0 +1,48 @@ +<?php +/** + * Copyright © 2015 Magento. All rights reserved. + * See COPYING.txt for license details. + */ +namespace Magento\Customer\Ui\Component\Listing\Column\Group; + +use Magento\Framework\Data\OptionSourceInterface; +use Magento\Customer\Model\Resource\Group\CollectionFactory; + +/** + * Class Options + */ +class Options implements OptionSourceInterface +{ + /** + * @var array + */ + protected $options; + + /** + * @var CollectionFactory + */ + protected $collectionFactory; + + /** + * Constructor + * + * @param CollectionFactory $collectionFactory + */ + public function __construct(CollectionFactory $collectionFactory) + { + $this->collectionFactory = $collectionFactory; + } + + /** + * Get options + * + * @return array + */ + public function toOptionArray() + { + if ($this->options === null) { + $this->options = $this->collectionFactory->create()->toOptionArray(); + } + return $this->options; + } +} diff --git a/app/code/Magento/Payment/Ui/Component/Listing/Column/Method/Options.php b/app/code/Magento/Payment/Ui/Component/Listing/Column/Method/Options.php new file mode 100644 index 0000000000000000000000000000000000000000..d5446bf5008145811f866e44222d60ef4c277fee --- /dev/null +++ b/app/code/Magento/Payment/Ui/Component/Listing/Column/Method/Options.php @@ -0,0 +1,45 @@ +<?php +/** + * Copyright © 2015 Magento. All rights reserved. + * See COPYING.txt for license details. + */ +namespace Magento\Payment\Ui\Component\Listing\Column\Method; + +/** + * Class Options + */ +class Options implements \Magento\Framework\Data\OptionSourceInterface +{ + /** + * @var array + */ + protected $options; + + /** + * @var \Magento\Payment\Helper\Data + */ + protected $paymentHelper; + + /** + * Constructor + * + * @param \Magento\Payment\Helper\Data $paymentHelper + */ + public function __construct(\Magento\Payment\Helper\Data $paymentHelper) + { + $this->paymentHelper = $paymentHelper; + } + + /** + * Get options + * + * @return array + */ + public function toOptionArray() + { + if ($this->options === null) { + $this->options = $this->paymentHelper->getPaymentMethodList(true, true); + } + return $this->options; + } +} diff --git a/app/code/Magento/Sales/Block/Adminhtml/Order/Grid.php b/app/code/Magento/Sales/Block/Adminhtml/Order/Grid.php index f3b8531f03bb63da928fad392e9a8983043cb509..ca83df2fe053b89ad6e244f541cfb74443757406 100644 --- a/app/code/Magento/Sales/Block/Adminhtml/Order/Grid.php +++ b/app/code/Magento/Sales/Block/Adminhtml/Order/Grid.php @@ -12,4 +12,51 @@ namespace Magento\Sales\Block\Adminhtml\Order; */ class Grid extends \Magento\Backend\Block\Widget\Grid { + /** + * @var \Magento\Framework\View\Element\UiComponentFactory + */ + protected $componentFactory; + + /** + * @param \Magento\Backend\Block\Template\Context $context + * @param \Magento\Backend\Helper\Data $backendHelper + * @param \Magento\Framework\View\Element\UiComponentFactory $componentFactory + * @param array $data + */ + public function __construct( + \Magento\Backend\Block\Template\Context $context, + \Magento\Backend\Helper\Data $backendHelper, + \Magento\Framework\View\Element\UiComponentFactory $componentFactory, + array $data = [] + ) { + $this->componentFactory = $componentFactory; + parent::__construct($context, $backendHelper, $data); + } + + /** + * @return $this + * @throws \Magento\Framework\Exception\LocalizedException + */ + protected function _prepareCollection() + { + $component = $this->componentFactory->create('sales_order_grid'); + $this->prepareComponent($component); + $component->render(); + $collection = $component->getContext()->getDataProvider()->getCollection(); + $this->setData('dataSource', $collection); + + return parent::_prepareCollection(); + } + + /** + * @param \Magento\Framework\View\Element\UiComponentInterface $componentElement + * @return void + */ + protected function prepareComponent(\Magento\Framework\View\Element\UiComponentInterface $componentElement) + { + foreach ($componentElement->getChildComponents() as $childComponent) { + $this->prepareComponent($childComponent); + } + $componentElement->prepare(); + } } 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 8304f41f1d06c78d51e73af3028b7337aa365814..1e5bce8fb535a5e67a5514ff66d2b5c189c506b3 100644 --- a/app/code/Magento/Sales/Controller/Adminhtml/Creditmemo/AbstractCreditmemo/Pdfcreditmemos.php +++ b/app/code/Magento/Sales/Controller/Adminhtml/Creditmemo/AbstractCreditmemo/Pdfcreditmemos.php @@ -8,13 +8,20 @@ namespace Magento\Sales\Controller\Adminhtml\Creditmemo\AbstractCreditmemo; use Magento\Framework\App\ResponseInterface; use Magento\Framework\App\Filesystem\DirectoryList; -class Pdfcreditmemos extends \Magento\Backend\App\Action +use Magento\Framework\Model\Resource\Db\Collection\AbstractCollection; + +class Pdfcreditmemos extends \Magento\Sales\Controller\Adminhtml\Order\AbstractMassAction { /** * @var \Magento\Framework\App\Response\Http\FileFactory */ protected $_fileFactory; + /** + * @var string + */ + protected $collection = 'Magento\Sales\Model\Resource\Order\Creditmemo\Grid\Collection'; + /** * @param \Magento\Backend\App\Action\Context $context * @param \Magento\Framework\App\Response\Http\FileFactory $fileFactory @@ -36,37 +43,25 @@ class Pdfcreditmemos extends \Magento\Backend\App\Action } /** - * @return ResponseInterface|\Magento\Backend\Model\View\Result\Redirect + * @param AbstractCollection $collection + * @return ResponseInterface|\Magento\Framework\Controller\Result\Redirect + * @throws \Exception */ - public function execute() + public function massAction(AbstractCollection $collection) { - $creditmemosIds = $this->getRequest()->getPost('creditmemo_ids'); - if (!empty($creditmemosIds)) { - $invoices = $this->_objectManager->create( - 'Magento\Sales\Model\Resource\Order\Creditmemo\Collection' - )->addAttributeToSelect( - '*' - )->addAttributeToFilter( - 'entity_id', - ['in' => $creditmemosIds] - )->load(); - if (!isset($pdf)) { - $pdf = $this->_objectManager->create('Magento\Sales\Model\Order\Pdf\Creditmemo')->getPdf($invoices); - } else { - $pages = $this->_objectManager->create('Magento\Sales\Model\Order\Pdf\Creditmemo')->getPdf($invoices); - $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(), - DirectoryList::VAR_DIR, - 'application/pdf' - ); + 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); } - $resultRedirect = $this->resultRedirectFactory->create(); - $resultRedirect->setPath('sales/*/'); - return $resultRedirect; + $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' + ); } } 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 fae61c7df106bf14ed025c871d446c6d60b52245..12c563f57151dd608d2233f0b3b193d0c33366bf 100644 --- a/app/code/Magento/Sales/Controller/Adminhtml/Invoice/AbstractInvoice/Pdfinvoices.php +++ b/app/code/Magento/Sales/Controller/Adminhtml/Invoice/AbstractInvoice/Pdfinvoices.php @@ -8,14 +8,22 @@ namespace Magento\Sales\Controller\Adminhtml\Invoice\AbstractInvoice; use Magento\Framework\App\ResponseInterface; use Magento\Framework\App\Filesystem\DirectoryList; +use Magento\Framework\Model\Resource\Db\Collection\AbstractCollection; -abstract class Pdfinvoices extends \Magento\Backend\App\Action +abstract class Pdfinvoices extends \Magento\Sales\Controller\Adminhtml\Order\AbstractMassAction { /** * @var \Magento\Framework\App\Response\Http\FileFactory */ protected $_fileFactory; + /** + * Resource collection + * + * @var string + */ + protected $collection = 'Magento\Sales\Model\Resource\Order\Invoice\Grid\Collection'; + /** * @param \Magento\Backend\App\Action\Context $context * @param \Magento\Framework\App\Response\Http\FileFactory $fileFactory @@ -37,31 +45,27 @@ abstract class Pdfinvoices extends \Magento\Backend\App\Action } /** - * @return ResponseInterface|void + * Save collection items to pdf invoices + * + * @param AbstractCollection $collection + * @return ResponseInterface + * @throws \Exception */ - public function execute() + public function massAction(AbstractCollection $collection) { - $invoicesIds = $this->getRequest()->getPost('invoice_ids'); - if (!empty($invoicesIds)) { - $invoices = $this->_objectManager->create('Magento\Sales\Model\Resource\Order\Invoice\Collection') - ->addAttributeToSelect('*') - ->addAttributeToFilter('entity_id', ['in' => $invoicesIds]) - ->load(); - 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); - } - $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' - ); + 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); } - return $this->resultRedirectFactory->create()->setPath('sales/*/'); + $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' + ); } } diff --git a/app/code/Magento/Sales/Controller/Adminhtml/Order/AbstractMassAction.php b/app/code/Magento/Sales/Controller/Adminhtml/Order/AbstractMassAction.php new file mode 100644 index 0000000000000000000000000000000000000000..fdc6bdcbdabf51de424178ee5b21995740be0533 --- /dev/null +++ b/app/code/Magento/Sales/Controller/Adminhtml/Order/AbstractMassAction.php @@ -0,0 +1,71 @@ +<?php +/** + * Copyright © 2015 Magento. All rights reserved. + * See COPYING.txt for license details. + */ +namespace Magento\Sales\Controller\Adminhtml\Order; + +use Magento\Framework\Model\Resource\Db\Collection\AbstractCollection; +use Magento\Framework\Controller\ResultFactory; + +/** + * Class AbstractMassStatus + */ +abstract class AbstractMassAction extends \Magento\Backend\App\Action +{ + /** + * Field id + */ + const ID_FIELD = 'entity_id'; + + /** + * Redirect url + */ + const REDIRECT_URL = '*/*/'; + + /** + * Resource collection + * + * @var string + */ + protected $collection = 'Magento\Sales\Model\Resource\Order\Grid\Collection'; + + /** + * Execute action + * + * @return \Magento\Backend\Model\View\Result\Redirect + * @throws \Magento\Framework\Exception\LocalizedException|\Exception + */ + 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).')); + } + } 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 collection items + * + * @param AbstractCollection $collection + * @return void + */ + abstract protected function massAction(AbstractCollection $collection); +} diff --git a/app/code/Magento/Sales/Controller/Adminhtml/Order/MassCancel.php b/app/code/Magento/Sales/Controller/Adminhtml/Order/MassCancel.php index 14eface4372bd160355907610a45b2d8957721dd..731363167b016e27905bfc125c1f911976e378c0 100644 --- a/app/code/Magento/Sales/Controller/Adminhtml/Order/MassCancel.php +++ b/app/code/Magento/Sales/Controller/Adminhtml/Order/MassCancel.php @@ -5,34 +5,35 @@ */ namespace Magento\Sales\Controller\Adminhtml\Order; -class MassCancel extends \Magento\Sales\Controller\Adminhtml\Order +use Magento\Framework\Model\Resource\Db\Collection\AbstractCollection; + +class MassCancel extends \Magento\Sales\Controller\Adminhtml\Order\AbstractMassAction { /** * Cancel selected orders * + * @param AbstractCollection $collection * @return \Magento\Backend\Model\View\Result\Redirect */ - public function execute() + protected function massAction(AbstractCollection $collection) { - $orderIds = $this->getRequest()->getPost('order_ids', []); $countCancelOrder = 0; - $countNonCancelOrder = 0; - foreach ($orderIds as $orderId) { - $order = $this->_objectManager->create('Magento\Sales\Model\Order')->load($orderId); - if ($order->canCancel()) { - $order->cancel()->save(); - $countCancelOrder++; - } else { - $countNonCancelOrder++; + foreach ($collection->getItems() as $order) { + if (!$order->canCancel()) { + continue; } + $order->cancel(); + $order->save(); + $countCancelOrder++; } - if ($countNonCancelOrder) { - if ($countCancelOrder) { - $this->messageManager->addError(__('%1 order(s) cannot be canceled.', $countNonCancelOrder)); - } else { - $this->messageManager->addError(__('You cannot cancel the order(s).')); - } + $countNonCancelOrder = $collection->count() - $countCancelOrder; + + if ($countNonCancelOrder && $countCancelOrder) { + $this->messageManager->addError(__('%1 order(s) cannot be canceled.', $countNonCancelOrder)); + } elseif ($countNonCancelOrder) { + $this->messageManager->addError(__('You cannot cancel the order(s).')); } + if ($countCancelOrder) { $this->messageManager->addSuccess(__('We canceled %1 order(s).', $countCancelOrder)); } diff --git a/app/code/Magento/Sales/Controller/Adminhtml/Order/MassHold.php b/app/code/Magento/Sales/Controller/Adminhtml/Order/MassHold.php index 6681bb10a83fc5e19fe30a61d30ee10a8b727b3e..c10ab68f62078d41f3c77ca4cb78748427d7e6e0 100644 --- a/app/code/Magento/Sales/Controller/Adminhtml/Order/MassHold.php +++ b/app/code/Magento/Sales/Controller/Adminhtml/Order/MassHold.php @@ -5,35 +5,35 @@ */ namespace Magento\Sales\Controller\Adminhtml\Order; -class MassHold extends \Magento\Sales\Controller\Adminhtml\Order +use Magento\Framework\Model\Resource\Db\Collection\AbstractCollection; + +class MassHold extends \Magento\Sales\Controller\Adminhtml\Order\AbstractMassAction { /** * Hold selected orders * + * @param AbstractCollection $collection * @return \Magento\Backend\Model\View\Result\Redirect */ - public function execute() + protected function massAction(AbstractCollection $collection) { - $orderIds = $this->getRequest()->getPost('order_ids', []); $countHoldOrder = 0; - - foreach ($orderIds as $orderId) { - $order = $this->_objectManager->create('Magento\Sales\Model\Order')->load($orderId); - if ($order->canHold()) { - $order->hold()->save(); - $countHoldOrder++; + foreach ($collection->getItems() as $order) { + if (!$order->canHold()) { + continue; } + $order->hold(); + $order->save(); + $countHoldOrder++; } + $countNonHoldOrder = $collection->count() - $countHoldOrder; - $countNonHoldOrder = count($orderIds) - $countHoldOrder; - - if ($countNonHoldOrder) { - if ($countHoldOrder) { - $this->messageManager->addError(__('%1 order(s) were not put on hold.', $countNonHoldOrder)); - } else { - $this->messageManager->addError(__('No order(s) were put on hold.')); - } + if ($countNonHoldOrder && $countHoldOrder) { + $this->messageManager->addError(__('%1 order(s) were not put on hold.', $countNonHoldOrder)); + } elseif ($countNonHoldOrder) { + $this->messageManager->addError(__('No order(s) were put on hold.')); } + if ($countHoldOrder) { $this->messageManager->addSuccess(__('You have put %1 order(s) on hold.', $countHoldOrder)); } diff --git a/app/code/Magento/Sales/Controller/Adminhtml/Order/MassPrint.php b/app/code/Magento/Sales/Controller/Adminhtml/Order/MassPrint.php deleted file mode 100644 index 69e3e26dabdd3ddcde0daa4cbb01876d8eb120b3..0000000000000000000000000000000000000000 --- a/app/code/Magento/Sales/Controller/Adminhtml/Order/MassPrint.php +++ /dev/null @@ -1,18 +0,0 @@ -<?php -/** - * Copyright © 2015 Magento. All rights reserved. - * See COPYING.txt for license details. - */ -namespace Magento\Sales\Controller\Adminhtml\Order; - -class MassPrint extends \Magento\Sales\Controller\Adminhtml\Order -{ - /** - * Print documents for selected orders - * - * @return void - */ - public function execute() - { - } -} diff --git a/app/code/Magento/Sales/Controller/Adminhtml/Order/MassStatus.php b/app/code/Magento/Sales/Controller/Adminhtml/Order/MassStatus.php deleted file mode 100644 index 50949ad823d6d5f6a6c924ad0f8714e5608e009c..0000000000000000000000000000000000000000 --- a/app/code/Magento/Sales/Controller/Adminhtml/Order/MassStatus.php +++ /dev/null @@ -1,18 +0,0 @@ -<?php -/** - * Copyright © 2015 Magento. All rights reserved. - * See COPYING.txt for license details. - */ -namespace Magento\Sales\Controller\Adminhtml\Order; - -class MassStatus extends \Magento\Sales\Controller\Adminhtml\Order -{ - /** - * Change status for selected orders - * - * @return void - */ - public function execute() - { - } -} diff --git a/app/code/Magento/Sales/Controller/Adminhtml/Order/MassUnhold.php b/app/code/Magento/Sales/Controller/Adminhtml/Order/MassUnhold.php index 71a4cae64fe6b008446fbeed4df77c4d69f1d497..80107a9f4ad8ea5e33ea688e02ed07707682ff35 100644 --- a/app/code/Magento/Sales/Controller/Adminhtml/Order/MassUnhold.php +++ b/app/code/Magento/Sales/Controller/Adminhtml/Order/MassUnhold.php @@ -5,37 +5,39 @@ */ namespace Magento\Sales\Controller\Adminhtml\Order; -class MassUnhold extends \Magento\Sales\Controller\Adminhtml\Order +use Magento\Framework\Model\Resource\Db\Collection\AbstractCollection; + +class MassUnhold extends \Magento\Sales\Controller\Adminhtml\Order\AbstractMassAction { /** * Unhold selected orders * + * @param AbstractCollection $collection * @return \Magento\Backend\Model\View\Result\Redirect */ - public function execute() + protected function massAction(AbstractCollection $collection) { - $orderIds = $this->getRequest()->getPost('order_ids', []); $countUnHoldOrder = 0; - $countNonUnHoldOrder = 0; - foreach ($orderIds as $orderId) { - $order = $this->_objectManager->create('Magento\Sales\Model\Order')->load($orderId); - if ($order->canUnhold()) { - $order->unhold()->save(); - $countUnHoldOrder++; - } else { - $countNonUnHoldOrder++; + foreach ($collection->getItems() as $order) { + if (!$order->canUnhold()) { + continue; } + $order->unhold(); + $order->save(); + $countUnHoldOrder++; } - if ($countNonUnHoldOrder) { - if ($countUnHoldOrder) { - $this->messageManager->addError( - __('%1 order(s) were not released from on hold status.', $countNonUnHoldOrder) - ); - } else { - $this->messageManager->addError(__('No order(s) were released from on hold status.')); - } + + $countNonUnHoldOrder = $collection->count() - $countUnHoldOrder; + + if ($countNonUnHoldOrder && $countUnHoldOrder) { + $this->messageManager->addError( + __('%1 order(s) were not released from on hold status.', $countNonUnHoldOrder) + ); + } elseif ($countNonUnHoldOrder) { + $this->messageManager->addError(__('No order(s) were released from on hold status.')); } + if ($countUnHoldOrder) { $this->messageManager->addSuccess( __('%1 order(s) have been released from on hold status.', $countUnHoldOrder) diff --git a/app/code/Magento/Sales/Controller/Adminhtml/Order/Pdfcreditmemos.php b/app/code/Magento/Sales/Controller/Adminhtml/Order/Pdfcreditmemos.php index 1c0022b10dca2113512e44851634ae790218f3aa..24d9f9d69a6545cf097570dfe9075e9433f2bbd5 100644 --- a/app/code/Magento/Sales/Controller/Adminhtml/Order/Pdfcreditmemos.php +++ b/app/code/Magento/Sales/Controller/Adminhtml/Order/Pdfcreditmemos.php @@ -7,52 +7,48 @@ namespace Magento\Sales\Controller\Adminhtml\Order; use Magento\Framework\App\ResponseInterface; use Magento\Framework\App\Filesystem\DirectoryList; +use Magento\Framework\Model\Resource\Db\Collection\AbstractCollection; -class Pdfcreditmemos extends \Magento\Sales\Controller\Adminhtml\Order +class Pdfcreditmemos extends \Magento\Sales\Controller\Adminhtml\Order\AbstractMassAction { /** * Print credit memos for selected orders * + * @param AbstractCollection $collection * @return ResponseInterface|\Magento\Backend\Model\View\Result\Redirect */ - public function execute() + protected function massAction(AbstractCollection $collection) { - $orderIds = $this->getRequest()->getPost('order_ids'); $resultRedirect = $this->resultRedirectFactory->create(); $flag = false; - if (!empty($orderIds)) { - foreach ($orderIds as $orderId) { - $creditmemos = $this->_objectManager->create('Magento\Sales\Model\Resource\Order\Creditmemo\Collection') - ->setOrderFilter($orderId) - ->load(); - 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); - } + /** @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 { - $this->messageManager->addError(__('There are no printable documents related to selected orders.')); - $resultRedirect->setPath('sales/*/'); - return $resultRedirect; - } } - $resultRedirect->setPath('sales/*/'); - return $resultRedirect; + 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 { + $this->messageManager->addError(__('There are no printable documents related to selected orders.')); + $resultRedirect->setPath('sales/*/'); + return $resultRedirect; + } } } diff --git a/app/code/Magento/Sales/Controller/Adminhtml/Order/Pdfdocs.php b/app/code/Magento/Sales/Controller/Adminhtml/Order/Pdfdocs.php index 498c72f47cdb59e517ec9a9c4b9c8c7f3ab28518..352abdf5bc265ceb128346e2c1034bc7b26c2379 100644 --- a/app/code/Magento/Sales/Controller/Adminhtml/Order/Pdfdocs.php +++ b/app/code/Magento/Sales/Controller/Adminhtml/Order/Pdfdocs.php @@ -7,84 +7,93 @@ namespace Magento\Sales\Controller\Adminhtml\Order; use Magento\Framework\App\ResponseInterface; use Magento\Framework\App\Filesystem\DirectoryList; +use Magento\Framework\Model\Resource\Db\Collection\AbstractCollection; -class Pdfdocs extends \Magento\Sales\Controller\Adminhtml\Order +class Pdfdocs extends \Magento\Sales\Controller\Adminhtml\Order\AbstractMassAction { + /** + * @var \Magento\Framework\App\Response\Http\FileFactory + */ + protected $fileFactory; + + /** + * @param \Magento\Backend\App\Action\Context $context + * @param \Magento\Framework\App\Response\Http\FileFactory $fileFactory + */ + public function __construct( + \Magento\Backend\App\Action\Context $context, + \Magento\Framework\App\Response\Http\FileFactory $fileFactory + ) { + $this->fileFactory = $fileFactory; + parent::__construct($context); + } + /** * Print all documents for selected orders * + * @param AbstractCollection $collection * @return ResponseInterface|\Magento\Backend\Model\View\Result\Redirect * * @SuppressWarnings(PHPMD.CyclomaticComplexity) */ - public function execute() + protected function massAction(AbstractCollection $collection) { - $orderIds = $this->getRequest()->getPost('order_ids'); $resultRedirect = $this->resultRedirectFactory->create(); $flag = false; - if (!empty($orderIds)) { - foreach ($orderIds as $orderId) { - $invoices = $this->_objectManager->create('Magento\Sales\Model\Resource\Order\Invoice\Collection') - ->setOrderFilter($orderId) - ->load(); - 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); - } + /** @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 = $this->_objectManager->create('Magento\Sales\Model\Resource\Order\Shipment\Collection') - ->setOrderFilter($orderId) - ->load(); - 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); - } + $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 = $this->_objectManager->create('Magento\Sales\Model\Resource\Order\Creditmemo\Collection') - ->setOrderFilter($orderId) - ->load(); - 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); - } + $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( - 'docs' . $date . '.pdf', - $pdf->render(), - DirectoryList::VAR_DIR, - 'application/pdf' - ); - } else { - $this->messageManager->addError(__('There are no printable documents related to selected orders.')); - $resultRedirect->setPath('sales/*/'); - return $resultRedirect; - } } - $resultRedirect->setPath('sales/*/'); - return $resultRedirect; + 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 { + $this->messageManager->addError(__('There are no printable documents related to selected orders.')); + $resultRedirect->setPath('sales/*/'); + return $resultRedirect; + } } } diff --git a/app/code/Magento/Sales/Controller/Adminhtml/Order/Pdfinvoices.php b/app/code/Magento/Sales/Controller/Adminhtml/Order/Pdfinvoices.php index 1f15336dc8c63d902998727d5e293b2d5f30c143..be03358130a1c967c5cda7ffc706a8ec52f2ee7f 100644 --- a/app/code/Magento/Sales/Controller/Adminhtml/Order/Pdfinvoices.php +++ b/app/code/Magento/Sales/Controller/Adminhtml/Order/Pdfinvoices.php @@ -7,52 +7,65 @@ namespace Magento\Sales\Controller\Adminhtml\Order; use Magento\Framework\App\ResponseInterface; use Magento\Framework\App\Filesystem\DirectoryList; +use Magento\Framework\Model\Resource\Db\Collection\AbstractCollection; -class Pdfinvoices extends \Magento\Sales\Controller\Adminhtml\Order +class Pdfinvoices extends \Magento\Sales\Controller\Adminhtml\Order\AbstractMassAction { + /** + * @var \Magento\Framework\App\Response\Http\FileFactory + */ + protected $fileFactory; + + /** + * @param \Magento\Backend\App\Action\Context $context + * @param \Magento\Framework\App\Response\Http\FileFactory $fileFactory + */ + public function __construct( + \Magento\Backend\App\Action\Context $context, + \Magento\Framework\App\Response\Http\FileFactory $fileFactory + ) { + $this->fileFactory = $fileFactory; + parent::__construct($context); + } + /** * Print invoices for selected orders * + * @param AbstractCollection $collection * @return ResponseInterface|\Magento\Backend\Model\View\Result\Redirect */ - public function execute() + protected function massAction(AbstractCollection $collection) { - $orderIds = $this->getRequest()->getPost('order_ids'); $resultRedirect = $this->resultRedirectFactory->create(); $flag = false; - if (!empty($orderIds)) { - foreach ($orderIds as $orderId) { - $invoices = $this->_objectManager->create('Magento\Sales\Model\Resource\Order\Invoice\Collection') - ->setOrderFilter($orderId) - ->load(); - 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); - } + /** @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 { - $this->messageManager->addError(__('There are no printable documents related to selected orders.')); - $resultRedirect->setPath('sales/*/'); - return $resultRedirect; - } } - $resultRedirect->setPath('sales/*/'); - return $resultRedirect; + 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 { + $this->messageManager->addError(__('There are no printable documents related to selected orders.')); + $resultRedirect->setPath('sales/*/'); + return $resultRedirect; + } } } diff --git a/app/code/Magento/Sales/Controller/Adminhtml/Order/Pdfshipments.php b/app/code/Magento/Sales/Controller/Adminhtml/Order/Pdfshipments.php index 32e548f4168793025a03632a18a38c88958aa5c9..ddcd0677c09ff21faf7dffc244dc160488f959d3 100644 --- a/app/code/Magento/Sales/Controller/Adminhtml/Order/Pdfshipments.php +++ b/app/code/Magento/Sales/Controller/Adminhtml/Order/Pdfshipments.php @@ -7,52 +7,48 @@ namespace Magento\Sales\Controller\Adminhtml\Order; use Magento\Framework\App\ResponseInterface; use Magento\Framework\App\Filesystem\DirectoryList; +use Magento\Framework\Model\Resource\Db\Collection\AbstractCollection; -class Pdfshipments extends \Magento\Sales\Controller\Adminhtml\Order +class Pdfshipments extends \Magento\Sales\Controller\Adminhtml\Order\AbstractMassAction { /** * Print shipments for selected orders * + * @param AbstractCollection $collection * @return ResponseInterface|\Magento\Backend\Model\View\Result\Redirect */ - public function execute() + protected function massAction(AbstractCollection $collection) { - $orderIds = $this->getRequest()->getPost('order_ids'); $resultRedirect = $this->resultRedirectFactory->create(); $flag = false; - if (!empty($orderIds)) { - foreach ($orderIds as $orderId) { - $shipments = $this->_objectManager->create('Magento\Sales\Model\Resource\Order\Shipment\Collection') - ->setOrderFilter($orderId) - ->load(); - 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); - } + /** @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 { - $this->messageManager->addError(__('There are no printable documents related to selected orders.')); - $resultRedirect->setPath('sales/*/'); - return $resultRedirect; - } } - $resultRedirect->setPath('sales/*/'); - return $resultRedirect; + 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 { + $this->messageManager->addError(__('There are no printable documents related to selected orders.')); + $resultRedirect->setPath('sales/*/'); + return $resultRedirect; + } } } 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 07a5b3d42dafb8e6ebdf89be3bed73bda4c2bd20..8c0b9baa42114d992f41ffcf3e63f149b0c40ff0 100644 --- a/app/code/Magento/Sales/Controller/Adminhtml/Shipment/AbstractShipment/Pdfshipments.php +++ b/app/code/Magento/Sales/Controller/Adminhtml/Shipment/AbstractShipment/Pdfshipments.php @@ -10,13 +10,20 @@ use Magento\Backend\App\Action\Context; use Magento\Framework\App\ResponseInterface; use Magento\Framework\App\Filesystem\DirectoryList; use Magento\Framework\App\Response\Http\FileFactory; +use Magento\Framework\Model\Resource\Db\Collection\AbstractCollection; -abstract class Pdfshipments extends \Magento\Backend\App\Action +abstract class Pdfshipments extends \Magento\Sales\Controller\Adminhtml\Order\AbstractMassAction { /** * @var FileFactory */ protected $_fileFactory; + /** + * Resource collection + * + * @var string + */ + protected $collection = 'Magento\Sales\Model\Resource\Order\Shipment\Grid\Collection'; /** * @param Context $context @@ -37,36 +44,24 @@ abstract class Pdfshipments extends \Magento\Backend\App\Action } /** - * @return ResponseInterface|\Magento\Backend\Model\View\Result\Redirect + * @param AbstractCollection $collection + * @return $this|ResponseInterface + * @throws \Exception */ - public function execute() + public function massAction(AbstractCollection $collection) { - $shipmentIds = $this->getRequest()->getPost('shipment_ids'); - if (!empty($shipmentIds)) { - $shipments = $this->_objectManager->create( - 'Magento\Sales\Model\Resource\Order\Shipment\Collection' - )->addAttributeToSelect( - '*' - )->addAttributeToFilter( - 'entity_id', - ['in' => $shipmentIds] - )->load(); - 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); - } - $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' - ); + 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); } - /** @var \Magento\Backend\Model\View\Result\Redirect $resultRedirect */ - $resultRedirect = $this->resultRedirectFactory->create(); - return $resultRedirect->setPath('sales/*/'); + $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' + ); } } diff --git a/app/code/Magento/Sales/Model/Order/Config.php b/app/code/Magento/Sales/Model/Order/Config.php index 6f638d146a34e3ef6e17eeba1c80ae9dc52489cc..bad7c52073a603562a9f7e2a34aa411520b17a82 100755 --- a/app/code/Magento/Sales/Model/Order/Config.php +++ b/app/code/Magento/Sales/Model/Order/Config.php @@ -173,7 +173,9 @@ class Config { $states = []; foreach ($this->_getCollection() as $item) { - $states[$item->getState()] = __($item->getData('label')); + if ($item->getState()) { + $states[$item->getState()] = __($item->getData('label')); + } } return $states; } diff --git a/app/code/Magento/Sales/Model/Resource/Grid.php b/app/code/Magento/Sales/Model/Resource/Grid.php new file mode 100644 index 0000000000000000000000000000000000000000..afccd93b2e0463ee2d2aacb82521973e9246a9e6 --- /dev/null +++ b/app/code/Magento/Sales/Model/Resource/Grid.php @@ -0,0 +1,152 @@ +<?php +/** + * Copyright © 2015 Magento. All rights reserved. + * See COPYING.txt for license details. + */ +namespace Magento\Sales\Model\Resource; + +use Magento\Framework\DB\Adapter\AdapterInterface; +use Magento\Sales\Model\Resource\AbstractGrid; +use Magento\Framework\Model\Resource\Db\Context; + +/** + * Class Grid + */ +class Grid extends AbstractGrid +{ + /** + * @var string + */ + protected $gridTableName; + + /** + * @var string + */ + protected $mainTableName; + + /** + * @var string + */ + protected $orderIdField; + + /** + * @var array + */ + protected $joins; + + /** + * @var array + */ + protected $columns; + + /** + * @param Context $context + * @param string $mainTableName + * @param string $gridTableName + * @param string $orderIdField + * @param array $joins + * @param array $columns + * @param string|null $resourcePrefix + */ + public function __construct( + Context $context, + $mainTableName, + $gridTableName, + $orderIdField, + array $joins = [], + array $columns = [], + $resourcePrefix = null + ) { + $this->mainTableName = $mainTableName; + $this->gridTableName = $gridTableName; + $this->orderIdField = $orderIdField; + $this->joins = $joins; + $this->columns = $columns; + parent::__construct($context, $resourcePrefix); + } + + /** + * Adds new orders to the grid. + * + * Only orders that correspond to $value and $field parameters will be added. + * + * @param int|string $value + * @param null|string $field + * @return \Zend_Db_Statement_Interface + */ + public function refresh($value, $field = null) + { + $select = $this->getGridOriginSelect() + ->where(($field ?: $this->mainTableName . '.entity_id') . ' = ?', $value); + return $this->getConnection()->query( + $this->getConnection() + ->insertFromSelect( + $select, + $this->getTable($this->gridTableName), + array_keys($this->columns), + AdapterInterface::INSERT_ON_DUPLICATE + ) + ); + } + + /** + * Adds new orders to the grid. + * + * Only orders created/updated since the last method call will be added. + * + * @return \Zend_Db_Statement_Interface + */ + public function refreshBySchedule() + { + $select = $this->getGridOriginSelect() + ->where($this->mainTableName . '.updated_at >= ?', $this->getLastUpdatedAtValue()); + + return $this->getConnection()->query( + $this->getConnection() + ->insertFromSelect( + $select, + $this->getTable($this->gridTableName), + array_keys($this->columns), + AdapterInterface::INSERT_ON_DUPLICATE + ) + ); + } + + /** + * @return string + */ + public function getOrderIdField() + { + return $this->orderIdField; + } + + /** + * Returns select object + * + * @return \Magento\Framework\DB\Select + */ + protected function getGridOriginSelect() + { + $select = $this->getConnection()->select() + ->from([$this->mainTableName => $this->getTable($this->mainTableName)], []); + foreach ($this->joins as $joinName => $data) { + $select->joinLeft( + [$joinName => $this->getTable($data['table'])], + sprintf( + '%s.%s = %s.%s', + $this->mainTableName, + $data['origin_column'], + $joinName, + $data['target_column'] + ), + [] + ); + } + $columns = []; + foreach ($this->columns as $key => $value) { + $columns[$key] = new \Zend_Db_Expr((string) $value); + } + $select->columns($columns); + return $select; + } +} diff --git a/app/code/Magento/Sales/Model/Resource/GridPool.php b/app/code/Magento/Sales/Model/Resource/GridPool.php index 80e5f44d1824879b836c45025a185fa5500f83c5..3c826c6abf2027a4be2b78d4adf997b5b2f784e7 100644 --- a/app/code/Magento/Sales/Model/Resource/GridPool.php +++ b/app/code/Magento/Sales/Model/Resource/GridPool.php @@ -6,36 +6,22 @@ namespace Magento\Sales\Model\Resource; -use Magento\Sales\Model\Resource\Order\Creditmemo\Grid as CreditmemoGrid; -use Magento\Sales\Model\Resource\Order\Grid as OrderGrid; -use Magento\Sales\Model\Resource\Order\Invoice\Grid as InvoiceGrid; -use Magento\Sales\Model\Resource\Order\Shipment\Grid as ShipmentGrid; - +/** + * Class GridPool + */ class GridPool { /** - * @var GridInterface[] + * @var \Magento\Sales\Model\Resource\Grid[] */ protected $grids; /** - * @param OrderGrid $orderGrid - * @param InvoiceGrid $invoiceGrid - * @param ShipmentGrid $shipmentGrid - * @param CreditmemoGrid $creditmemoGrid + * @param array $grids */ - public function __construct( - OrderGrid $orderGrid, - InvoiceGrid $invoiceGrid, - ShipmentGrid $shipmentGrid, - CreditmemoGrid $creditmemoGrid - ) { - $this->grids = [ - 'order_grid' => $orderGrid, - 'invoice_grid' => $invoiceGrid, - 'shipment_grid' => $shipmentGrid, - 'creditmemo_grid' => $creditmemoGrid, - ]; + public function __construct(array $grids) + { + $this->grids = $grids; } /** @@ -47,8 +33,9 @@ class GridPool public function refreshByOrderId($orderId) { foreach ($this->grids as $grid) { - $grid->refresh($orderId, 'sfo.entity_id'); + $grid->refresh($orderId, $grid->getOrderIdField()); } + return $this; } } diff --git a/app/code/Magento/Sales/Model/Resource/Order/Address.php b/app/code/Magento/Sales/Model/Resource/Order/Address.php index 760895576385ec3fd42c8598f2f34e9e590bba1a..83453f3ca6802d7d3938c738a10a03ef561cd7f5 100644 --- a/app/code/Magento/Sales/Model/Resource/Order/Address.php +++ b/app/code/Magento/Sales/Model/Resource/Order/Address.php @@ -132,8 +132,8 @@ class Address extends SalesResource implements OrderAddressResourceInterface protected function _afterSave(\Magento\Framework\Model\AbstractModel $object) { $resource = parent::_afterSave($object); - if ($object->getOrderId()) { - $this->gridPool->refreshByOrderId($object->getOrderId()); + if ($object->getParentId()) { + $this->gridPool->refreshByOrderId($object->getParentId()); } return $resource; } diff --git a/app/code/Magento/Sales/Model/Resource/Order/Creditmemo/Grid.php b/app/code/Magento/Sales/Model/Resource/Order/Creditmemo/Grid.php deleted file mode 100644 index 7d769253351d876da7f1ccba803da175bb195a10..0000000000000000000000000000000000000000 --- a/app/code/Magento/Sales/Model/Resource/Order/Creditmemo/Grid.php +++ /dev/null @@ -1,118 +0,0 @@ -<?php -/** - * Copyright © 2015 Magento. All rights reserved. - * See COPYING.txt for license details. - */ -namespace Magento\Sales\Model\Resource\Order\Creditmemo; - -use Magento\Framework\DB\Adapter\AdapterInterface; -use Magento\Sales\Model\Resource\AbstractGrid; - -/** - * Class Grid - */ -class Grid extends AbstractGrid -{ - /** - * @var string - */ - protected $gridTableName = 'sales_creditmemo_grid'; - - /** - * @var string - */ - protected $creditmemoTableName = 'sales_creditmemo'; - - /** - * Adds new order creditmemos to the grid. - * - * Only order creditmemos that correspond to $value and $field - * parameters will be added. - * - * @param int|string $value - * @param null|string $field - * @return \Zend_Db_Statement_Interface - */ - public function refresh($value, $field = null) - { - $select = $this->getGridOriginSelect() - ->where(($field ?: 'sfc.entity_id') . ' = ?', $value); - - return $this->getConnection()->query( - $this->getConnection() - ->insertFromSelect( - $select, - $this->getTable($this->gridTableName), - [], - AdapterInterface::INSERT_ON_DUPLICATE - ) - ); - } - - /** - * Adds new order creditmemos to the grid. - * - * Only order creditmemos created/updated since the last method call - * will be added. - * - * @return \Zend_Db_Statement_Interface - */ - public function refreshBySchedule() - { - $select = $this->getGridOriginSelect() - ->where('sfc.updated_at >= ?', $this->getLastUpdatedAtValue()); - - return $this->getConnection()->query( - $this->getConnection() - ->insertFromSelect( - $select, - $this->getTable($this->gridTableName), - [], - AdapterInterface::INSERT_ON_DUPLICATE - ) - ); - } - - /** - * Returns select object - * - * @return \Magento\Framework\DB\Select - */ - protected function getGridOriginSelect() - { - return $this->getConnection()->select() - ->from(['sfc' => $this->getTable($this->creditmemoTableName)], []) - ->join(['sfo' => $this->getTable($this->orderTableName)], 'sfc.order_id = sfo.entity_id', []) - ->joinLeft( - ['sba' => $this->getTable($this->addressTableName)], - 'sfo.billing_address_id = sba.entity_id', - [] - ) - ->columns( - [ - 'entity_id' => 'sfc.entity_id', - 'store_id' => 'sfc.store_id', - 'store_to_order_rate' => 'sfc.store_to_order_rate', - 'base_to_order_rate' => 'sfc.base_to_order_rate', - 'grand_total' => 'sfc.grand_total', - 'store_to_base_rate' => 'sfc.store_to_base_rate', - 'base_to_global_rate' => 'sfc.base_to_global_rate', - 'base_grand_total' => 'sfc.base_grand_total', - 'order_id' => 'sfc.order_id', - 'creditmemo_status' => 'sfc.creditmemo_status', - 'state' => 'sfc.state', - 'invoice_id' => 'sfc.invoice_id', - 'store_currency_code' => 'sfc.store_currency_code', - 'order_currency_code' => 'sfc.order_currency_code', - 'base_currency_code' => 'sfc.base_currency_code', - 'global_currency_code' => 'sfc.global_currency_code', - 'increment_id' => 'sfc.increment_id', - 'order_increment_id' => 'sfo.increment_id', - 'created_at' => 'sfc.created_at', - 'updated_at' => 'sfc.updated_at', - 'order_created_at' => 'sfo.created_at', - 'billing_name' => "trim(concat(ifnull(sba.firstname, ''), ' ', ifnull(sba.lastname, '')))", - ] - ); - } -} 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 index c24cfddac98ab0f1e998c390ed099e04a8518234..93ad0a20aedbd02bcccdb460d17ee93a935bdc23 100644 --- 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 @@ -66,30 +66,7 @@ class Collection extends \Magento\Sales\Model\Resource\Order\Creditmemo\Grid\Col */ protected function _initSelect() { - parent::_initSelect(); - $this->addFieldToSelect( - 'entity_id' - )->addFieldToSelect( - 'created_at' - )->addFieldToSelect( - 'increment_id' - )->addFieldToSelect( - 'order_currency_code' - )->addFieldToSelect( - 'store_currency_code' - )->addFieldToSelect( - 'base_currency_code' - )->addFieldToSelect( - 'state' - )->addFieldToSelect( - 'grand_total' - )->addFieldToSelect( - 'base_grand_total' - )->addFieldToSelect( - 'billing_name' - )->setOrderFilter( - $this->getOrder() - ); + parent::_initSelect()->setOrderFilter($this->getOrder()); return $this; } } diff --git a/app/code/Magento/Sales/Model/Resource/Order/Grid.php b/app/code/Magento/Sales/Model/Resource/Order/Grid.php deleted file mode 100644 index 92bccf926f30a0f069e4def9af00929ab7282975..0000000000000000000000000000000000000000 --- a/app/code/Magento/Sales/Model/Resource/Order/Grid.php +++ /dev/null @@ -1,109 +0,0 @@ -<?php -/** - * Copyright © 2015 Magento. All rights reserved. - * See COPYING.txt for license details. - */ -namespace Magento\Sales\Model\Resource\Order; - -use Magento\Framework\DB\Adapter\AdapterInterface; -use Magento\Sales\Model\Resource\AbstractGrid; - -/** - * Class Grid - */ -class Grid extends AbstractGrid -{ - /** - * @var string - */ - protected $gridTableName = 'sales_order_grid'; - - /** - * Adds new orders to the grid. - * - * Only orders that correspond to $value and $field parameters will be added. - * - * @param int|string $value - * @param null|string $field - * @return \Zend_Db_Statement_Interface - */ - public function refresh($value, $field = null) - { - $select = $this->getGridOriginSelect() - ->where(($field ?: 'sfo.entity_id') . ' = ?', $value); - - return $this->getConnection()->query( - $this->getConnection() - ->insertFromSelect( - $select, - $this->getTable($this->gridTableName), - [], - AdapterInterface::INSERT_ON_DUPLICATE - ) - ); - } - - /** - * Adds new orders to the grid. - * - * Only orders created/updated since the last method call will be added. - * - * @return \Zend_Db_Statement_Interface - */ - public function refreshBySchedule() - { - $select = $this->getGridOriginSelect() - ->where('sfo.updated_at >= ?', $this->getLastUpdatedAtValue()); - - return $this->getConnection()->query( - $this->getConnection() - ->insertFromSelect( - $select, - $this->getTable($this->gridTableName), - [], - AdapterInterface::INSERT_ON_DUPLICATE - ) - ); - } - - /** - * Returns select object - * - * @return \Magento\Framework\DB\Select - */ - protected function getGridOriginSelect() - { - return $this->getConnection()->select() - ->from(['sfo' => $this->getTable($this->orderTableName)], []) - ->joinLeft( - ['sba' => $this->getTable($this->addressTableName)], - 'sfo.billing_address_id = sba.entity_id', - [] - ) - ->joinLeft( - ['ssa' => $this->getTable($this->addressTableName)], - 'sfo.shipping_address_id = ssa.entity_id', - [] - ) - ->columns( - [ - 'entity_id' => 'sfo.entity_id', - 'status' => 'sfo.status', - 'store_id' => 'sfo.store_id', - 'store_name' => 'sfo.store_name', - 'customer_id' => 'sfo.customer_id', - 'base_grand_total' => 'sfo.base_grand_total', - 'base_total_paid' => 'sfo.base_total_paid', - 'grand_total' => 'sfo.grand_total', - 'total_paid' => 'sfo.total_paid', - 'increment_id' => 'sfo.increment_id', - 'base_currency_code' => 'sfo.base_currency_code', - 'order_currency_code' => 'sfo.order_currency_code', - 'shipping_name' => "trim(concat(ifnull(ssa.firstname, ''), ' ' ,ifnull(ssa.lastname, '')))", - 'billing_name' => "trim(concat(ifnull(sba.firstname, ''), ' ', ifnull(sba.lastname, '')))", - 'created_at' => 'sfo.created_at', - 'updated_at' => 'sfo.updated_at', - ] - ); - } -} 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 new file mode 100644 index 0000000000000000000000000000000000000000..5a40a3fcb049f5523282111c0db2d770de3e5f2b --- /dev/null +++ b/app/code/Magento/Sales/Model/Resource/Order/Grid/Sql/Concat.php @@ -0,0 +1,50 @@ +<?php +/** + * Copyright © 2015 Magento. All rights reserved. + * See COPYING.txt for license details. + */ +namespace Magento\Sales\Model\Resource\Order\Grid\Sql; + +/** + * Class Concat + */ +class Concat +{ + /** + * @var string[] + */ + protected $columns; + + /** + * @var string + */ + protected $separator; + + /** + * @param string[] $columns + * @param string $separator + */ + public function __construct(array $columns, $separator = ' ') + { + $this->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 new file mode 100644 index 0000000000000000000000000000000000000000..b588c47bda30e9fad0ea103e2a74799e73a00861 --- /dev/null +++ b/app/code/Magento/Sales/Model/Resource/Order/Grid/Sql/SubSelect.php @@ -0,0 +1,101 @@ +<?php +/** + * Copyright © 2015 Magento. All rights reserved. + * See COPYING.txt for license details. + */ +namespace Magento\Sales\Model\Resource\Order\Grid\Sql; + +use Magento\Framework\App\Resource; +use Magento\Framework\DB\Adapter\AdapterInterface; + +/** + * Class Concat + */ +class SubSelect +{ + /** + * @var string + */ + protected $table; + + /** + * @var string[] + */ + protected $columns; + + /** + * @var string + */ + protected $originColumn; + + /** + * @var string + */ + protected $targetColumn; + + /** + * @var \Magento\Framework\App\Resource + */ + protected $resource; + + /** + * @var string + */ + protected $connectionName; + + /** + * @var AdapterInterface + */ + protected $connection; + + /** + * @param Resource $resource + * @param string $connectionName + * @param string $table + * @param string[] $columns + * @param string $originColumn + * @param string $targetColumn + */ + public function __construct( + Resource $resource, + $connectionName, + $table, + array $columns, + $originColumn, + $targetColumn + ) { + $this->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/Invoice/Grid.php b/app/code/Magento/Sales/Model/Resource/Order/Invoice/Grid.php deleted file mode 100644 index e203becb74c7e47a3302e6c77bd2900840fb5029..0000000000000000000000000000000000000000 --- a/app/code/Magento/Sales/Model/Resource/Order/Invoice/Grid.php +++ /dev/null @@ -1,112 +0,0 @@ -<?php -/** - * Copyright © 2015 Magento. All rights reserved. - * See COPYING.txt for license details. - */ -namespace Magento\Sales\Model\Resource\Order\Invoice; - -use Magento\Framework\DB\Adapter\AdapterInterface; -use Magento\Sales\Model\Resource\AbstractGrid; - -/** - * Class Grid - */ -class Grid extends AbstractGrid -{ - /** - * @var string - */ - protected $gridTableName = 'sales_invoice_grid'; - - /** - * @var string - */ - protected $invoiceTableName = 'sales_invoice'; - - /** - * Adds new order invoices to the grid. - * - * Only order invoices that correspond to $value and $field - * parameters will be added. - * - * @param int|string $value - * @param null|string $field - * @return \Zend_Db_Statement_Interface - */ - public function refresh($value, $field = null) - { - $select = $this->getGridOriginSelect() - ->where(($field ?: 'sfi.entity_id') . ' = ?', $value); - - return $this->getConnection()->query( - $this->getConnection() - ->insertFromSelect( - $select, - $this->getTable($this->gridTableName), - [], - AdapterInterface::INSERT_ON_DUPLICATE - ) - ); - } - - /** - * Adds new order invoices to the grid. - * - * Only order invoices created/updated since the last method call - * will be added. - * - * @return \Zend_Db_Statement_Interface - */ - public function refreshBySchedule() - { - $select = $this->getGridOriginSelect() - ->where('sfi.updated_at >= ?', $this->getLastUpdatedAtValue()); - - return $this->getConnection()->query( - $this->getConnection() - ->insertFromSelect( - $select, - $this->getTable($this->gridTableName), - [], - AdapterInterface::INSERT_ON_DUPLICATE - ) - ); - } - - /** - * Returns select object - * - * @return \Magento\Framework\DB\Select - */ - protected function getGridOriginSelect() - { - return $this->getConnection()->select() - ->from(['sfi' => $this->getTable($this->invoiceTableName)], []) - ->join(['sfo' => $this->getTable($this->orderTableName)], 'sfi.order_id = sfo.entity_id', []) - ->joinLeft( - ['sba' => $this->getTable($this->addressTableName)], - 'sfo.billing_address_id = sba.entity_id', - [] - ) - ->columns( - [ - 'entity_id' => 'sfi.entity_id', - 'store_id' => 'sfi.store_id', - 'base_grand_total' => 'sfi.base_grand_total', - 'grand_total' => 'sfi.grand_total', - 'order_id' => 'sfi.order_id', - 'state' => 'sfi.state', - 'store_currency_code' => 'sfi.store_currency_code', - 'order_currency_code' => 'sfi.order_currency_code', - 'base_currency_code' => 'sfi.base_currency_code', - 'global_currency_code' => 'sfi.global_currency_code', - 'increment_id' => 'sfi.increment_id', - 'order_increment_id' => 'sfo.increment_id', - 'created_at' => 'sfi.created_at', - 'updated_at' => 'sfi.updated_at', - 'order_created_at' => 'sfo.created_at', - 'billing_name' => "trim(concat(ifnull(sba.firstname, ''), ' ', ifnull(sba.lastname, '')))", - ] - ); - } -} 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 index 2a79e1c08d2575123511f230b5270453baec11da..c0d9c383cc8d76d44e3e61cb8b9b66104a26904a 100644 --- 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 @@ -62,31 +62,7 @@ class Collection extends \Magento\Sales\Model\Resource\Order\Invoice\Grid\Collec protected function _initSelect() { parent::_initSelect(); - $this->addFieldToSelect( - 'entity_id' - )->addFieldToSelect( - 'created_at' - )->addFieldToSelect( - 'order_id' - )->addFieldToSelect( - 'increment_id' - )->addFieldToSelect( - 'state' - )->addFieldToSelect( - 'grand_total' - )->addFieldToSelect( - 'base_grand_total' - )->addFieldToSelect( - 'store_currency_code' - )->addFieldToSelect( - 'base_currency_code' - )->addFieldToSelect( - 'order_currency_code' - )->addFieldToSelect( - 'billing_name' - )->setOrderFilter( - $this->getOrder() - ); + $this->setOrderFilter($this->getOrder()); return $this; } } diff --git a/app/code/Magento/Sales/Model/Resource/Order/Shipment.php b/app/code/Magento/Sales/Model/Resource/Order/Shipment.php index 32293e81802cc33e1a738ce2acd867b88117d82b..e5afdc4e837bedb3d15fa2d9c94baf62408f41bd 100644 --- a/app/code/Magento/Sales/Model/Resource/Order/Shipment.php +++ b/app/code/Magento/Sales/Model/Resource/Order/Shipment.php @@ -9,8 +9,6 @@ use Magento\Framework\App\Resource as AppResource; use Magento\SalesSequence\Model\Manager; use Magento\Sales\Model\Resource\Attribute; use Magento\Sales\Model\Resource\EntityAbstract as SalesResource; -use Magento\Framework\Model\Resource\Db\VersionControl\Snapshot; -use Magento\Sales\Model\Resource\Order\Shipment\Grid as ShipmentGrid; use Magento\Sales\Model\Spi\ShipmentResourceInterface; /** diff --git a/app/code/Magento/Sales/Model/Resource/Order/Shipment/Grid.php b/app/code/Magento/Sales/Model/Resource/Order/Shipment/Grid.php deleted file mode 100644 index c8c84e615498d0621dcf68acc9fe1d08393e7da7..0000000000000000000000000000000000000000 --- a/app/code/Magento/Sales/Model/Resource/Order/Shipment/Grid.php +++ /dev/null @@ -1,107 +0,0 @@ -<?php -/** - * Copyright © 2015 Magento. All rights reserved. - * See COPYING.txt for license details. - */ -namespace Magento\Sales\Model\Resource\Order\Shipment; - -use Magento\Framework\DB\Adapter\AdapterInterface; -use Magento\Sales\Model\Resource\AbstractGrid; - -/** - * Class Grid - */ -class Grid extends AbstractGrid -{ - /** - * @var string - */ - protected $gridTableName = 'sales_shipment_grid'; - - /** - * @var string - */ - protected $shipmentTableName = 'sales_shipment'; - - /** - * Adds new order shipments to the grid. - * - * Only order shipments that correspond to $value and $field - * parameters will be added. - * - * @param int|string $value - * @param null|string $field - * @return \Zend_Db_Statement_Interface - */ - public function refresh($value, $field = null) - { - $select = $this->getGridOriginSelect() - ->where(($field ?: 'sfs.entity_id') . ' = ?', $value); - - return $this->getConnection()->query( - $this->getConnection() - ->insertFromSelect( - $select, - $this->getTable($this->gridTableName), - [], - AdapterInterface::INSERT_ON_DUPLICATE - ) - ); - } - - /** - * Adds new order shipments to the grid. - * - * Only order shipments created/updated since the last method call - * will be added. - * - * @return \Zend_Db_Statement_Interface - */ - public function refreshBySchedule() - { - $select = $this->getGridOriginSelect() - ->where('sfs.updated_at >= ?', $this->getLastUpdatedAtValue()); - - return $this->getConnection()->query( - $this->getConnection() - ->insertFromSelect( - $select, - $this->getTable($this->gridTableName), - [], - AdapterInterface::INSERT_ON_DUPLICATE - ) - ); - } - - /** - * Returns select object - * - * @return \Magento\Framework\DB\Select - */ - protected function getGridOriginSelect() - { - return $this->getConnection()->select() - ->from(['sfs' => $this->getTable($this->shipmentTableName)], []) - ->join(['sfo' => $this->getTable($this->orderTableName)], 'sfs.order_id = sfo.entity_id', []) - ->joinLeft( - ['ssa' => $this->getTable($this->addressTableName)], - 'sfo.shipping_address_id = ssa.entity_id', - [] - ) - ->columns( - [ - 'entity_id' => 'sfs.entity_id', - 'store_id' => 'sfs.store_id', - 'total_qty' => 'sfs.total_qty', - 'order_id' => 'sfs.order_id', - 'shipment_status' => 'sfs.shipment_status', - 'increment_id' => 'sfs.increment_id', - 'order_increment_id' => 'sfo.increment_id', - 'created_at' => 'sfs.created_at', - 'updated_at' => 'sfs.updated_at', - 'order_created_at' => 'sfo.created_at', - 'shipping_name' => "trim(concat(ifnull(ssa.firstname, ''), ' ' ,ifnull(ssa.lastname, '')))", - ] - ); - } -} 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 index d61ea0fbd7c82fb0455ffe6d5c502be45f0a4afe..6abb188c1b7edda39c82044b96fa265804e9556f 100644 --- 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 @@ -67,19 +67,7 @@ class Collection extends \Magento\Sales\Model\Resource\Order\Shipment\Grid\Colle protected function _initSelect() { parent::_initSelect(); - $this->addFieldToSelect( - 'entity_id' - )->addFieldToSelect( - 'created_at' - )->addFieldToSelect( - 'increment_id' - )->addFieldToSelect( - 'total_qty' - )->addFieldToSelect( - 'shipping_name' - )->setOrderFilter( - $this->getOrder() - ); + $this->setOrderFilter($this->getOrder()); return $this; } } diff --git a/app/code/Magento/Sales/Setup/InstallSchema.php b/app/code/Magento/Sales/Setup/InstallSchema.php index edc0cf10a36e942cae238556aa7fa0872c177cc3..afa4460d56fa6d084051b95f1bb19afb60b2c95b 100644 --- a/app/code/Magento/Sales/Setup/InstallSchema.php +++ b/app/code/Magento/Sales/Setup/InstallSchema.php @@ -989,6 +989,66 @@ class InstallSchema implements InstallSchemaInterface null, [], 'Updated At' + )->addColumn( + 'billing_address', + \Magento\Framework\DB\Ddl\Table::TYPE_TEXT, + 255, + [], + 'Billing Address' + )->addColumn( + 'shipping_address', + \Magento\Framework\DB\Ddl\Table::TYPE_TEXT, + 255, + [], + 'Shipping Address' + )->addColumn( + 'shipping_information', + \Magento\Framework\DB\Ddl\Table::TYPE_TEXT, + 255, + [], + 'Shipping Method Name' + )->addColumn( + 'customer_email', + \Magento\Framework\DB\Ddl\Table::TYPE_TEXT, + 255, + [], + 'Customer Email' + )->addColumn( + 'customer_group', + \Magento\Framework\DB\Ddl\Table::TYPE_TEXT, + 255, + [], + 'Customer Group' + )->addColumn( + 'subtotal', + \Magento\Framework\DB\Ddl\Table::TYPE_DECIMAL, + '12,4', + [], + 'Subtotal' + )->addColumn( + 'shipping_and_handling', + \Magento\Framework\DB\Ddl\Table::TYPE_DECIMAL, + '12,4', + [], + 'Shipping and handling amount' + )->addColumn( + 'customer_name', + \Magento\Framework\DB\Ddl\Table::TYPE_TEXT, + 255, + [], + 'Customer Name' + )->addColumn( + 'payment_method', + \Magento\Framework\DB\Ddl\Table::TYPE_TEXT, + 255, + [], + 'Payment Method' + )->addColumn( + 'total_refunded', + \Magento\Framework\DB\Ddl\Table::TYPE_DECIMAL, + '12,4', + [], + 'Total Refunded' )->addIndex( $installer->getIdxName('sales_order_grid', ['status']), ['status'] @@ -1030,24 +1090,30 @@ class InstallSchema implements InstallSchemaInterface )->addIndex( $installer->getIdxName('sales_order_grid', ['updated_at']), ['updated_at'] - )->addForeignKey( - $installer->getFkName('sales_order_grid', 'customer_id', 'customer_entity', 'entity_id'), - 'customer_id', - $installer->getTable('customer_entity'), - 'entity_id', - \Magento\Framework\DB\Ddl\Table::ACTION_SET_NULL - )->addForeignKey( - $installer->getFkName('sales_order_grid', 'entity_id', 'sales_order', 'entity_id'), - 'entity_id', - $installer->getTable('sales_order'), - 'entity_id', - \Magento\Framework\DB\Ddl\Table::ACTION_CASCADE - )->addForeignKey( - $installer->getFkName('sales_order_grid', 'store_id', 'store', 'store_id'), - 'store_id', - $installer->getTable('store'), - 'store_id', - \Magento\Framework\DB\Ddl\Table::ACTION_SET_NULL + )->addIndex( + $installer->getIdxName( + 'sales_order_grid', + [ + 'increment_id', + 'billing_name', + 'shipping_name', + 'shipping_address', + 'billing_address', + 'customer_name', + 'customer_email' + ], + \Magento\Framework\DB\Adapter\AdapterInterface::INDEX_TYPE_FULLTEXT + ), + [ + 'increment_id', + 'billing_name', + 'shipping_name', + 'shipping_address', + 'billing_address', + 'customer_name', + 'customer_email' + ], + ['type' => \Magento\Framework\DB\Adapter\AdapterInterface::INDEX_TYPE_FULLTEXT] )->setComment( 'Sales Flat Order Grid' ); @@ -2185,6 +2251,8 @@ class InstallSchema implements InstallSchemaInterface /** * Create table 'sales_shipment_grid' + * + * @add order_id, shipping_description */ $table = $installer->getConnection()->newTable( $installer->getTable('sales_shipment_grid') @@ -2194,6 +2262,12 @@ class InstallSchema implements InstallSchemaInterface null, ['unsigned' => true, 'nullable' => false, 'primary' => true], 'Entity Id' + )->addColumn( + 'increment_id', + \Magento\Framework\DB\Ddl\Table::TYPE_TEXT, + 50, + [], + 'Increment Id' )->addColumn( 'store_id', \Magento\Framework\DB\Ddl\Table::TYPE_SMALLINT, @@ -2201,17 +2275,35 @@ class InstallSchema implements InstallSchemaInterface ['unsigned' => true], 'Store Id' )->addColumn( - 'total_qty', - \Magento\Framework\DB\Ddl\Table::TYPE_DECIMAL, - '12,4', - [], - 'Total Qty' + 'order_increment_id', + \Magento\Framework\DB\Ddl\Table::TYPE_TEXT, + 32, + ['nullable' => false], + 'Order Increment Id' )->addColumn( 'order_id', \Magento\Framework\DB\Ddl\Table::TYPE_INTEGER, null, ['unsigned' => true, 'nullable' => false], 'Order Id' + )->addColumn( + 'order_created_at', + \Magento\Framework\DB\Ddl\Table::TYPE_TIMESTAMP, + null, + ['nullable' => false], + 'Order Increment Id' + )->addColumn( + 'customer_name', + \Magento\Framework\DB\Ddl\Table::TYPE_TEXT, + 128, + ['nullable' => false], + 'Customer Name' + )->addColumn( + 'total_qty', + \Magento\Framework\DB\Ddl\Table::TYPE_DECIMAL, + '12,4', + [], + 'Total Qty' )->addColumn( 'shipment_status', \Magento\Framework\DB\Ddl\Table::TYPE_INTEGER, @@ -2219,17 +2311,59 @@ class InstallSchema implements InstallSchemaInterface [], 'Shipment Status' )->addColumn( - 'increment_id', + 'order_status', \Magento\Framework\DB\Ddl\Table::TYPE_TEXT, - 50, + 32, [], - 'Increment Id' + 'Order' )->addColumn( - 'order_increment_id', + 'billing_address', \Magento\Framework\DB\Ddl\Table::TYPE_TEXT, - 50, + 255, [], - 'Order Increment Id' + 'Billing Address' + )->addColumn( + 'shipping_address', + \Magento\Framework\DB\Ddl\Table::TYPE_TEXT, + 255, + [], + 'Shipping Address' + )->addColumn( + 'billing_name', + \Magento\Framework\DB\Ddl\Table::TYPE_TEXT, + 128, + [], + 'Billing Name' + )->addColumn( + 'shipping_name', + \Magento\Framework\DB\Ddl\Table::TYPE_TEXT, + 128, + [], + 'Shipping Name' + )->addColumn( + 'customer_email', + \Magento\Framework\DB\Ddl\Table::TYPE_TEXT, + 128, + [], + 'Customer Email' + )->addColumn( + 'customer_group_id', + \Magento\Framework\DB\Ddl\Table::TYPE_SMALLINT, + null, + [], + 'Customer Group Id' + )->addColumn( + 'payment_method', + \Magento\Framework\DB\Ddl\Table::TYPE_TEXT, + 32, + [], + 'Payment Method' + )->addColumn( + 'shipping_information', + \Magento\Framework\DB\Ddl\Table::TYPE_TEXT, + 255, + [], + 'Shipping Method Name' )->addColumn( 'created_at', \Magento\Framework\DB\Ddl\Table::TYPE_TIMESTAMP, @@ -2237,40 +2371,52 @@ class InstallSchema implements InstallSchemaInterface [], 'Created At' )->addColumn( - 'order_created_at', + 'updated_at', \Magento\Framework\DB\Ddl\Table::TYPE_TIMESTAMP, null, [], - 'Order Created At' - )->addColumn( - 'shipping_name', - \Magento\Framework\DB\Ddl\Table::TYPE_TEXT, - 255, - [], - 'Shipping Name' + 'Updated At' + )->addIndex( + $installer->getIdxName( + 'sales_shipment_grid', + [ + 'increment_id', + 'store_id' + ], + \Magento\Framework\DB\Adapter\AdapterInterface::INDEX_TYPE_UNIQUE + ), + ['increment_id', 'store_id'], + ['type' => \Magento\Framework\DB\Adapter\AdapterInterface::INDEX_TYPE_UNIQUE] )->addIndex( - $installer->getIdxName('sales_shipment_grid', ['store_id']), + $installer->getIdxName( + 'sales_shipment_grid', + ['store_id'] + ), ['store_id'] )->addIndex( - $installer->getIdxName('sales_shipment_grid', ['total_qty']), + $installer->getIdxName( + 'sales_shipment_grid', + ['total_qty'] + ), ['total_qty'] )->addIndex( - $installer->getIdxName('sales_shipment_grid', ['order_id']), - ['order_id'] + $installer->getIdxName( + 'sales_shipment_grid', + ['order_increment_id'] + ), + ['order_increment_id'] )->addIndex( - $installer->getIdxName('sales_shipment_grid', ['shipment_status']), + $installer->getIdxName( + 'sales_shipment_grid', + ['shipment_status'] + ), ['shipment_status'] )->addIndex( $installer->getIdxName( 'sales_shipment_grid', - ['increment_id'], - \Magento\Framework\DB\Adapter\AdapterInterface::INDEX_TYPE_UNIQUE + ['order_status'] ), - ['increment_id'], - ['type' => \Magento\Framework\DB\Adapter\AdapterInterface::INDEX_TYPE_UNIQUE] - )->addIndex( - $installer->getIdxName('sales_shipment_grid', ['order_increment_id']), - ['order_increment_id'] + ['order_status'] )->addIndex( $installer->getIdxName('sales_shipment_grid', ['created_at']), ['created_at'] @@ -2280,18 +2426,33 @@ class InstallSchema implements InstallSchemaInterface )->addIndex( $installer->getIdxName('sales_shipment_grid', ['shipping_name']), ['shipping_name'] - )->addForeignKey( - $installer->getFkName('sales_shipment_grid', 'entity_id', 'sales_shipment', 'entity_id'), - 'entity_id', - $installer->getTable('sales_shipment'), - 'entity_id', - \Magento\Framework\DB\Ddl\Table::ACTION_CASCADE - )->addForeignKey( - $installer->getFkName('sales_shipment_grid', 'store_id', 'store', 'store_id'), - 'store_id', - $installer->getTable('store'), - 'store_id', - \Magento\Framework\DB\Ddl\Table::ACTION_SET_NULL + )->addIndex( + $installer->getIdxName('sales_shipment_grid', ['billing_name']), + ['billing_name'] + )->addIndex( + $installer->getIdxName( + 'sales_shipment_grid', + [ + 'increment_id', + 'order_increment_id', + 'shipping_name', + 'customer_name', + 'customer_email', + 'billing_address', + 'shipping_address' + ], + \Magento\Framework\DB\Adapter\AdapterInterface::INDEX_TYPE_FULLTEXT + ), + [ + 'increment_id', + 'order_increment_id', + 'shipping_name', + 'customer_name', + 'customer_email', + 'billing_address', + 'shipping_address' + ], + ['type' => \Magento\Framework\DB\Adapter\AdapterInterface::INDEX_TYPE_FULLTEXT] )->setComment( 'Sales Flat Shipment Grid' ); @@ -2857,6 +3018,18 @@ class InstallSchema implements InstallSchemaInterface null, ['unsigned' => true, 'nullable' => false, 'primary' => true], 'Entity Id' + )->addColumn( + 'increment_id', + \Magento\Framework\DB\Ddl\Table::TYPE_TEXT, + 50, + [], + 'Increment Id' + )->addColumn( + 'state', + \Magento\Framework\DB\Ddl\Table::TYPE_INTEGER, + null, + [], + 'State' )->addColumn( 'store_id', \Magento\Framework\DB\Ddl\Table::TYPE_SMALLINT, @@ -2864,17 +3037,11 @@ class InstallSchema implements InstallSchemaInterface ['unsigned' => true], 'Store Id' )->addColumn( - 'base_grand_total', - \Magento\Framework\DB\Ddl\Table::TYPE_DECIMAL, - '12,4', - [], - 'Base Grand Total' - )->addColumn( - 'grand_total', - \Magento\Framework\DB\Ddl\Table::TYPE_DECIMAL, - '12,4', + 'store_name', + \Magento\Framework\DB\Ddl\Table::TYPE_TEXT, + 255, [], - 'Grand Total' + 'Store Name' )->addColumn( 'order_id', \Magento\Framework\DB\Ddl\Table::TYPE_INTEGER, @@ -2882,11 +3049,41 @@ class InstallSchema implements InstallSchemaInterface ['unsigned' => true, 'nullable' => false], 'Order Id' )->addColumn( - 'state', - \Magento\Framework\DB\Ddl\Table::TYPE_INTEGER, + 'order_increment_id', + \Magento\Framework\DB\Ddl\Table::TYPE_TEXT, + 50, + [], + 'Order Increment Id' + )->addColumn( + 'order_created_at', + \Magento\Framework\DB\Ddl\Table::TYPE_TIMESTAMP, null, [], - 'State' + 'Order Created At' + )->addColumn( + 'customer_name', + \Magento\Framework\DB\Ddl\Table::TYPE_TEXT, + 255, + [], + 'Customer Name' + )->addColumn( + 'customer_email', + \Magento\Framework\DB\Ddl\Table::TYPE_TEXT, + 255, + [], + 'Customer Email' + )->addColumn( + 'customer_group_id', + \Magento\Framework\DB\Ddl\Table::TYPE_SMALLINT, + null, + [], + 'Customer Group Id' + )->addColumn( + 'payment_method', + \Magento\Framework\DB\Ddl\Table::TYPE_TEXT, + 128, + [], + 'Payment Method' )->addColumn( 'store_currency_code', \Magento\Framework\DB\Ddl\Table::TYPE_TEXT, @@ -2912,35 +3109,53 @@ class InstallSchema implements InstallSchemaInterface [], 'Global Currency Code' )->addColumn( - 'increment_id', + 'billing_name', \Magento\Framework\DB\Ddl\Table::TYPE_TEXT, - 50, + 255, [], - 'Increment Id' + 'Billing Name' )->addColumn( - 'order_increment_id', + 'billing_address', \Magento\Framework\DB\Ddl\Table::TYPE_TEXT, - 50, - [], - 'Order Increment Id' - )->addColumn( - 'created_at', - \Magento\Framework\DB\Ddl\Table::TYPE_TIMESTAMP, - null, + 255, [], - 'Created At' + 'Billing Address' )->addColumn( - 'order_created_at', - \Magento\Framework\DB\Ddl\Table::TYPE_TIMESTAMP, - null, + 'shipping_address', + \Magento\Framework\DB\Ddl\Table::TYPE_TEXT, + 255, [], - 'Order Created At' + 'Shipping Address' )->addColumn( - 'billing_name', + 'shipping_information', \Magento\Framework\DB\Ddl\Table::TYPE_TEXT, 255, [], - 'Billing Name' + 'Shipping Method Name' + )->addColumn( + 'subtotal', + \Magento\Framework\DB\Ddl\Table::TYPE_DECIMAL, + '12,4', + [], + 'Subtotal' + )->addColumn( + 'shipping_and_handling', + \Magento\Framework\DB\Ddl\Table::TYPE_DECIMAL, + '12,4', + [], + 'Shipping and handling amount' + )->addColumn( + 'grand_total', + \Magento\Framework\DB\Ddl\Table::TYPE_DECIMAL, + '12,4', + [], + 'Grand Total' + )->addColumn( + 'created_at', + \Magento\Framework\DB\Ddl\Table::TYPE_TIMESTAMP, + null, + [], + 'Created At' )->addIndex( $installer->getIdxName('sales_invoice_grid', ['store_id']), ['store_id'] @@ -2956,10 +3171,10 @@ class InstallSchema implements InstallSchemaInterface )->addIndex( $installer->getIdxName( 'sales_invoice_grid', - ['increment_id'], + ['increment_id', 'store_id'], \Magento\Framework\DB\Adapter\AdapterInterface::INDEX_TYPE_UNIQUE ), - ['increment_id'], + ['increment_id', 'store_id'], ['type' => \Magento\Framework\DB\Adapter\AdapterInterface::INDEX_TYPE_UNIQUE] )->addIndex( $installer->getIdxName('sales_invoice_grid', ['order_increment_id']), @@ -2973,18 +3188,30 @@ class InstallSchema implements InstallSchemaInterface )->addIndex( $installer->getIdxName('sales_invoice_grid', ['billing_name']), ['billing_name'] - )->addForeignKey( - $installer->getFkName('sales_invoice_grid', 'entity_id', 'sales_invoice', 'entity_id'), - 'entity_id', - $installer->getTable('sales_invoice'), - 'entity_id', - \Magento\Framework\DB\Ddl\Table::ACTION_CASCADE - )->addForeignKey( - $installer->getFkName('sales_invoice_grid', 'store_id', 'store', 'store_id'), - 'store_id', - $installer->getTable('store'), - 'store_id', - \Magento\Framework\DB\Ddl\Table::ACTION_SET_NULL + )->addIndex( + $installer->getIdxName( + 'sales_invoice_grid', + [ + 'increment_id', + 'order_increment_id', + 'billing_name', + 'billing_address', + 'shipping_address', + 'customer_name', + 'customer_email' + ], + \Magento\Framework\DB\Adapter\AdapterInterface::INDEX_TYPE_FULLTEXT + ), + [ + 'increment_id', + 'order_increment_id', + 'billing_name', + 'billing_address', + 'shipping_address', + 'customer_name', + 'customer_email' + ], + ['type' => \Magento\Framework\DB\Adapter\AdapterInterface::INDEX_TYPE_FULLTEXT] )->setComment( 'Sales Flat Invoice Grid' ); @@ -3562,41 +3789,47 @@ class InstallSchema implements InstallSchemaInterface ['unsigned' => true, 'nullable' => false, 'primary' => true], 'Entity Id' )->addColumn( - 'store_id', - \Magento\Framework\DB\Ddl\Table::TYPE_SMALLINT, - null, - ['unsigned' => true], - 'Store Id' + 'increment_id', + \Magento\Framework\DB\Ddl\Table::TYPE_TEXT, + 50, + [], + 'Increment Id' )->addColumn( - 'store_to_order_rate', - \Magento\Framework\DB\Ddl\Table::TYPE_DECIMAL, - '12,4', + 'created_at', + \Magento\Framework\DB\Ddl\Table::TYPE_TIMESTAMP, + null, [], - 'Store To Order Rate' + 'Created At' )->addColumn( - 'base_to_order_rate', - \Magento\Framework\DB\Ddl\Table::TYPE_DECIMAL, - '12,4', + 'order_id', + \Magento\Framework\DB\Ddl\Table::TYPE_INTEGER, + null, + ['unsigned' => true, 'nullable' => false], + 'Order Id' + )->addColumn( + 'order_increment_id', + \Magento\Framework\DB\Ddl\Table::TYPE_TEXT, + 50, [], - 'Base To Order Rate' + 'Order Increment Id' )->addColumn( - 'grand_total', - \Magento\Framework\DB\Ddl\Table::TYPE_DECIMAL, - '12,4', + 'order_created_at', + \Magento\Framework\DB\Ddl\Table::TYPE_TIMESTAMP, + null, [], - 'Grand Total' + 'Order Created At' )->addColumn( - 'store_to_base_rate', - \Magento\Framework\DB\Ddl\Table::TYPE_DECIMAL, - '12,4', + 'billing_name', + \Magento\Framework\DB\Ddl\Table::TYPE_TEXT, + 255, [], - 'Store To Base Rate' + 'Billing Name' )->addColumn( - 'base_to_global_rate', - \Magento\Framework\DB\Ddl\Table::TYPE_DECIMAL, - '12,4', + 'state', + \Magento\Framework\DB\Ddl\Table::TYPE_INTEGER, + null, [], - 'Base To Global Rate' + 'Status' )->addColumn( 'base_grand_total', \Magento\Framework\DB\Ddl\Table::TYPE_DECIMAL, @@ -3604,108 +3837,99 @@ class InstallSchema implements InstallSchemaInterface [], 'Base Grand Total' )->addColumn( - 'order_id', - \Magento\Framework\DB\Ddl\Table::TYPE_INTEGER, - null, - ['unsigned' => true, 'nullable' => false], - 'Order Id' - )->addColumn( - 'creditmemo_status', - \Magento\Framework\DB\Ddl\Table::TYPE_INTEGER, - null, + 'order_status', + \Magento\Framework\DB\Ddl\Table::TYPE_TEXT, + 32, [], - 'Creditmemo Status' + 'Order Status' )->addColumn( - 'state', - \Magento\Framework\DB\Ddl\Table::TYPE_INTEGER, + 'store_id', + \Magento\Framework\DB\Ddl\Table::TYPE_SMALLINT, null, - [], - 'State' + ['unsigned' => true], + 'Store Id' )->addColumn( - 'invoice_id', - \Magento\Framework\DB\Ddl\Table::TYPE_INTEGER, - null, + 'billing_address', + \Magento\Framework\DB\Ddl\Table::TYPE_TEXT, + 255, [], - 'Invoice Id' + 'Billing Address' )->addColumn( - 'store_currency_code', + 'shipping_address', \Magento\Framework\DB\Ddl\Table::TYPE_TEXT, - 3, + 255, [], - 'Store Currency Code' + 'Shipping Address' )->addColumn( - 'order_currency_code', + 'customer_name', \Magento\Framework\DB\Ddl\Table::TYPE_TEXT, - 3, - [], - 'Order Currency Code' + 128, + ['nullable' => false], + 'Customer Name' )->addColumn( - 'base_currency_code', + 'customer_email', \Magento\Framework\DB\Ddl\Table::TYPE_TEXT, - 3, + 128, [], - 'Base Currency Code' + 'Customer Email' )->addColumn( - 'global_currency_code', - \Magento\Framework\DB\Ddl\Table::TYPE_TEXT, - 3, + 'customer_group_id', + \Magento\Framework\DB\Ddl\Table::TYPE_SMALLINT, + null, [], - 'Global Currency Code' + 'Customer Group Id' )->addColumn( - 'increment_id', + 'payment_method', \Magento\Framework\DB\Ddl\Table::TYPE_TEXT, - 50, + 32, [], - 'Increment Id' + 'Payment Method' )->addColumn( - 'order_increment_id', + 'shipping_information', \Magento\Framework\DB\Ddl\Table::TYPE_TEXT, - 50, + 255, [], - 'Order Increment Id' + 'Shipping Method Name' )->addColumn( - 'created_at', - \Magento\Framework\DB\Ddl\Table::TYPE_TIMESTAMP, - null, + 'subtotal', + \Magento\Framework\DB\Ddl\Table::TYPE_DECIMAL, + '12,4', [], - 'Created At' + 'Subtotal' )->addColumn( - 'order_created_at', - \Magento\Framework\DB\Ddl\Table::TYPE_TIMESTAMP, - null, + 'shipping_and_handling', + \Magento\Framework\DB\Ddl\Table::TYPE_DECIMAL, + '12,4', [], - 'Order Created At' + 'Shipping and handling amount' )->addColumn( - 'billing_name', - \Magento\Framework\DB\Ddl\Table::TYPE_TEXT, - 255, + 'adjustment_positive', + \Magento\Framework\DB\Ddl\Table::TYPE_DECIMAL, + '12,4', [], - 'Billing Name' - )->addIndex( - $installer->getIdxName('sales_creditmemo_grid', ['store_id']), - ['store_id'] - )->addIndex( - $installer->getIdxName('sales_creditmemo_grid', ['grand_total']), - ['grand_total'] - )->addIndex( - $installer->getIdxName('sales_creditmemo_grid', ['base_grand_total']), - ['base_grand_total'] - )->addIndex( - $installer->getIdxName('sales_creditmemo_grid', ['order_id']), - ['order_id'] - )->addIndex( - $installer->getIdxName('sales_creditmemo_grid', ['creditmemo_status']), - ['creditmemo_status'] - )->addIndex( - $installer->getIdxName('sales_creditmemo_grid', ['state']), - ['state'] + 'Adjustment Positive' + )->addColumn( + 'adjustment_negative', + \Magento\Framework\DB\Ddl\Table::TYPE_DECIMAL, + '12,4', + [], + 'Adjustment Negative' + )->addColumn( + 'order_base_grand_total', + \Magento\Framework\DB\Ddl\Table::TYPE_DECIMAL, + '12,4', + [], + 'Order Grand Total' )->addIndex( $installer->getIdxName( 'sales_creditmemo_grid', - ['increment_id'], + [ + 'increment_id', + 'store_id' + ], \Magento\Framework\DB\Adapter\AdapterInterface::INDEX_TYPE_UNIQUE ), - ['increment_id'], + ['increment_id', 'store_id'], ['type' => \Magento\Framework\DB\Adapter\AdapterInterface::INDEX_TYPE_UNIQUE] )->addIndex( $installer->getIdxName('sales_creditmemo_grid', ['order_increment_id']), @@ -3716,21 +3940,51 @@ class InstallSchema implements InstallSchemaInterface )->addIndex( $installer->getIdxName('sales_creditmemo_grid', ['order_created_at']), ['order_created_at'] + )->addIndex( + $installer->getIdxName('sales_creditmemo_grid', ['state']), + ['state'] )->addIndex( $installer->getIdxName('sales_creditmemo_grid', ['billing_name']), ['billing_name'] - )->addForeignKey( - $installer->getFkName('sales_creditmemo_grid', 'entity_id', 'sales_creditmemo', 'entity_id'), - 'entity_id', - $installer->getTable('sales_creditmemo'), - 'entity_id', - \Magento\Framework\DB\Ddl\Table::ACTION_CASCADE - )->addForeignKey( - $installer->getFkName('sales_creditmemo_grid', 'store_id', 'store', 'store_id'), - 'store_id', - $installer->getTable('store'), - 'store_id', - \Magento\Framework\DB\Ddl\Table::ACTION_SET_NULL + )->addIndex( + $installer->getIdxName('sales_creditmemo_grid', ['order_status']), + ['order_status'] + )->addIndex( + $installer->getIdxName('sales_creditmemo_grid', ['base_grand_total']), + ['base_grand_total'] + )->addIndex( + $installer->getIdxName('sales_creditmemo_grid', ['store_id']), + ['store_id'] + )->addIndex( + $installer->getIdxName('sales_creditmemo_grid', ['order_base_grand_total']), + ['order_base_grand_total'] + )->addIndex( + $installer->getIdxName('sales_creditmemo_grid', ['order_id']), + ['order_id'] + )->addIndex( + $installer->getIdxName( + 'sales_creditmemo_grid', + [ + 'increment_id', + 'order_increment_id', + 'billing_name', + 'billing_address', + 'shipping_address', + 'customer_name', + 'customer_email' + ], + \Magento\Framework\DB\Adapter\AdapterInterface::INDEX_TYPE_FULLTEXT + ), + [ + 'increment_id', + 'order_increment_id', + 'billing_name', + 'billing_address', + 'shipping_address', + 'customer_name', + 'customer_email' + ], + ['type' => \Magento\Framework\DB\Adapter\AdapterInterface::INDEX_TYPE_FULLTEXT] )->setComment( 'Sales Flat Creditmemo Grid' ); diff --git a/app/code/Magento/Sales/Setup/UpgradeSchema.php b/app/code/Magento/Sales/Setup/UpgradeSchema.php index 99823503bd2e1abe1ba888584a5d47885e66de6e..58d07c9d1bba2e1348a1218895e7bc6e16f9888e 100644 --- a/app/code/Magento/Sales/Setup/UpgradeSchema.php +++ b/app/code/Magento/Sales/Setup/UpgradeSchema.php @@ -119,10 +119,7 @@ class UpgradeSchema implements UpgradeSchemaInterface 'sales_invoice', 'sales_order', 'sales_shipment', - 'sales_creditmemo_grid', - 'sales_invoice_grid', 'sales_order_grid', - 'sales_shipment_grid', ]; foreach ($dropIncrementIndexTables as $table) { $connection->dropIndex( @@ -139,10 +136,7 @@ class UpgradeSchema implements UpgradeSchemaInterface 'sales_invoice', 'sales_order', 'sales_shipment', - 'sales_creditmemo_grid', - 'sales_invoice_grid', 'sales_order_grid', - 'sales_shipment_grid', ]; foreach ($createIncrementIndexTables as $table) { $connection->addIndex( 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 new file mode 100644 index 0000000000000000000000000000000000000000..98ba820ade67fd143dabb1215e1462ad9ff59cce --- /dev/null +++ b/app/code/Magento/Sales/Test/Unit/Block/Adminhtml/Order/GridTest.php @@ -0,0 +1,128 @@ +<?php +/** + * Copyright © 2015 Magento. All rights reserved. + * See COPYING.txt for license details. + */ + +namespace Magento\Sales\Test\Unit\Block\Adminhtml\Order; + +/** + * Class GridTest + */ +class GridTest extends \PHPUnit_Framework_TestCase +{ + /** + * @var \PHPUnit_Framework_MockObject_MockObject + */ + protected $componentFactory; + + /** + * @var \Magento\Sales\Block\Adminhtml\Order\Grid + */ + protected $block; + + /** + * @var \PHPUnit_Framework_MockObject_MockObject + */ + protected $requestMock; + + /** + * @var \PHPUnit_Framework_MockObject_MockObject + */ + protected $contextMock; + + protected function setUp() + { + $this->componentFactory = $this->getMockBuilder('Magento\Framework\View\Element\UiComponentFactory') + ->disableOriginalConstructor() + ->getMock(); + $this->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 = [ + 'componentFactory' => $this->componentFactory, + '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() + { + $contextMock = $this->getMockBuilder('Magento\Framework\View\Element\UiComponent\ContextInterface') + ->disableOriginalConstructor() + ->getMock(); + $collectionMock = $this->getMockBuilder('Magento\Sales\Model\Resource\Order\Grid\Collection') + ->disableOriginalConstructor() + ->getMock(); + $providerName = 'Magento\Framework\View\Element\UiComponent\DataProvider\DataProvider'; + $dataProviderMock = $this->getMockBuilder($providerName) + ->disableOriginalConstructor() + ->getMock(); + $componentMock = $this->getMockBuilder('Magento\Framework\View\Element\UiComponentInterface') + ->disableOriginalConstructor() + ->getMock(); + $childComponentMock = $this->getMockBuilder('Magento\Framework\View\Element\UiComponentInterface') + ->disableOriginalConstructor() + ->getMock(); + $this->componentFactory->expects($this->once()) + ->method('create') + ->with('sales_order_grid') + ->willReturn($componentMock); + $componentMock->expects($this->once()) + ->method('getChildComponents') + ->willReturn([$childComponentMock]); + $childComponentMock->expects($this->once()) + ->method('getChildComponents') + ->willReturn([]); + $childComponentMock->expects($this->once()) + ->method('prepare'); + $componentMock->expects($this->once()) + ->method('render'); + $componentMock->expects($this->once()) + ->method('getContext') + ->willReturn($contextMock); + $contextMock->expects($this->once()) + ->method('getDataProvider') + ->willReturn($dataProviderMock); + $dataProviderMock->expects($this->once()) + ->method('getCollection') + ->willReturn($collectionMock); + $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->assertInstanceOf( + 'Magento\Sales\Model\Resource\Order\Grid\Collection', + $this->block->getPreparedCollection() + ); + } +} 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 new file mode 100644 index 0000000000000000000000000000000000000000..69b02f1522b24bbc935028ec823c8499fad2d918 --- /dev/null +++ b/app/code/Magento/Sales/Test/Unit/Controller/Adminhtml/Order/MassCancelTest.php @@ -0,0 +1,365 @@ +<?php +/** + * Copyright © 2015 Magento. All rights reserved. + * See COPYING.txt for license details. + */ + +namespace Magento\Sales\Test\Unit\Controller\Adminhtml\Order; + +use Magento\Framework\App\Action\Context; +use Magento\Framework\TestFramework\Unit\Helper\ObjectManager as ObjectManagerHelper; + +/** + * Class MassCancelTest + * @SuppressWarnings(PHPMD.CouplingBetweenObjects) + */ +class MassCancelTest extends \PHPUnit_Framework_TestCase +{ + /** + * @var \Magento\Sales\Controller\Adminhtml\Order\MassCancel + */ + protected $massAction; + + /** + * @var Context|\PHPUnit_Framework_MockObject_MockObject + */ + protected $contextMock; + + /** + * @var \Magento\Backend\Model\View\Result\Redirect|\PHPUnit_Framework_MockObject_MockObject + */ + protected $resultRedirectMock; + + /** + * @var \Magento\Framework\App\Request\Http|\PHPUnit_Framework_MockObject_MockObject + */ + protected $requestMock; + + /** + * @var \Magento\Framework\App\ResponseInterface|\PHPUnit_Framework_MockObject_MockObject + */ + protected $responseMock; + + /** + * @var \Magento\Framework\Message\Manager|\PHPUnit_Framework_MockObject_MockObject + */ + protected $messageManagerMock; + + /** + * @var \Magento\Framework\ObjectManager\ObjectManager|\PHPUnit_Framework_MockObject_MockObject + */ + protected $objectManagerMock; + + /** + * @var \Magento\Backend\Model\Session|\PHPUnit_Framework_MockObject_MockObject + */ + protected $sessionMock; + + /** + * @var \Magento\Framework\App\ActionFlag|\PHPUnit_Framework_MockObject_MockObject + */ + protected $actionFlagMock; + + /** + * @var \Magento\Backend\Helper\Data|\PHPUnit_Framework_MockObject_MockObject + */ + protected $helperMock; + + /** + * @var \Magento\Sales\Model\Order|\PHPUnit_Framework_MockObject_MockObject + */ + protected $orderMock; + + /** + * @var \PHPUnit_Framework_MockObject_MockObject + */ + protected $orderCollectionMock; + + 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->objectManagerMock = $this->getMock( + 'Magento\Framework\ObjectManager\ObjectManager', + ['create'], + [], + '', + false + ); + $this->messageManagerMock = $this->getMock( + 'Magento\Framework\Message\Manager', + ['addSuccess', 'addError'], + [], + '', + false + ); + + $this->orderCollectionMock = $this->getMockBuilder('Magento\Sales\Model\Resource\Order\Collection') + ->disableOriginalConstructor() + ->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); + $this->resultRedirectMock = $this->getMock('Magento\Backend\Model\View\Result\Redirect', [], [], '', false); + $resultRedirectFactory->expects($this->any())->method('create')->willReturn($this->resultRedirectMock); + + $redirectMock = $this->getMockBuilder('Magento\Backend\Model\View\Result\Redirect') + ->disableOriginalConstructor() + ->getMock(); + + $resultFactoryMock = $this->getMockBuilder('Magento\Framework\Controller\ResultFactory') + ->disableOriginalConstructor() + ->getMock(); + $resultFactoryMock->expects($this->any()) + ->method('create') + ->with(\Magento\Framework\Controller\ResultFactory::TYPE_REDIRECT) + ->willReturn($redirectMock); + + $this->contextMock->expects($this->once())->method('getMessageManager')->willReturn($this->messageManagerMock); + $this->contextMock->expects($this->once())->method('getRequest')->willReturn($this->requestMock); + $this->contextMock->expects($this->once())->method('getResponse')->willReturn($this->responseMock); + $this->contextMock->expects($this->once())->method('getObjectManager')->willReturn($this->objectManagerMock); + $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()) + ->method('getResultRedirectFactory') + ->willReturn($resultRedirectFactory); + $this->contextMock->expects($this->any()) + ->method('getResultFactory') + ->willReturn($resultFactoryMock); + + $this->massAction = $objectManagerHelper->getObject( + 'Magento\Sales\Controller\Adminhtml\Order\MassCancel', + [ + 'context' => $this->contextMock + ] + ); + } + + /** + * Test for selected orders + * Two orders, only $order1 can be canceled + */ + public function testExecuteTwoOrderCanceled() + { + $selected = [1, 2]; + $countOrders = count($selected); + + $order1 = $this->getMockBuilder('Magento\Sales\Model\Order') + ->disableOriginalConstructor() + ->getMock(); + $order2 = $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, $order2]); + + $order1->expects($this->once()) + ->method('canCancel') + ->willReturn(true); + $order1->expects($this->once()) + ->method('cancel'); + $order1->expects($this->once()) + ->method('save'); + + $this->orderCollectionMock->expects($this->once()) + ->method('count') + ->willReturn($countOrders); + + $order2->expects($this->once()) + ->method('canCancel') + ->willReturn(false); + + $this->messageManagerMock->expects($this->once()) + ->method('addError') + ->with('1 order(s) cannot be canceled.'); + + $this->messageManagerMock->expects($this->once()) + ->method('addSuccess') + ->with('We canceled 1 order(s).'); + + $this->resultRedirectMock->expects($this->once()) + ->method('setPath') + ->with('sales/*/') + ->willReturnSelf(); + + $this->massAction->execute(); + } + + /** + * Test for excluded orders + * Two orders could't be canceled + */ + public function testExcludedOrderCannotBeCanceled() + { + $excluded = [1, 2]; + $countOrders = count($excluded); + + $order1 = $this->getMockBuilder('Magento\Sales\Model\Order') + ->disableOriginalConstructor() + ->getMock(); + $order2 = $this->getMockBuilder('Magento\Sales\Model\Order') + ->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); + + $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]); + + $order1->expects($this->once()) + ->method('canCancel') + ->willReturn(false); + + $this->orderCollectionMock->expects($this->once()) + ->method('count') + ->willReturn($countOrders); + + $order2->expects($this->once()) + ->method('canCancel') + ->willReturn(false); + + $this->messageManagerMock->expects($this->once()) + ->method('addError') + ->with('You cannot cancel the order(s).'); + + $this->resultRedirectMock->expects($this->once()) + ->method('setPath') + ->with('sales/*/') + ->willReturnSelf(); + + $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->massAction->execute(); + } + + /** + * Order throws exception while canceling + */ + 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]); + + $order1->expects($this->once()) + ->method('canCancel') + ->willReturn(true); + $order1->expects($this->once()) + ->method('cancel') + ->willThrowException($exception); + + $this->messageManagerMock->expects($this->once()) + ->method('addError') + ->with('Can not cancel'); + + $this->massAction->execute(); + } +} 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 new file mode 100644 index 0000000000000000000000000000000000000000..bb25130c4171d09c80b163709b413e5f9343debc --- /dev/null +++ b/app/code/Magento/Sales/Test/Unit/Controller/Adminhtml/Order/MassHoldTest.php @@ -0,0 +1,295 @@ +<?php +/** + * Copyright © 2015 Magento. All rights reserved. + * See COPYING.txt for license details. + */ + +namespace Magento\Sales\Test\Unit\Controller\Adminhtml\Order; + +use Magento\Framework\App\Action\Context; +use Magento\Framework\TestFramework\Unit\Helper\ObjectManager as ObjectManagerHelper; + +/** + * Class MassHoldTest + * @SuppressWarnings(PHPMD.CouplingBetweenObjects) + */ +class MassHoldTest extends \PHPUnit_Framework_TestCase +{ + /** + * @var \Magento\Sales\Controller\Adminhtml\Order\MassHold + */ + protected $massAction; + + /** + * @var Context|\PHPUnit_Framework_MockObject_MockObject + */ + protected $contextMock; + + /** + * @var \Magento\Backend\Model\View\Result\Redirect|\PHPUnit_Framework_MockObject_MockObject + */ + protected $resultRedirectMock; + + /** + * @var \Magento\Framework\App\Request\Http|\PHPUnit_Framework_MockObject_MockObject + */ + protected $requestMock; + + /** + * @var \Magento\Framework\App\ResponseInterface|\PHPUnit_Framework_MockObject_MockObject + */ + protected $responseMock; + + /** + * @var \Magento\Framework\Message\Manager|\PHPUnit_Framework_MockObject_MockObject + */ + protected $messageManagerMock; + + /** + * @var \Magento\Framework\ObjectManager\ObjectManager|\PHPUnit_Framework_MockObject_MockObject + */ + protected $objectManagerMock; + + /** + * @var \Magento\Backend\Model\Session|\PHPUnit_Framework_MockObject_MockObject + */ + protected $sessionMock; + + /** + * @var \Magento\Framework\App\ActionFlag|\PHPUnit_Framework_MockObject_MockObject + */ + protected $actionFlagMock; + + /** + * @var \Magento\Backend\Helper\Data|\PHPUnit_Framework_MockObject_MockObject + */ + protected $helperMock; + + /** + * @var \Magento\Sales\Model\Order|\PHPUnit_Framework_MockObject_MockObject + */ + protected $orderMock; + + /** + * @var \PHPUnit_Framework_MockObject_MockObject + */ + protected $orderCollectionMock; + + 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->objectManagerMock = $this->getMock( + 'Magento\Framework\ObjectManager\ObjectManager', + ['create'], + [], + '', + false + ); + $this->messageManagerMock = $this->getMock( + 'Magento\Framework\Message\Manager', + ['addSuccess', 'addError'], + [], + '', + false + ); + $this->orderCollectionMock = $this->getMockBuilder('Magento\Sales\Model\Resource\Order\Collection') + ->disableOriginalConstructor() + ->getMock(); + + $redirectMock = $this->getMockBuilder('Magento\Backend\Model\View\Result\Redirect') + ->disableOriginalConstructor() + ->getMock(); + + $resultFactoryMock = $this->getMockBuilder('Magento\Framework\Controller\ResultFactory') + ->disableOriginalConstructor() + ->getMock(); + $resultFactoryMock->expects($this->any()) + ->method('create') + ->with(\Magento\Framework\Controller\ResultFactory::TYPE_REDIRECT) + ->willReturn($redirectMock); + + $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); + $this->resultRedirectMock = $this->getMock('Magento\Backend\Model\View\Result\Redirect', [], [], '', false); + $resultRedirectFactory->expects($this->any())->method('create')->willReturn($this->resultRedirectMock); + + $this->contextMock->expects($this->once())->method('getMessageManager')->willReturn($this->messageManagerMock); + $this->contextMock->expects($this->once())->method('getRequest')->willReturn($this->requestMock); + $this->contextMock->expects($this->once())->method('getResponse')->willReturn($this->responseMock); + $this->contextMock->expects($this->once())->method('getObjectManager')->willReturn($this->objectManagerMock); + $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()) + ->method('getResultRedirectFactory') + ->willReturn($resultRedirectFactory); + $this->contextMock->expects($this->any()) + ->method('getResultFactory') + ->willReturn($resultFactoryMock); + + $this->massAction = $objectManagerHelper->getObject( + 'Magento\Sales\Controller\Adminhtml\Order\MassHold', + [ + 'context' => $this->contextMock, + ] + ); + } + + public function testExecuteTwoOrdersPutOnHold() + { + $selected = [1, 2]; + $countOrders = count($selected); + + $order1 = $this->getMockBuilder('Magento\Sales\Model\Order') + ->disableOriginalConstructor() + ->getMock(); + $order2 = $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, $order2]); + + $order1->expects($this->once()) + ->method('canHold') + ->willReturn(true); + $order1->expects($this->once()) + ->method('hold'); + $order1->expects($this->once()) + ->method('save'); + + $this->orderCollectionMock->expects($this->once()) + ->method('count') + ->willReturn($countOrders); + + $order2->expects($this->once()) + ->method('canHold') + ->willReturn(false); + + $this->messageManagerMock->expects($this->once()) + ->method('addError') + ->with('1 order(s) were not put on hold.'); + + $this->messageManagerMock->expects($this->once()) + ->method('addSuccess') + ->with('You have put 1 order(s) on hold.'); + + $this->resultRedirectMock->expects($this->once()) + ->method('setPath') + ->with('sales/*/') + ->willReturnSelf(); + + $this->massAction->execute(); + } + + public function testExecuteOneOrderCannotBePutOnHold() + { + $excluded = [1, 2]; + $countOrders = count($excluded); + + $order1 = $this->getMockBuilder('Magento\Sales\Model\Order') + ->disableOriginalConstructor() + ->getMock(); + $order2 = $this->getMockBuilder('Magento\Sales\Model\Order') + ->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); + + $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]); + + $order1->expects($this->once()) + ->method('canHold') + ->willReturn(false); + + $this->orderCollectionMock->expects($this->once()) + ->method('count') + ->willReturn($countOrders); + + $order2->expects($this->once()) + ->method('canHold') + ->willReturn(false); + + $this->messageManagerMock->expects($this->once()) + ->method('addError') + ->with('No order(s) were put on hold.'); + + $this->resultRedirectMock->expects($this->once()) + ->method('setPath') + ->with('sales/*/') + ->willReturnSelf(); + + $this->massAction->execute(); + } +} 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 new file mode 100644 index 0000000000000000000000000000000000000000..9b3175ab6d7e59d0097e452300521be06c6e40d3 --- /dev/null +++ b/app/code/Magento/Sales/Test/Unit/Controller/Adminhtml/Order/MassUnholdTest.php @@ -0,0 +1,296 @@ +<?php +/** + * Copyright © 2015 Magento. All rights reserved. + * See COPYING.txt for license details. + */ + +namespace Magento\Sales\Test\Unit\Controller\Adminhtml\Order; + +use Magento\Framework\App\Action\Context; +use Magento\Framework\TestFramework\Unit\Helper\ObjectManager as ObjectManagerHelper; + +/** + * Class MassHoldTest + * @SuppressWarnings(PHPMD.CouplingBetweenObjects) + */ +class MassUnholdTest extends \PHPUnit_Framework_TestCase +{ + /** + * @var \Magento\Sales\Controller\Adminhtml\Order\MassUnhold + */ + protected $massAction; + + /** + * @var Context|\PHPUnit_Framework_MockObject_MockObject + */ + protected $contextMock; + + /** + * @var \Magento\Backend\Model\View\Result\Redirect|\PHPUnit_Framework_MockObject_MockObject + */ + protected $resultRedirectMock; + + /** + * @var \Magento\Framework\App\Request\Http|\PHPUnit_Framework_MockObject_MockObject + */ + protected $requestMock; + + /** + * @var \Magento\Framework\App\ResponseInterface|\PHPUnit_Framework_MockObject_MockObject + */ + protected $responseMock; + + /** + * @var \Magento\Framework\Message\Manager|\PHPUnit_Framework_MockObject_MockObject + */ + protected $messageManagerMock; + + /** + * @var \Magento\Framework\ObjectManager\ObjectManager|\PHPUnit_Framework_MockObject_MockObject + */ + protected $objectManagerMock; + + /** + * @var \Magento\Backend\Model\Session|\PHPUnit_Framework_MockObject_MockObject + */ + protected $sessionMock; + + /** + * @var \Magento\Framework\App\ActionFlag|\PHPUnit_Framework_MockObject_MockObject + */ + protected $actionFlagMock; + + /** + * @var \Magento\Backend\Helper\Data|\PHPUnit_Framework_MockObject_MockObject + */ + protected $helperMock; + + /** + * @var \Magento\Sales\Model\Order|\PHPUnit_Framework_MockObject_MockObject + */ + protected $orderMock; + + /** + * @var \PHPUnit_Framework_MockObject_MockObject + */ + protected $orderCollectionMock; + + 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->objectManagerMock = $this->getMock( + 'Magento\Framework\ObjectManager\ObjectManager', + ['create'], + [], + '', + false + ); + $this->messageManagerMock = $this->getMock( + 'Magento\Framework\Message\Manager', + ['addSuccess', 'addError'], + [], + '', + false + ); + + $this->orderCollectionMock = $this->getMockBuilder('Magento\Sales\Model\Resource\Order\Collection') + ->disableOriginalConstructor() + ->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); + $this->resultRedirectMock = $this->getMock('Magento\Backend\Model\View\Result\Redirect', [], [], '', false); + $resultRedirectFactory->expects($this->any())->method('create')->willReturn($this->resultRedirectMock); + + $redirectMock = $this->getMockBuilder('Magento\Backend\Model\View\Result\Redirect') + ->disableOriginalConstructor() + ->getMock(); + + $resultFactoryMock = $this->getMockBuilder('Magento\Framework\Controller\ResultFactory') + ->disableOriginalConstructor() + ->getMock(); + $resultFactoryMock->expects($this->any()) + ->method('create') + ->with(\Magento\Framework\Controller\ResultFactory::TYPE_REDIRECT) + ->willReturn($redirectMock); + + $this->contextMock->expects($this->once())->method('getMessageManager')->willReturn($this->messageManagerMock); + $this->contextMock->expects($this->once())->method('getRequest')->willReturn($this->requestMock); + $this->contextMock->expects($this->once())->method('getResponse')->willReturn($this->responseMock); + $this->contextMock->expects($this->once())->method('getObjectManager')->willReturn($this->objectManagerMock); + $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()) + ->method('getResultRedirectFactory') + ->willReturn($resultRedirectFactory); + $this->contextMock->expects($this->any()) + ->method('getResultFactory') + ->willReturn($resultFactoryMock); + + $this->massAction = $objectManagerHelper->getObject( + 'Magento\Sales\Controller\Adminhtml\Order\MassUnhold', + [ + 'context' => $this->contextMock, + ] + ); + } + + public function testExecuteTwoOrdersReleasedFromHold() + { + $selected = [1, 2]; + $countOrders = count($selected); + + $order1 = $this->getMockBuilder('Magento\Sales\Model\Order') + ->disableOriginalConstructor() + ->getMock(); + $order2 = $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, $order2]); + + $order1->expects($this->once()) + ->method('canUnhold') + ->willReturn(true); + $order1->expects($this->once()) + ->method('unhold'); + $order1->expects($this->once()) + ->method('save'); + + $this->orderCollectionMock->expects($this->once()) + ->method('count') + ->willReturn($countOrders); + + $order2->expects($this->once()) + ->method('canUnhold') + ->willReturn(false); + + $this->messageManagerMock->expects($this->once()) + ->method('addError') + ->with('1 order(s) were not released from on hold status.'); + + $this->messageManagerMock->expects($this->once()) + ->method('addSuccess') + ->with('1 order(s) have been released from on hold status.'); + + $this->resultRedirectMock->expects($this->once()) + ->method('setPath') + ->with('sales/*/') + ->willReturnSelf(); + + $this->massAction->execute(); + } + + public function testExecuteOneOrderWhereNotReleasedFromHold() + { + $excluded = [1, 2]; + $countOrders = count($excluded); + + $order1 = $this->getMockBuilder('Magento\Sales\Model\Order') + ->disableOriginalConstructor() + ->getMock(); + $order2 = $this->getMockBuilder('Magento\Sales\Model\Order') + ->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); + + $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]); + + $order1->expects($this->once()) + ->method('canUnhold') + ->willReturn(false); + + $this->orderCollectionMock->expects($this->once()) + ->method('count') + ->willReturn($countOrders); + + $order2->expects($this->once()) + ->method('canUnhold') + ->willReturn(false); + + $this->messageManagerMock->expects($this->once()) + ->method('addError') + ->with('No order(s) were released from on hold status.'); + + $this->resultRedirectMock->expects($this->once()) + ->method('setPath') + ->with('sales/*/') + ->willReturnSelf(); + + $this->massAction->execute(); + } +} diff --git a/app/code/Magento/Sales/Test/Unit/Model/Order/DataProviderTest,php b/app/code/Magento/Sales/Test/Unit/Model/Order/DataProviderTest,php new file mode 100644 index 0000000000000000000000000000000000000000..d16ed34395e13916e5d469758cb24605f9fe666b --- /dev/null +++ b/app/code/Magento/Sales/Test/Unit/Model/Order/DataProviderTest,php @@ -0,0 +1,206 @@ +<?php +/** + * Copyright © 2015 Magento. All rights reserved. + * See COPYING.txt for license details. + */ + +namespace Magento\Sales\Test\Unit\Model\Order; + +/** + * Class DataProviderTest + */ +class DataProviderTest extends \PHPUnit_Framework_TestCase +{ + + /** + * @var \Magento\Sales\Model\Order\DataProvider + */ + protected $dataProvider; + + /** + * @var \Magento\Sales\Model\Resource\Order\Grid\CollectionFactory|\PHPUnit_Framework_MockObject_MockObject + */ + protected $collectionFactoryMock; + + /** + * @var \Magento\Sales\Model\Resource\Order\Grid\Collection|\PHPUnit_Framework_MockObject_MockObject + */ + protected $collectionMock; + + public function setUp() + { + $this->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/Test/Unit/Model/Resource/GridPoolTest.php b/app/code/Magento/Sales/Test/Unit/Model/Resource/GridPoolTest.php index 0491808bab3368fe5e13a083698a6d74f7d6e94a..fe9a0fa65f03bc5381ffc4136f0c82bce51d54f6 100644 --- a/app/code/Magento/Sales/Test/Unit/Model/Resource/GridPoolTest.php +++ b/app/code/Magento/Sales/Test/Unit/Model/Resource/GridPoolTest.php @@ -44,21 +44,25 @@ class GridPoolTest extends \PHPUnit_Framework_TestCase public function setUp() { $this->orderGridMock = $this->getMock( - 'Magento\Sales\Model\Resource\Order\Grid', [], [], '', false + 'Magento\Sales\Model\Resource\Grid', [], [], '', false ); $this->invoiceGridMock = $this->getMock( - 'Magento\Sales\Model\Resource\Order\Invoice\Grid', [], [], '', false + 'Magento\Sales\Model\Resource\Grid', [], [], '', false ); $this->shipmentGridMock = $this->getMock( - 'Magento\Sales\Model\Resource\Order\Shipment\Grid', [], [], '', false + 'Magento\Sales\Model\Resource\Grid', [], [], '', false ); $this->creditmemoGridMock = $this->getMock( - 'Magento\Sales\Model\Resource\Order\Creditmemo\Grid', [], [], '', false + 'Magento\Sales\Model\Resource\Grid', [], [], '', false ); $this->statementMock = $this->getMockForAbstractClass('Zend_Db_Statement_Interface'); - $this->gridPool = new \Magento\Sales\Model\Resource\GridPool( - $this->orderGridMock, $this->invoiceGridMock, $this->shipmentGridMock, $this->creditmemoGridMock - ); + $grids = [ + 'order_grid' => $this->orderGridMock, + 'invoice_grid' => $this->invoiceGridMock, + 'shipment_grid' => $this->shipmentGridMock, + 'creditmemo_grid' => $this->creditmemoGridMock + ]; + $this->gridPool = new \Magento\Sales\Model\Resource\GridPool($grids); } /** @@ -67,6 +71,20 @@ class GridPoolTest extends \PHPUnit_Framework_TestCase public function testRefreshByOrderId() { $orderId = 1; + + $this->orderGridMock->expects($this->once()) + ->method('getOrderIdField') + ->willReturn('sfo.entity_id'); + $this->invoiceGridMock->expects($this->once()) + ->method('getOrderIdField') + ->willReturn('sfo.entity_id'); + $this->shipmentGridMock->expects($this->once()) + ->method('getOrderIdField') + ->willReturn('sfo.entity_id'); + $this->creditmemoGridMock->expects($this->once()) + ->method('getOrderIdField') + ->willReturn('sfo.entity_id'); + $this->orderGridMock->expects($this->once()) ->method('refresh') ->with($this->equalTo($orderId), $this->equalTo('sfo.entity_id')) diff --git a/app/code/Magento/Sales/Test/Unit/Model/Resource/Order/AddressTest.php b/app/code/Magento/Sales/Test/Unit/Model/Resource/Order/AddressTest.php index fd9d023735b57c1bcdccb2f6d4b1deba2829b12f..2c2af880de119f6e9cebb309ace0a57455bea924 100644 --- a/app/code/Magento/Sales/Test/Unit/Model/Resource/Order/AddressTest.php +++ b/app/code/Magento/Sales/Test/Unit/Model/Resource/Order/AddressTest.php @@ -54,7 +54,7 @@ class AddressTest extends \PHPUnit_Framework_TestCase { $this->addressMock = $this->getMock( 'Magento\Sales\Model\Order\Address', - ['__wakeup', 'getOrderId', 'hasDataChanges', 'beforeSave', 'afterSave', 'validateBeforeSave', 'getOrder'], + ['__wakeup', 'getParentId', 'hasDataChanges', 'beforeSave', 'afterSave', 'validateBeforeSave', 'getOrder'], [], '', false @@ -136,18 +136,12 @@ class AddressTest extends \PHPUnit_Framework_TestCase ->method('isModified') ->with($this->addressMock) ->willReturn(true); - $this->addressMock->expects($this->exactly(2)) - ->method('getOrder') - ->will($this->returnValue($this->orderMock)); - $this->orderMock->expects($this->once()) - ->method('getId') - ->willReturn(1); - $this->addressMock->expects($this->exactly(2)) - ->method('getOrderId') - ->will($this->returnValue(2)); + $this->addressMock->expects($this->exactly(3)) + ->method('getParentId') + ->will($this->returnValue(1)); $this->gridPoolMock->expects($this->once()) ->method('refreshByOrderId') - ->with($this->equalTo(2)) + ->with($this->equalTo(1)) ->will($this->returnSelf()); $this->addressResource->save($this->addressMock); diff --git a/app/code/Magento/Sales/Test/Unit/Model/Resource/Order/Creditmemo/GridTest.php b/app/code/Magento/Sales/Test/Unit/Model/Resource/Order/Creditmemo/GridTest.php deleted file mode 100644 index 656b71be37cf95c0d868eecfa6a9e5e25ff03b99..0000000000000000000000000000000000000000 --- a/app/code/Magento/Sales/Test/Unit/Model/Resource/Order/Creditmemo/GridTest.php +++ /dev/null @@ -1,152 +0,0 @@ -<?php -/** - * Copyright © 2015 Magento. All rights reserved. - * See COPYING.txt for license details. - */ -namespace Magento\Sales\Test\Unit\Model\Resource\Order\Creditmemo; - -/** - * Class GridTest - */ -class GridTest extends \PHPUnit_Framework_TestCase -{ - /** - * @var \Magento\Sales\Model\Resource\Order\Creditmemo\Grid|\PHPUnit_Framework_MockObject_MockObject - */ - protected $grid; - - /** - * @var \Magento\Framework\App\Resource|\PHPUnit_Framework_MockObject_MockObject - */ - protected $appResourceMock; - - /** - * @var \Magento\Framework\DB\Adapter\Pdo\Mysql|\PHPUnit_Framework_MockObject_MockObject - */ - protected $adapterMock; - - /** - * @var \Magento\Framework\DB\Select|\PHPUnit_Framework_MockObject_MockObject - */ - protected $selectMock; - - /** - * @var \Zend_Db_Statement_Interface|\PHPUnit_Framework_MockObject_MockObject - */ - protected $statementMock; - - public function setUp() - { - $this->appResourceMock = $this->getMock( - 'Magento\Framework\App\Resource', - [], - [], - '', - false - ); - $this->eventManagerMock = $this->getMockForAbstractClass( - 'Magento\Framework\Event\ManagerInterface', - [], - '', - false, - false, - true, - [] - ); - $this->modelMock = $this->getMockForAbstractClass( - 'Magento\Sales\Model\AbstractModel', - [], - '', - false, - false, - true, - ['__wakeup', 'getId'] - ); - $this->adapterMock = $this->getMock( - 'Magento\Framework\DB\Adapter\Pdo\Mysql', - ['select', 'query', 'insertFromSelect', 'delete'], - [], - '', - false - ); - $this->selectMock = $this->getMock( - 'Magento\Framework\DB\Select', - [], - [], - '', - false - ); - $this->statementMock = $this->getMockForAbstractClass( - 'Zend_Db_Statement_Interface', - [], - '', - false, - false, - true, - [] - ); - - $contextMock = $this->getMock('\Magento\Framework\Model\Resource\Db\Context', [], [], '', false); - $contextMock->expects($this->once())->method('getResources')->willReturn($this->appResourceMock); - $this->grid = new \Magento\Sales\Model\Resource\Order\Creditmemo\Grid($contextMock); - } - - /** - * Test refresh method - */ - public function testRefresh() - { - $this->appResourceMock->expects($this->once()) - ->method('getConnection') - ->will($this->returnValue($this->adapterMock)); - $this->appResourceMock->expects($this->any()) - ->method('getTableName') - ->will($this->returnValue('sales_creditmemo_grid')); - $this->adapterMock->expects($this->once()) - ->method('select') - ->will($this->returnValue($this->selectMock)); - $this->selectMock->expects($this->once()) - ->method('from') - ->will($this->returnSelf()); - $this->selectMock->expects($this->once()) - ->method('join') - ->will($this->returnSelf()); - $this->selectMock->expects($this->once()) - ->method('joinLeft') - ->will($this->returnSelf()); - $this->selectMock->expects($this->once()) - ->method('columns') - ->will($this->returnSelf()); - $this->selectMock->expects($this->once()) - ->method('where') - ->with('fi.field = ?', 1, null) - ->will($this->returnSelf()); - $this->adapterMock->expects($this->once()) - ->method('query') - ->with('sql-query') - ->will($this->returnValue($this->statementMock)); - $this->adapterMock->expects($this->once()) - ->method('insertFromSelect') - ->with($this->selectMock, 'sales_creditmemo_grid', [], 1) - ->will($this->returnValue('sql-query')); - $this->assertEquals($this->statementMock, $this->grid->refresh(1, 'fi.field')); - } - - /** - * Test purge method - */ - public function testPurge() - { - $this->appResourceMock->expects($this->once()) - ->method('getConnection') - ->will($this->returnValue($this->adapterMock)); - $this->appResourceMock->expects($this->once()) - ->method('getTableName') - ->will($this->returnValue('sales_creditmemo_grid')); - $this->adapterMock->expects($this->once()) - ->method('delete') - ->with('sales_creditmemo_grid', ['fi.field = ?' => 1]) - ->will($this->returnValue(1)); - $this->assertEquals(1, $this->grid->purge(1, 'fi.field')); - } -} diff --git a/app/code/Magento/Sales/Test/Unit/Model/Resource/Order/GridTest.php b/app/code/Magento/Sales/Test/Unit/Model/Resource/Order/GridTest.php deleted file mode 100644 index 80def49756d9ac9fbf914008fa0ebccd7ec8255e..0000000000000000000000000000000000000000 --- a/app/code/Magento/Sales/Test/Unit/Model/Resource/Order/GridTest.php +++ /dev/null @@ -1,149 +0,0 @@ -<?php -/** - * Copyright © 2015 Magento. All rights reserved. - * See COPYING.txt for license details. - */ -namespace Magento\Sales\Test\Unit\Model\Resource\Order; - -/** - * Class GridTest - */ -class GridTest extends \PHPUnit_Framework_TestCase -{ - /** - * @var \Magento\Sales\Model\Resource\Order\Grid|\PHPUnit_Framework_MockObject_MockObject - */ - protected $grid; - - /** - * @var \Magento\Framework\App\Resource|\PHPUnit_Framework_MockObject_MockObject - */ - protected $appResourceMock; - - /** - * @var \Magento\Framework\DB\Adapter\Pdo\Mysql|\PHPUnit_Framework_MockObject_MockObject - */ - protected $adapterMock; - - /** - * @var \Magento\Framework\DB\Select|\PHPUnit_Framework_MockObject_MockObject - */ - protected $selectMock; - - /** - * @var \Zend_Db_Statement_Interface|\PHPUnit_Framework_MockObject_MockObject - */ - protected $statementMock; - - public function setUp() - { - $this->appResourceMock = $this->getMock( - 'Magento\Framework\App\Resource', - [], - [], - '', - false - ); - $this->eventManagerMock = $this->getMockForAbstractClass( - 'Magento\Framework\Event\ManagerInterface', - [], - '', - false, - false, - true, - [] - ); - $this->modelMock = $this->getMockForAbstractClass( - 'Magento\Sales\Model\AbstractModel', - [], - '', - false, - false, - true, - ['__wakeup', 'getId'] - ); - $this->adapterMock = $this->getMock( - 'Magento\Framework\DB\Adapter\Pdo\Mysql', - ['select', 'query', 'insertFromSelect', 'delete'], - [], - '', - false - ); - $this->selectMock = $this->getMock( - 'Magento\Framework\DB\Select', - [], - [], - '', - false - ); - $this->statementMock = $this->getMockForAbstractClass( - 'Zend_Db_Statement_Interface', - [], - '', - false, - false, - true, - [] - ); - - $contextMock = $this->getMock('\Magento\Framework\Model\Resource\Db\Context', [], [], '', false); - $contextMock->expects($this->once())->method('getResources')->willReturn($this->appResourceMock); - $this->grid = new \Magento\Sales\Model\Resource\Order\Grid($contextMock); - } - - /** - * Test refresh method - */ - public function testRefresh() - { - $this->appResourceMock->expects($this->once()) - ->method('getConnection') - ->will($this->returnValue($this->adapterMock)); - $this->appResourceMock->expects($this->any()) - ->method('getTableName') - ->will($this->returnValue('sales_order_grid')); - $this->adapterMock->expects($this->once()) - ->method('select') - ->will($this->returnValue($this->selectMock)); - $this->selectMock->expects($this->once()) - ->method('from') - ->will($this->returnSelf()); - $this->selectMock->expects($this->exactly(2)) - ->method('joinLeft') - ->will($this->returnSelf()); - $this->selectMock->expects($this->once()) - ->method('columns') - ->will($this->returnSelf()); - $this->selectMock->expects($this->once()) - ->method('where') - ->with('fi.field = ?', 1, null) - ->will($this->returnSelf()); - $this->adapterMock->expects($this->once()) - ->method('query') - ->with('sql-query') - ->will($this->returnValue($this->statementMock)); - $this->adapterMock->expects($this->once()) - ->method('insertFromSelect') - ->with($this->selectMock, 'sales_order_grid', [], 1) - ->will($this->returnValue('sql-query')); - $this->assertEquals($this->statementMock, $this->grid->refresh(1, 'fi.field')); - } - - /** - * Test purge method - */ - public function testPurge() - { - $this->appResourceMock->expects($this->once()) - ->method('getConnection') - ->will($this->returnValue($this->adapterMock)); - $this->appResourceMock->expects($this->once()) - ->method('getTableName') - ->will($this->returnValue('sales_order_grid')); - $this->adapterMock->expects($this->once()) - ->method('delete') - ->with('sales_order_grid', ['fi.field = ?' => 1]) - ->will($this->returnValue(1)); - $this->assertEquals(1, $this->grid->purge(1, 'fi.field')); - } -} diff --git a/app/code/Magento/Sales/Test/Unit/Model/Resource/Order/Invoice/GridTest.php b/app/code/Magento/Sales/Test/Unit/Model/Resource/Order/Invoice/GridTest.php deleted file mode 100644 index dbd833c14a5aba6d8a8b5330d2cda230ba726bcc..0000000000000000000000000000000000000000 --- a/app/code/Magento/Sales/Test/Unit/Model/Resource/Order/Invoice/GridTest.php +++ /dev/null @@ -1,151 +0,0 @@ -<?php -/** - * Copyright © 2015 Magento. All rights reserved. - * See COPYING.txt for license details. - */ -namespace Magento\Sales\Test\Unit\Model\Resource\Order\Invoice; - -/** - * Class GridTest - */ -class GridTest extends \PHPUnit_Framework_TestCase -{ - /** - * @var \Magento\Sales\Model\Resource\Order\Invoice\Grid|\PHPUnit_Framework_MockObject_MockObject - */ - protected $grid; - - /** - * @var \Magento\Framework\App\Resource|\PHPUnit_Framework_MockObject_MockObject - */ - protected $appResourceMock; - - /** - * @var \Magento\Framework\DB\Adapter\Pdo\Mysql|\PHPUnit_Framework_MockObject_MockObject - */ - protected $adapterMock; - - /** - * @var \Magento\Framework\DB\Select|\PHPUnit_Framework_MockObject_MockObject - */ - protected $selectMock; - - /** - * @var \Zend_Db_Statement_Interface|\PHPUnit_Framework_MockObject_MockObject - */ - protected $statementMock; - - public function setUp() - { - $this->appResourceMock = $this->getMock( - 'Magento\Framework\App\Resource', - [], - [], - '', - false - ); - $this->eventManagerMock = $this->getMockForAbstractClass( - 'Magento\Framework\Event\ManagerInterface', - [], - '', - false, - false, - true, - [] - ); - $this->modelMock = $this->getMockForAbstractClass( - 'Magento\Sales\Model\AbstractModel', - [], - '', - false, - false, - true, - ['__wakeup', 'getId'] - ); - $this->adapterMock = $this->getMock( - 'Magento\Framework\DB\Adapter\Pdo\Mysql', - ['select', 'query', 'insertFromSelect', 'delete'], - [], - '', - false - ); - $this->selectMock = $this->getMock( - 'Magento\Framework\DB\Select', - [], - [], - '', - false - ); - $this->statementMock = $this->getMockForAbstractClass( - 'Zend_Db_Statement_Interface', - [], - '', - false, - false, - true, - [] - ); - $contextMock = $this->getMock('\Magento\Framework\Model\Resource\Db\Context', [], [], '', false); - $contextMock->expects($this->once())->method('getResources')->willReturn($this->appResourceMock); - $this->grid = new \Magento\Sales\Model\Resource\Order\Invoice\Grid($contextMock); - } - - /** - * Test refresh method - */ - public function testRefresh() - { - $this->appResourceMock->expects($this->once()) - ->method('getConnection') - ->will($this->returnValue($this->adapterMock)); - $this->appResourceMock->expects($this->any()) - ->method('getTableName') - ->will($this->returnValue('sales_invoice_grid')); - $this->adapterMock->expects($this->once()) - ->method('select') - ->will($this->returnValue($this->selectMock)); - $this->selectMock->expects($this->once()) - ->method('from') - ->will($this->returnSelf()); - $this->selectMock->expects($this->once()) - ->method('join') - ->will($this->returnSelf()); - $this->selectMock->expects($this->once()) - ->method('joinLeft') - ->will($this->returnSelf()); - $this->selectMock->expects($this->once()) - ->method('columns') - ->will($this->returnSelf()); - $this->selectMock->expects($this->once()) - ->method('where') - ->with('fi.field = ?', 1, null) - ->will($this->returnSelf()); - $this->adapterMock->expects($this->once()) - ->method('query') - ->with('sql-query') - ->will($this->returnValue($this->statementMock)); - $this->adapterMock->expects($this->once()) - ->method('insertFromSelect') - ->with($this->selectMock, 'sales_invoice_grid', [], 1) - ->will($this->returnValue('sql-query')); - $this->assertEquals($this->statementMock, $this->grid->refresh(1, 'fi.field')); - } - - /** - * Test purge method - */ - public function testPurge() - { - $this->appResourceMock->expects($this->once()) - ->method('getConnection') - ->will($this->returnValue($this->adapterMock)); - $this->appResourceMock->expects($this->once()) - ->method('getTableName') - ->will($this->returnValue('sales_invoice_grid')); - $this->adapterMock->expects($this->once()) - ->method('delete') - ->with('sales_invoice_grid', ['fi.field = ?' => 1]) - ->will($this->returnValue(1)); - $this->assertEquals(1, $this->grid->purge(1, 'fi.field')); - } -} diff --git a/app/code/Magento/Sales/Test/Unit/Model/Resource/Order/Shipment/GridTest.php b/app/code/Magento/Sales/Test/Unit/Model/Resource/Order/Shipment/GridTest.php deleted file mode 100644 index 7aa692e77f726c6adaf2bacb6506b161fcc7c164..0000000000000000000000000000000000000000 --- a/app/code/Magento/Sales/Test/Unit/Model/Resource/Order/Shipment/GridTest.php +++ /dev/null @@ -1,151 +0,0 @@ -<?php -/** - * Copyright © 2015 Magento. All rights reserved. - * See COPYING.txt for license details. - */ -namespace Magento\Sales\Test\Unit\Model\Resource\Order\Shipment; - -/** - * Class GridTest - */ -class GridTest extends \PHPUnit_Framework_TestCase -{ - /** - * @var \Magento\Sales\Model\Resource\Order\Shipment\Grid|\PHPUnit_Framework_MockObject_MockObject - */ - protected $grid; - - /** - * @var \Magento\Framework\App\Resource|\PHPUnit_Framework_MockObject_MockObject - */ - protected $appResourceMock; - - /** - * @var \Magento\Framework\DB\Adapter\Pdo\Mysql|\PHPUnit_Framework_MockObject_MockObject - */ - protected $adapterMock; - - /** - * @var \Magento\Framework\DB\Select|\PHPUnit_Framework_MockObject_MockObject - */ - protected $selectMock; - - /** - * @var \Zend_Db_Statement_Interface|\PHPUnit_Framework_MockObject_MockObject - */ - protected $statementMock; - - public function setUp() - { - $this->appResourceMock = $this->getMock( - 'Magento\Framework\App\Resource', - [], - [], - '', - false - ); - $this->eventManagerMock = $this->getMockForAbstractClass( - 'Magento\Framework\Event\ManagerInterface', - [], - '', - false, - false, - true, - [] - ); - $this->modelMock = $this->getMockForAbstractClass( - 'Magento\Sales\Model\AbstractModel', - [], - '', - false, - false, - true, - ['__wakeup', 'getId'] - ); - $this->adapterMock = $this->getMock( - 'Magento\Framework\DB\Adapter\Pdo\Mysql', - ['select', 'query', 'insertFromSelect', 'delete'], - [], - '', - false - ); - $this->selectMock = $this->getMock( - 'Magento\Framework\DB\Select', - [], - [], - '', - false - ); - $this->statementMock = $this->getMockForAbstractClass( - 'Zend_Db_Statement_Interface', - [], - '', - false, - false, - true, - [] - ); - $contextMock = $this->getMock('\Magento\Framework\Model\Resource\Db\Context', [], [], '', false); - $contextMock->expects($this->once())->method('getResources')->willReturn($this->appResourceMock); - $this->grid = new \Magento\Sales\Model\Resource\Order\Shipment\Grid($contextMock); - } - - /** - * Test refresh method - */ - public function testRefresh() - { - $this->appResourceMock->expects($this->once()) - ->method('getConnection') - ->will($this->returnValue($this->adapterMock)); - $this->appResourceMock->expects($this->any()) - ->method('getTableName') - ->will($this->returnValue('sales_shipment_grid')); - $this->adapterMock->expects($this->once()) - ->method('select') - ->will($this->returnValue($this->selectMock)); - $this->selectMock->expects($this->once()) - ->method('from') - ->will($this->returnSelf()); - $this->selectMock->expects($this->once()) - ->method('join') - ->will($this->returnSelf()); - $this->selectMock->expects($this->once()) - ->method('joinLeft') - ->will($this->returnSelf()); - $this->selectMock->expects($this->once()) - ->method('columns') - ->will($this->returnSelf()); - $this->selectMock->expects($this->once()) - ->method('where') - ->with('fi.field = ?', 1, null) - ->will($this->returnSelf()); - $this->adapterMock->expects($this->once()) - ->method('query') - ->with('sql-query') - ->will($this->returnValue($this->statementMock)); - $this->adapterMock->expects($this->once()) - ->method('insertFromSelect') - ->with($this->selectMock, 'sales_shipment_grid', [], 1) - ->will($this->returnValue('sql-query')); - $this->assertEquals($this->statementMock, $this->grid->refresh(1, 'fi.field')); - } - - /** - * Test purge method - */ - public function testPurge() - { - $this->appResourceMock->expects($this->once()) - ->method('getConnection') - ->will($this->returnValue($this->adapterMock)); - $this->appResourceMock->expects($this->once()) - ->method('getTableName') - ->will($this->returnValue('sales_shipment_grid')); - $this->adapterMock->expects($this->once()) - ->method('delete') - ->with('sales_shipment_grid', ['fi.field = ?' => 1]) - ->will($this->returnValue(1)); - $this->assertEquals(1, $this->grid->purge(1, 'fi.field')); - } -} diff --git a/app/code/Magento/Sales/Test/Unit/Ui/Component/Listing/Column/AddressTest.php b/app/code/Magento/Sales/Test/Unit/Ui/Component/Listing/Column/AddressTest.php new file mode 100644 index 0000000000000000000000000000000000000000..592116ce92822e6882155c9c158c186a7518a409 --- /dev/null +++ b/app/code/Magento/Sales/Test/Unit/Ui/Component/Listing/Column/AddressTest.php @@ -0,0 +1,45 @@ +<?php +/** + * Copyright © 2015 Magento. All rights reserved. + * See COPYING.txt for license details. + */ +namespace Magento\Sales\Test\Unit\Ui\Component\Listing\Column; + +use Magento\Framework\TestFramework\Unit\Helper\ObjectManager; +use Magento\Customer\Api\GroupRepositoryInterface; +use Magento\Sales\Ui\Component\Listing\Column\Address; + +/** + * Class AddressTest + */ +class AddressTest extends \PHPUnit_Framework_TestCase +{ + /** + * @var Address + */ + protected $model; + + public function setUp() + { + $objectManager = new ObjectManager($this); + $this->model = $objectManager->getObject('Magento\Sales\Ui\Component\Listing\Column\Address'); + } + + public function testPrepareDataSource() + { + $itemName = 'itemName'; + $oldItemValue = "itemValue\n"; + $newItemValue = 'itemValue<br/>'; + $dataSource = [ + 'data' => [ + 'items' => [ + [$itemName => $oldItemValue] + ] + ] + ]; + + $this->model->setData('name', $itemName); + $this->model->prepareDataSource($dataSource); + $this->assertEquals($newItemValue, $dataSource['data']['items'][0][$itemName]); + } +} diff --git a/app/code/Magento/Sales/Test/Unit/Ui/Component/Listing/Column/CustomerGroupTest.php b/app/code/Magento/Sales/Test/Unit/Ui/Component/Listing/Column/CustomerGroupTest.php new file mode 100644 index 0000000000000000000000000000000000000000..0ef21fae35f4b9ecf157d02b6abd9b14d7b1e256 --- /dev/null +++ b/app/code/Magento/Sales/Test/Unit/Ui/Component/Listing/Column/CustomerGroupTest.php @@ -0,0 +1,63 @@ +<?php +/** + * Copyright © 2015 Magento. All rights reserved. + * See COPYING.txt for license details. + */ +namespace Magento\Sales\Test\Unit\Ui\Component\Listing\Column; + +use Magento\Framework\TestFramework\Unit\Helper\ObjectManager; +use Magento\Customer\Api\GroupRepositoryInterface; +use Magento\Sales\Ui\Component\Listing\Column\CustomerGroup; + +/** + * Class CustomerGroupTest + */ +class CustomerGroupTest extends \PHPUnit_Framework_TestCase +{ + /** + * @var CustomerGroup + */ + protected $model; + + /** + * @var GroupRepositoryInterface|\PHPUnit_Framework_MockObject_MockObject + */ + protected $groupRepository; + + public function setUp() + { + $objectManager = new ObjectManager($this); + $this->groupRepository = $this->getMockForAbstractClass('Magento\Customer\Api\GroupRepositoryInterface'); + $this->model = $objectManager->getObject( + 'Magento\Sales\Ui\Component\Listing\Column\CustomerGroup', + ['groupRepository' => $this->groupRepository] + ); + } + + public function testPrepareDataSource() + { + $itemName = 'itemName'; + $oldItemValue = 'oldItemValue'; + $newItemValue = 'newItemValue'; + $dataSource = [ + 'data' => [ + 'items' => [ + [$itemName => $oldItemValue] + ] + ] + ]; + + $group = $this->getMockForAbstractClass('Magento\Customer\Api\Data\GroupInterface'); + $group->expects($this->once()) + ->method('getCode') + ->willReturn($newItemValue); + $this->groupRepository->expects($this->once()) + ->method('getById') + ->with($oldItemValue) + ->willReturn($group); + + $this->model->setData('name', $itemName); + $this->model->prepareDataSource($dataSource); + $this->assertEquals($newItemValue, $dataSource['data']['items'][0][$itemName]); + } +} diff --git a/app/code/Magento/Sales/Test/Unit/Ui/Component/Listing/Column/OrderActionsTest.php b/app/code/Magento/Sales/Test/Unit/Ui/Component/Listing/Column/OrderActionsTest.php new file mode 100644 index 0000000000000000000000000000000000000000..71fbaf852cb55d7b8a3c57e6c6be184f5d445f50 --- /dev/null +++ b/app/code/Magento/Sales/Test/Unit/Ui/Component/Listing/Column/OrderActionsTest.php @@ -0,0 +1,69 @@ +<?php +/** + * Copyright © 2015 Magento. All rights reserved. + * See COPYING.txt for license details. + */ +namespace Magento\Sales\Test\Unit\Ui\Component\Listing\Column; + +use Magento\Framework\TestFramework\Unit\Helper\ObjectManager; +use Magento\Framework\UrlInterface; +use Magento\Sales\Ui\Component\Listing\Column\OrderActions; + +/** + * Class OrderActionsTest + */ +class OrderActionsTest extends \PHPUnit_Framework_TestCase +{ + /** + * @var OrderActions + */ + protected $model; + + /** + * @var UrlInterface|\PHPUnit_Framework_MockObject_MockObject + */ + protected $urlBuilder; + + public function setUp() + { + $objectManager = new ObjectManager($this); + $this->urlBuilder = $this->getMockForAbstractClass('Magento\Framework\UrlInterface'); + $this->model = $objectManager->getObject( + 'Magento\Sales\Ui\Component\Listing\Column\OrderActions', + ['urlBuilder' => $this->urlBuilder] + ); + } + + public function testPrepareDataSource() + { + $entityId = 1; + $url = 'url'; + $itemName = 'itemName'; + $oldItemValue = 'itemValue'; + $newItemValue = [ + 'view' => [ + 'href' => $url, + 'label' => __('View') + ] + ]; + $dataSource = [ + 'data' => [ + 'items' => [ + [ + $itemName => $oldItemValue, + 'entity_id' => $entityId + ] + ] + ] + ]; + + $this->urlBuilder->expects($this->once()) + ->method('getUrl') + ->with(OrderActions::URL_PATH_VIEW, ['order_id' => $entityId]) + ->willReturn($url); + + $this->model->setData('name', $itemName); + $this->model->prepareDataSource($dataSource); + $this->assertEquals($newItemValue, $dataSource['data']['items'][0][$itemName]); + } +} diff --git a/app/code/Magento/Sales/Test/Unit/Ui/Component/Listing/Column/PaymentMethodTest.php b/app/code/Magento/Sales/Test/Unit/Ui/Component/Listing/Column/PaymentMethodTest.php new file mode 100644 index 0000000000000000000000000000000000000000..5d6f5195f2ff51a93348377b6b1f9258684f89d5 --- /dev/null +++ b/app/code/Magento/Sales/Test/Unit/Ui/Component/Listing/Column/PaymentMethodTest.php @@ -0,0 +1,63 @@ +<?php +/** + * Copyright © 2015 Magento. All rights reserved. + * See COPYING.txt for license details. + */ +namespace Magento\Sales\Test\Unit\Ui\Component\Listing\Column; + +use Magento\Framework\TestFramework\Unit\Helper\ObjectManager; +use Magento\Payment\Helper\Data; +use Magento\Sales\Ui\Component\Listing\Column\PaymentMethod; + +/** + * Class PaymentMethodTest + */ +class PaymentMethodTest extends \PHPUnit_Framework_TestCase +{ + /** + * @var PaymentMethod + */ + protected $model; + + /** + * @var Data|\PHPUnit_Framework_MockObject_MockObject + */ + protected $paymentHelper; + + public function setUp() + { + $objectManager = new ObjectManager($this); + $this->paymentHelper = $this->getMock('Magento\Payment\Helper\Data', [], [], '', false); + $this->model = $objectManager->getObject( + 'Magento\Sales\Ui\Component\Listing\Column\PaymentMethod', + ['paymentHelper' => $this->paymentHelper] + ); + } + + public function testPrepareDataSource() + { + $itemName = 'itemName'; + $oldItemValue = 'oldItemValue'; + $newItemValue = 'newItemValue'; + $dataSource = [ + 'data' => [ + 'items' => [ + [$itemName => $oldItemValue] + ] + ] + ]; + + $payment = $this->getMockForAbstractClass('Magento\Payment\Model\MethodInterface'); + $payment->expects($this->once()) + ->method('getTitle') + ->willReturn($newItemValue); + $this->paymentHelper->expects($this->once()) + ->method('getMethodInstance') + ->with($oldItemValue) + ->willReturn($payment); + + $this->model->setData('name', $itemName); + $this->model->prepareDataSource($dataSource); + $this->assertEquals($newItemValue, $dataSource['data']['items'][0][$itemName]); + } +} diff --git a/app/code/Magento/Sales/Test/Unit/Ui/Component/Listing/Column/PriceTest.php b/app/code/Magento/Sales/Test/Unit/Ui/Component/Listing/Column/PriceTest.php new file mode 100644 index 0000000000000000000000000000000000000000..4efffe34f630d35ec082f473a9ad4eed69d18901 --- /dev/null +++ b/app/code/Magento/Sales/Test/Unit/Ui/Component/Listing/Column/PriceTest.php @@ -0,0 +1,59 @@ +<?php +/** + * Copyright © 2015 Magento. All rights reserved. + * See COPYING.txt for license details. + */ +namespace Magento\Sales\Test\Unit\Ui\Component\Listing\Column; + +use Magento\Framework\Pricing\PriceCurrencyInterface; +use Magento\Framework\TestFramework\Unit\Helper\ObjectManager; +use Magento\Sales\Ui\Component\Listing\Column\Price; + +/** + * Class PriceTest + */ +class PriceTest extends \PHPUnit_Framework_TestCase +{ + /** + * @var Price + */ + protected $model; + + /** + * @var PriceCurrencyInterface|\PHPUnit_Framework_MockObject_MockObject + */ + protected $priceFormatterMock; + + public function setUp() + { + $objectManager = new ObjectManager($this); + $this->priceFormatterMock = $this->getMockForAbstractClass('Magento\Framework\Pricing\PriceCurrencyInterface'); + $this->model = $objectManager->getObject( + 'Magento\Sales\Ui\Component\Listing\Column\Price', + ['priceFormatter' => $this->priceFormatterMock] + ); + } + + public function testPrepareDataSource() + { + $itemName = 'itemName'; + $oldItemValue = 'oldItemValue'; + $newItemValue = 'newItemValue'; + $dataSource = [ + 'data' => [ + 'items' => [ + [$itemName => $oldItemValue] + ] + ] + ]; + + $this->priceFormatterMock->expects($this->once()) + ->method('format') + ->with($oldItemValue, false) + ->willReturn($newItemValue); + + $this->model->setData('name', $itemName); + $this->model->prepareDataSource($dataSource); + $this->assertEquals($newItemValue, $dataSource['data']['items'][0][$itemName]); + } +} diff --git a/app/code/Magento/Sales/Test/Unit/Ui/Component/Listing/Column/Status/OptionsTest.php b/app/code/Magento/Sales/Test/Unit/Ui/Component/Listing/Column/Status/OptionsTest.php new file mode 100644 index 0000000000000000000000000000000000000000..251328dcde8a76202ddbd2b2541d834f427e1fe6 --- /dev/null +++ b/app/code/Magento/Sales/Test/Unit/Ui/Component/Listing/Column/Status/OptionsTest.php @@ -0,0 +1,57 @@ +<?php +/** + * Copyright © 2015 Magento. All rights reserved. + * See COPYING.txt for license details. + */ +namespace Magento\Sales\Test\Unit\Ui\Component\Listing\Column\Status; + +use Magento\Sales\Model\Resource\Order\Status\CollectionFactory; +use Magento\Framework\TestFramework\Unit\Helper\ObjectManager; +use Magento\Sales\Ui\Component\Listing\Column\Status\Options; + +/** + * Class OptionsTest + */ +class OptionsTest extends \PHPUnit_Framework_TestCase +{ + /** + * @var Options + */ + protected $model; + + /** + * @var CollectionFactory|\PHPUnit_Framework_MockObject_MockObject + */ + protected $collectionFactoryMock; + + public function setUp() + { + $objectManager = new ObjectManager($this); + $this->collectionFactoryMock = $this->getMock( + 'Magento\Sales\Model\Resource\Order\Status\CollectionFactory', + [], + [], + '', + false + ); + $this->model = $objectManager->getObject( + 'Magento\Sales\Ui\Component\Listing\Column\Status\Options', + ['collectionFactory' => $this->collectionFactoryMock] + ); + } + + public function testToOptionArray() + { + $collectionMock = $this->getMock('Magento\Sales\Model\Resource\Order\Status\Collection', [], [], '', false); + $options = ['options']; + + $this->collectionFactoryMock->expects($this->once()) + ->method('create') + ->willReturn($collectionMock); + $collectionMock->expects($this->once()) + ->method('toOptionArray') + ->willReturn($options); + $this->assertEquals($options, $this->model->toOptionArray()); + $this->assertEquals($options, $this->model->toOptionArray()); + } +} diff --git a/app/code/Magento/Sales/Test/Unit/Ui/Component/Listing/Column/StatusTest.php b/app/code/Magento/Sales/Test/Unit/Ui/Component/Listing/Column/StatusTest.php new file mode 100644 index 0000000000000000000000000000000000000000..0b1d3c8179e0162de84f2516393a807870462a96 --- /dev/null +++ b/app/code/Magento/Sales/Test/Unit/Ui/Component/Listing/Column/StatusTest.php @@ -0,0 +1,54 @@ +<?php +/** + * Copyright © 2015 Magento. All rights reserved. + * See COPYING.txt for license details. + */ +namespace Magento\Sales\Test\Unit\Ui\Component\Listing\Column; + +use Magento\Framework\TestFramework\Unit\Helper\ObjectManager; +use Magento\Sales\Ui\Component\Listing\Column\Status; + +/** + * Class StatusTest + */ +class StatusTest extends \PHPUnit_Framework_TestCase +{ + public function testPrepareDataSource() + { + $itemName = 'itemName'; + $oldItemValue = 'oldItemValue'; + $newItemValue = 'newItemValue'; + $itemMapping = [$oldItemValue => $newItemValue]; + $dataSource = [ + 'data' => [ + 'items' => [ + [$itemName => $oldItemValue] + ] + ] + ]; + $collection = $this->getMock('Magento\Sales\Model\Resource\Order\Status\Collection', [], [], '', false); + $collection->expects($this->once()) + ->method('toOptionHash') + ->willReturn($itemMapping); + + $collectionFactoryMock = $this->getMock( + 'Magento\Sales\Model\Resource\Order\Status\CollectionFactory', + [], + [], + '', + false + ); + $collectionFactoryMock->expects($this->once()) + ->method('create') + ->willReturn($collection); + + $objectManager = new ObjectManager($this); + $model = $objectManager->getObject( + 'Magento\Sales\Ui\Component\Listing\Column\Status', + ['collectionFactory' => $collectionFactoryMock] + ); + $model->setData('name', $itemName); + $model->prepareDataSource($dataSource); + $this->assertEquals($newItemValue, $dataSource['data']['items'][0][$itemName]); + } +} diff --git a/app/code/Magento/Sales/Ui/Component/Listing/Column/Address.php b/app/code/Magento/Sales/Ui/Component/Listing/Column/Address.php new file mode 100644 index 0000000000000000000000000000000000000000..deecee4c629a5a2327c077dacd1b4b79fe813163 --- /dev/null +++ b/app/code/Magento/Sales/Ui/Component/Listing/Column/Address.php @@ -0,0 +1,32 @@ +<?php +/** + * Copyright © 2015 Magento. All rights reserved. + * See COPYING.txt for license details. + */ +namespace Magento\Sales\Ui\Component\Listing\Column; + +use Magento\Ui\Component\Listing\Columns\Column; +use Magento\Framework\View\Element\UiComponent\ContextInterface; +use Magento\Framework\View\Element\UiComponentFactory; +use Magento\Sales\Model\Resource\Order\Status\CollectionFactory; + +/** + * Class Address + */ +class Address extends Column +{ + /** + * Prepare Data Source + * + * @param array $dataSource + * @return void + */ + public function prepareDataSource(array & $dataSource) + { + if (isset($dataSource['data']['items'])) { + foreach ($dataSource['data']['items'] as & $item) { + $item[$this->getData('name')] = str_replace("\n", '<br/>', $item[$this->getData('name')]); + } + } + } +} diff --git a/app/code/Magento/Sales/Ui/Component/Listing/Column/Creditmemo/State.php b/app/code/Magento/Sales/Ui/Component/Listing/Column/Creditmemo/State.php new file mode 100644 index 0000000000000000000000000000000000000000..311f5c5ad729da92b480de03979a3a2d84822308 --- /dev/null +++ b/app/code/Magento/Sales/Ui/Component/Listing/Column/Creditmemo/State.php @@ -0,0 +1,57 @@ +<?php +/** + * Copyright © 2015 Magento. All rights reserved. + * See COPYING.txt for license details. + */ +namespace Magento\Sales\Ui\Component\Listing\Column\Creditmemo; + +use Magento\Ui\Component\Listing\Columns\Column; +use Magento\Framework\View\Element\UiComponent\ContextInterface; +use Magento\Framework\View\Element\UiComponentFactory; +use Magento\Sales\Model\Order\CreditmemoFactory; + +/** + * Class State + */ +class State extends Column +{ + /** + * @var string[] + */ + protected $states; + + /** + * Constructor + * + * @param ContextInterface $context + * @param UiComponentFactory $uiComponentFactory + * @param CreditmemoFactory $creditmemoFactory + * @param array $components + * @param array $data + */ + public function __construct( + ContextInterface $context, + UiComponentFactory $uiComponentFactory, + CreditmemoFactory $creditmemoFactory, + array $components = [], + array $data = [] + ) { + $this->states = $creditmemoFactory->create()->getStates(); + parent::__construct($context, $uiComponentFactory, $components, $data); + } + + /** + * Prepare Data Source + * + * @param array $dataSource + * @return void + */ + public function prepareDataSource(array & $dataSource) + { + if (isset($dataSource['data']['items'])) { + foreach ($dataSource['data']['items'] as & $item) { + $item[$this->getData('name')] = $this->states[$item[$this->getData('name')]]; + } + } + } +} diff --git a/app/code/Magento/Sales/Ui/Component/Listing/Column/Creditmemo/State/Options.php b/app/code/Magento/Sales/Ui/Component/Listing/Column/Creditmemo/State/Options.php new file mode 100644 index 0000000000000000000000000000000000000000..edb9e3519273bff245e8ff3170d6137eb9206457 --- /dev/null +++ b/app/code/Magento/Sales/Ui/Component/Listing/Column/Creditmemo/State/Options.php @@ -0,0 +1,57 @@ +<?php +/** + * Copyright © 2015 Magento. All rights reserved. + * See COPYING.txt for license details. + */ +namespace Magento\Sales\Ui\Component\Listing\Column\Creditmemo\State; + +use Magento\Framework\Data\OptionSourceInterface; +use Magento\Sales\Model\Order\CreditmemoFactory; + +/** + * Class Options + */ +class Options implements OptionSourceInterface +{ + /** + * @var array + */ + protected $options; + + /** + * @var CreditmemoFactory + */ + protected $creditmemoFactory; + + /** + * Constructor + * + * @param CreditmemoFactory $creditmemoFactory + */ + public function __construct(CreditmemoFactory $creditmemoFactory) + { + $this->creditmemoFactory = $creditmemoFactory; + } + + /** + * Get options + * + * @return array + */ + public function toOptionArray() + { + if ($this->options === null) { + $this->options = []; + + /** @var \Magento\Framework\Phrase $state */ + foreach ($this->creditmemoFactory->create()->getStates() as $id => $state) { + $this->options[] = [ + 'value' => $id, + 'label' => $state->render() + ]; + } + } + + return $this->options; + } +} diff --git a/app/code/Magento/Sales/Ui/Component/Listing/Column/CustomerGroup.php b/app/code/Magento/Sales/Ui/Component/Listing/Column/CustomerGroup.php new file mode 100644 index 0000000000000000000000000000000000000000..d33d301d3311bcd2a00cd797d3dad6acd8386bd3 --- /dev/null +++ b/app/code/Magento/Sales/Ui/Component/Listing/Column/CustomerGroup.php @@ -0,0 +1,58 @@ +<?php +/** + * Copyright © 2015 Magento. All rights reserved. + * See COPYING.txt for license details. + */ +namespace Magento\Sales\Ui\Component\Listing\Column; + +use Magento\Ui\Component\Listing\Columns\Column; +use Magento\Framework\View\Element\UiComponent\ContextInterface; +use Magento\Framework\View\Element\UiComponentFactory; +use Magento\Customer\Api\GroupRepositoryInterface; + +/** + * Class CustomerGroup + */ +class CustomerGroup extends Column +{ + /** + * @var GroupRepositoryInterface + */ + protected $groupRepository; + + /** + * Constructor + * + * @param ContextInterface $context + * @param GroupRepositoryInterface $groupRepository + * @param UiComponentFactory $uiComponentFactory + * @param array $components + * @param array $data + */ + public function __construct( + ContextInterface $context, + UiComponentFactory $uiComponentFactory, + GroupRepositoryInterface $groupRepository, + array $components = [], + array $data = [] + ) { + $this->groupRepository = $groupRepository; + parent::__construct($context, $uiComponentFactory, $components, $data); + } + + /** + * Prepare Data Source + * + * @param array $dataSource + * @return void + */ + public function prepareDataSource(array & $dataSource) + { + if (isset($dataSource['data']['items'])) { + foreach ($dataSource['data']['items'] as & $item) { + $item[$this->getData('name')] = $this->groupRepository->getById($item[$this->getData('name')]) + ->getCode(); + } + } + } +} diff --git a/app/code/Magento/Sales/Ui/Component/Listing/Column/Invoice/State.php b/app/code/Magento/Sales/Ui/Component/Listing/Column/Invoice/State.php new file mode 100644 index 0000000000000000000000000000000000000000..d65b8e5e7f842165d8df63cf7d987da966aabf3a --- /dev/null +++ b/app/code/Magento/Sales/Ui/Component/Listing/Column/Invoice/State.php @@ -0,0 +1,57 @@ +<?php +/** + * Copyright © 2015 Magento. All rights reserved. + * See COPYING.txt for license details. + */ +namespace Magento\Sales\Ui\Component\Listing\Column\Invoice; + +use Magento\Ui\Component\Listing\Columns\Column; +use Magento\Framework\View\Element\UiComponent\ContextInterface; +use Magento\Framework\View\Element\UiComponentFactory; +use Magento\Sales\Model\Order\InvoiceFactory; + +/** + * Class State + */ +class State extends Column +{ + /** + * @var string[] + */ + protected $states; + + /** + * Constructor + * + * @param ContextInterface $context + * @param UiComponentFactory $uiComponentFactory + * @param InvoiceFactory $invoiceFactory + * @param array $components + * @param array $data + */ + public function __construct( + ContextInterface $context, + UiComponentFactory $uiComponentFactory, + InvoiceFactory $invoiceFactory, + array $components = [], + array $data = [] + ) { + $this->states = $invoiceFactory->create()->getStates(); + parent::__construct($context, $uiComponentFactory, $components, $data); + } + + /** + * Prepare Data Source + * + * @param array $dataSource + * @return void + */ + public function prepareDataSource(array & $dataSource) + { + if (isset($dataSource['data']['items'])) { + foreach ($dataSource['data']['items'] as & $item) { + $item[$this->getData('name')] = $this->states[$item[$this->getData('name')]]; + } + } + } +} diff --git a/app/code/Magento/Sales/Ui/Component/Listing/Column/Invoice/State/Options.php b/app/code/Magento/Sales/Ui/Component/Listing/Column/Invoice/State/Options.php new file mode 100644 index 0000000000000000000000000000000000000000..8c4ec82ee21f6f950693ef96a0e7e544e892b81e --- /dev/null +++ b/app/code/Magento/Sales/Ui/Component/Listing/Column/Invoice/State/Options.php @@ -0,0 +1,57 @@ +<?php +/** + * Copyright © 2015 Magento. All rights reserved. + * See COPYING.txt for license details. + */ +namespace Magento\Sales\Ui\Component\Listing\Column\Invoice\State; + +use Magento\Framework\Data\OptionSourceInterface; +use Magento\Sales\Model\Order\InvoiceFactory; + +/** + * Class Options + */ +class Options implements OptionSourceInterface +{ + /** + * @var array + */ + protected $options; + + /** + * @var InvoiceFactory + */ + protected $invoiceFactory; + + /** + * Constructor + * + * @param InvoiceFactory $invoiceFactory + */ + public function __construct(InvoiceFactory $invoiceFactory) + { + $this->invoiceFactory = $invoiceFactory; + } + + /** + * Get options + * + * @return array + */ + public function toOptionArray() + { + if ($this->options === null) { + $this->options = []; + + /** @var \Magento\Framework\Phrase $state */ + foreach ($this->invoiceFactory->create()->getStates() as $id => $state) { + $this->options[] = [ + 'value' => $id, + 'label' => $state->render() + ]; + } + } + + return $this->options; + } +} diff --git a/app/code/Magento/Sales/Ui/Component/Listing/Column/OrderActions.php b/app/code/Magento/Sales/Ui/Component/Listing/Column/OrderActions.php new file mode 100644 index 0000000000000000000000000000000000000000..3989e329d866e28f0fa35866956ef6ad32e2776a --- /dev/null +++ b/app/code/Magento/Sales/Ui/Component/Listing/Column/OrderActions.php @@ -0,0 +1,74 @@ +<?php +/** + * Copyright © 2015 Magento. All rights reserved. + * See COPYING.txt for license details. + */ +namespace Magento\Sales\Ui\Component\Listing\Column; + +use Magento\Framework\UrlInterface; +use Magento\Framework\View\Element\UiComponent\ContextInterface; +use Magento\Framework\View\Element\UiComponentFactory; +use Magento\Ui\Component\Listing\Columns\Column; + +/** + * Class OrderActions + */ +class OrderActions extends Column +{ + /** + * Url path + */ + const URL_PATH_VIEW = 'sales/order/view'; + + /** + * @var UrlInterface + */ + protected $urlBuilder; + + /** + * Constructor + * + * @param ContextInterface $context + * @param UiComponentFactory $uiComponentFactory + * @param UrlInterface $urlBuilder + * @param array $components + * @param array $data + */ + public function __construct( + ContextInterface $context, + UiComponentFactory $uiComponentFactory, + UrlInterface $urlBuilder, + array $components = [], + array $data = [] + ) { + $this->urlBuilder = $urlBuilder; + parent::__construct($context, $uiComponentFactory, $components, $data); + } + + /** + * Prepare Data Source + * + * @param array $dataSource + * @return void + */ + public function prepareDataSource(array & $dataSource) + { + if (isset($dataSource['data']['items'])) { + foreach ($dataSource['data']['items'] as & $item) { + if (isset($item['entity_id'])) { + $item[$this->getData('name')] = [ + 'view' => [ + 'href' => $this->urlBuilder->getUrl( + static::URL_PATH_VIEW, + [ + 'order_id' => $item['entity_id'] + ] + ), + 'label' => __('View') + ] + ]; + } + } + } + } +} diff --git a/app/code/Magento/Sales/Ui/Component/Listing/Column/OrderCreditmemoActions.php b/app/code/Magento/Sales/Ui/Component/Listing/Column/OrderCreditmemoActions.php new file mode 100644 index 0000000000000000000000000000000000000000..f2a49891c51f53c38d0ea4055333aee043232354 --- /dev/null +++ b/app/code/Magento/Sales/Ui/Component/Listing/Column/OrderCreditmemoActions.php @@ -0,0 +1,74 @@ +<?php +/** + * Copyright © 2015 Magento. All rights reserved. + * See COPYING.txt for license details. + */ +namespace Magento\Sales\Ui\Component\Listing\Column; + +use Magento\Framework\UrlInterface; +use Magento\Framework\View\Element\UiComponent\ContextInterface; +use Magento\Framework\View\Element\UiComponentFactory; +use Magento\Ui\Component\Listing\Columns\Column; + +/** + * Class OrderActions + */ +class OrderCreditmemoActions extends Column +{ + /** + * Url path + */ + const URL_PATH_VIEW = 'sales/creditmemo/view'; + + /** + * @var UrlInterface + */ + protected $urlBuilder; + + /** + * Constructor + * + * @param ContextInterface $context + * @param UiComponentFactory $uiComponentFactory + * @param UrlInterface $urlBuilder + * @param array $components + * @param array $data + */ + public function __construct( + ContextInterface $context, + UiComponentFactory $uiComponentFactory, + UrlInterface $urlBuilder, + array $components = [], + array $data = [] + ) { + $this->urlBuilder = $urlBuilder; + parent::__construct($context, $uiComponentFactory, $components, $data); + } + + /** + * Prepare Data Source + * + * @param array $dataSource + * @return void + */ + public function prepareDataSource(array & $dataSource) + { + if (isset($dataSource['data']['items'])) { + foreach ($dataSource['data']['items'] as & $item) { + if (isset($item['entity_id'])) { + $item[$this->getData('name')] = [ + 'view' => [ + 'href' => $this->urlBuilder->getUrl( + static::URL_PATH_VIEW, + [ + 'creditmemo_id' => $item['entity_id'] + ] + ), + 'label' => __('View') + ] + ]; + } + } + } + } +} diff --git a/app/code/Magento/Sales/Ui/Component/Listing/Column/OrderInvoiceActions.php b/app/code/Magento/Sales/Ui/Component/Listing/Column/OrderInvoiceActions.php new file mode 100644 index 0000000000000000000000000000000000000000..301b78e0405caf943f55ce8f7e30303733c5a8f2 --- /dev/null +++ b/app/code/Magento/Sales/Ui/Component/Listing/Column/OrderInvoiceActions.php @@ -0,0 +1,74 @@ +<?php +/** + * Copyright © 2015 Magento. All rights reserved. + * See COPYING.txt for license details. + */ +namespace Magento\Sales\Ui\Component\Listing\Column; + +use Magento\Framework\UrlInterface; +use Magento\Framework\View\Element\UiComponent\ContextInterface; +use Magento\Framework\View\Element\UiComponentFactory; +use Magento\Ui\Component\Listing\Columns\Column; + +/** + * Class OrderActions + */ +class OrderInvoiceActions extends Column +{ + /** + * Url path + */ + const URL_PATH_VIEW = 'sales/invoice/view'; + + /** + * @var UrlInterface + */ + protected $urlBuilder; + + /** + * Constructor + * + * @param ContextInterface $context + * @param UiComponentFactory $uiComponentFactory + * @param UrlInterface $urlBuilder + * @param array $components + * @param array $data + */ + public function __construct( + ContextInterface $context, + UiComponentFactory $uiComponentFactory, + UrlInterface $urlBuilder, + array $components = [], + array $data = [] + ) { + $this->urlBuilder = $urlBuilder; + parent::__construct($context, $uiComponentFactory, $components, $data); + } + + /** + * Prepare Data Source + * + * @param array $dataSource + * @return void + */ + public function prepareDataSource(array & $dataSource) + { + if (isset($dataSource['data']['items'])) { + foreach ($dataSource['data']['items'] as & $item) { + if (isset($item['entity_id'])) { + $item[$this->getData('name')] = [ + 'view' => [ + 'href' => $this->urlBuilder->getUrl( + static::URL_PATH_VIEW, + [ + 'invoice_id' => $item['entity_id'] + ] + ), + 'label' => __('View') + ] + ]; + } + } + } + } +} diff --git a/app/code/Magento/Sales/Ui/Component/Listing/Column/OrderShipmentActions.php b/app/code/Magento/Sales/Ui/Component/Listing/Column/OrderShipmentActions.php new file mode 100644 index 0000000000000000000000000000000000000000..d220b755f168915c8f0ed8f00d0e6c33448cf9ac --- /dev/null +++ b/app/code/Magento/Sales/Ui/Component/Listing/Column/OrderShipmentActions.php @@ -0,0 +1,74 @@ +<?php +/** + * Copyright © 2015 Magento. All rights reserved. + * See COPYING.txt for license details. + */ +namespace Magento\Sales\Ui\Component\Listing\Column; + +use Magento\Framework\UrlInterface; +use Magento\Framework\View\Element\UiComponent\ContextInterface; +use Magento\Framework\View\Element\UiComponentFactory; +use Magento\Ui\Component\Listing\Columns\Column; + +/** + * Class OrderActions + */ +class OrderShipmentActions extends Column +{ + /** + * Url path + */ + const URL_PATH_VIEW = 'sales/shipment/view'; + + /** + * @var UrlInterface + */ + protected $urlBuilder; + + /** + * Constructor + * + * @param ContextInterface $context + * @param UiComponentFactory $uiComponentFactory + * @param UrlInterface $urlBuilder + * @param array $components + * @param array $data + */ + public function __construct( + ContextInterface $context, + UiComponentFactory $uiComponentFactory, + UrlInterface $urlBuilder, + array $components = [], + array $data = [] + ) { + $this->urlBuilder = $urlBuilder; + parent::__construct($context, $uiComponentFactory, $components, $data); + } + + /** + * Prepare Data Source + * + * @param array $dataSource + * @return void + */ + public function prepareDataSource(array & $dataSource) + { + if (isset($dataSource['data']['items'])) { + foreach ($dataSource['data']['items'] as & $item) { + if (isset($item['entity_id'])) { + $item[$this->getData('name')] = [ + 'view' => [ + 'href' => $this->urlBuilder->getUrl( + static::URL_PATH_VIEW, + [ + 'shipment_id' => $item['entity_id'] + ] + ), + 'label' => __('View') + ] + ]; + } + } + } + } +} diff --git a/app/code/Magento/Sales/Ui/Component/Listing/Column/PaymentMethod.php b/app/code/Magento/Sales/Ui/Component/Listing/Column/PaymentMethod.php new file mode 100644 index 0000000000000000000000000000000000000000..fa8011a7bb5640950d7a12adc1afcc60a705e50d --- /dev/null +++ b/app/code/Magento/Sales/Ui/Component/Listing/Column/PaymentMethod.php @@ -0,0 +1,58 @@ +<?php +/** + * Copyright © 2015 Magento. All rights reserved. + * See COPYING.txt for license details. + */ +namespace Magento\Sales\Ui\Component\Listing\Column; + +use Magento\Ui\Component\Listing\Columns\Column; +use Magento\Framework\View\Element\UiComponent\ContextInterface; +use Magento\Framework\View\Element\UiComponentFactory; +use Magento\Payment\Helper\Data; + +/** + * Class PaymentMethod + */ +class PaymentMethod extends Column +{ + /** + * @var Data + */ + protected $paymentHelper; + + /** + * Constructor + * + * @param ContextInterface $context + * @param UiComponentFactory $uiComponentFactory + * @param Data $paymentHelper + * @param array $components + * @param array $data + */ + public function __construct( + ContextInterface $context, + UiComponentFactory $uiComponentFactory, + Data $paymentHelper, + array $components = [], + array $data = [] + ) { + $this->paymentHelper = $paymentHelper; + parent::__construct($context, $uiComponentFactory, $components, $data); + } + + /** + * Prepare Data Source + * + * @param array $dataSource + * @return void + */ + public function prepareDataSource(array & $dataSource) + { + if (isset($dataSource['data']['items'])) { + foreach ($dataSource['data']['items'] as & $item) { + $item[$this->getData('name')] = $this->paymentHelper->getMethodInstance($item[$this->getData('name')]) + ->getTitle(); + } + } + } +} diff --git a/app/code/Magento/Sales/Ui/Component/Listing/Column/Price.php b/app/code/Magento/Sales/Ui/Component/Listing/Column/Price.php new file mode 100644 index 0000000000000000000000000000000000000000..28f86b9d365b42e6079da7d121ca850211d9be06 --- /dev/null +++ b/app/code/Magento/Sales/Ui/Component/Listing/Column/Price.php @@ -0,0 +1,57 @@ +<?php +/** + * Copyright © 2015 Magento. All rights reserved. + * See COPYING.txt for license details. + */ +namespace Magento\Sales\Ui\Component\Listing\Column; + +use Magento\Framework\View\Element\UiComponent\ContextInterface; +use Magento\Framework\View\Element\UiComponentFactory; +use Magento\Ui\Component\Listing\Columns\Column; +use Magento\Framework\Pricing\PriceCurrencyInterface; + +/** + * Class Price + */ +class Price extends Column +{ + /** + * @var PriceCurrencyInterface + */ + protected $priceFormatter; + + /** + * Constructor + * + * @param ContextInterface $context + * @param UiComponentFactory $uiComponentFactory + * @param PriceCurrencyInterface $priceFormatter + * @param array $components + * @param array $data + */ + public function __construct( + ContextInterface $context, + UiComponentFactory $uiComponentFactory, + PriceCurrencyInterface $priceFormatter, + array $components = [], + array $data = [] + ) { + $this->priceFormatter = $priceFormatter; + parent::__construct($context, $uiComponentFactory, $components, $data); + } + + /** + * Prepare Data Source + * + * @param array $dataSource + * @return void + */ + public function prepareDataSource(array & $dataSource) + { + if (isset($dataSource['data']['items'])) { + foreach ($dataSource['data']['items'] as & $item) { + $item[$this->getData('name')] = $this->priceFormatter->format($item[$this->getData('name')], false); + } + } + } +} diff --git a/app/code/Magento/Sales/Ui/Component/Listing/Column/Status.php b/app/code/Magento/Sales/Ui/Component/Listing/Column/Status.php new file mode 100644 index 0000000000000000000000000000000000000000..34b6dd60ea31a5456436befff84746ed0d0828ca --- /dev/null +++ b/app/code/Magento/Sales/Ui/Component/Listing/Column/Status.php @@ -0,0 +1,57 @@ +<?php +/** + * Copyright © 2015 Magento. All rights reserved. + * See COPYING.txt for license details. + */ +namespace Magento\Sales\Ui\Component\Listing\Column; + +use Magento\Ui\Component\Listing\Columns\Column; +use Magento\Framework\View\Element\UiComponent\ContextInterface; +use Magento\Framework\View\Element\UiComponentFactory; +use Magento\Sales\Model\Resource\Order\Status\CollectionFactory; + +/** + * Class Status + */ +class Status extends Column +{ + /** + * @var string[] + */ + protected $statuses; + + /** + * Constructor + * + * @param ContextInterface $context + * @param UiComponentFactory $uiComponentFactory + * @param CollectionFactory $collectionFactory + * @param array $components + * @param array $data + */ + public function __construct( + ContextInterface $context, + UiComponentFactory $uiComponentFactory, + CollectionFactory $collectionFactory, + array $components = [], + array $data = [] + ) { + $this->statuses = $collectionFactory->create()->toOptionHash(); + parent::__construct($context, $uiComponentFactory, $components, $data); + } + + /** + * Prepare Data Source + * + * @param array $dataSource + * @return void + */ + public function prepareDataSource(array & $dataSource) + { + if (isset($dataSource['data']['items'])) { + foreach ($dataSource['data']['items'] as & $item) { + $item[$this->getData('name')] = $this->statuses[$item[$this->getData('name')]]; + } + } + } +} diff --git a/app/code/Magento/Sales/Ui/Component/Listing/Column/Status/Options.php b/app/code/Magento/Sales/Ui/Component/Listing/Column/Status/Options.php new file mode 100644 index 0000000000000000000000000000000000000000..4f4e3f46b8a64cfaea1024f542c8f7de6a9a5a4f --- /dev/null +++ b/app/code/Magento/Sales/Ui/Component/Listing/Column/Status/Options.php @@ -0,0 +1,48 @@ +<?php +/** + * Copyright © 2015 Magento. All rights reserved. + * See COPYING.txt for license details. + */ +namespace Magento\Sales\Ui\Component\Listing\Column\Status; + +use Magento\Framework\Data\OptionSourceInterface; +use Magento\Sales\Model\Resource\Order\Status\CollectionFactory; + +/** + * Class Options + */ +class Options implements OptionSourceInterface +{ + /** + * @var array + */ + protected $options; + + /** + * @var CollectionFactory + */ + protected $collectionFactory; + + /** + * Constructor + * + * @param CollectionFactory $collectionFactory + */ + public function __construct(CollectionFactory $collectionFactory) + { + $this->collectionFactory = $collectionFactory; + } + + /** + * Get options + * + * @return array + */ + public function toOptionArray() + { + if ($this->options === null) { + $this->options = $this->collectionFactory->create()->toOptionArray(); + } + return $this->options; + } +} diff --git a/app/code/Magento/Sales/etc/di.xml b/app/code/Magento/Sales/etc/di.xml index 8b0d60ea3c63cf9cfcc05fd415a49e7c1e3cb356..2cb95358885dcd789511a38416b1802b5e7a32f8 100755 --- a/app/code/Magento/Sales/etc/di.xml +++ b/app/code/Magento/Sales/etc/di.xml @@ -149,12 +149,12 @@ </virtualType> <virtualType name="Magento\Sales\Model\Observer\Order\Shipment\IndexGrid" type="Magento\Sales\Model\Observer\IndexGrid"> <arguments> - <argument name="entityGrid" xsi:type="object">Magento\Sales\Model\Resource\Order\Shipment\Grid</argument> + <argument name="entityGrid" xsi:type="object">ShipmentGridAggregator</argument> </arguments> </virtualType> <virtualType name="Magento\Sales\Model\Observer\Order\Creditmemo\IndexGrid" type="Magento\Sales\Model\Observer\IndexGrid"> <arguments> - <argument name="entityGrid" xsi:type="object">Magento\Sales\Model\Resource\Order\Creditmemo\Grid</argument> + <argument name="entityGrid" xsi:type="object">CreditmemoGridAggregator</argument> </arguments> </virtualType> <virtualType name="Magento\Sales\Model\Observer\Order\SendEmails" type="Magento\Sales\Model\Observer\SendEmails"> @@ -268,6 +268,299 @@ <argument name="entityRelationComposite" xsi:type="object">CreditmemoRelationsComposite</argument> </arguments> </type> + <virtualType name="Magento\Sales\Model\Resource\Order\Grid" type="Magento\Sales\Model\Resource\Grid"> + <arguments> + <argument name="mainTableName" xsi:type="string">sales_order</argument> + <argument name="gridTableName" xsi:type="string">sales_order_grid</argument> + <argument name="orderIdField" xsi:type="string">sales_order.entity_id</argument> + <argument name="joins" xsi:type="array"> + <item name="sales_shipping_address" xsi:type="array"> + <item name="table" xsi:type="string">sales_order_address</item> + <item name="origin_column" xsi:type="string">shipping_address_id</item> + <item name="target_column" xsi:type="string">entity_id</item> + </item> + <item name="sales_billing_address" xsi:type="array"> + <item name="table" xsi:type="string">sales_order_address</item> + <item name="origin_column" xsi:type="string">billing_address_id</item> + <item name="target_column" xsi:type="string">entity_id</item> + </item> + </argument> + <argument name="columns" xsi:type="array"> + <item name="entity_id" xsi:type="string">sales_order.entity_id</item> + <item name="status" xsi:type="string">sales_order.status</item> + <item name="store_id" xsi:type="string">sales_order.store_id</item> + <item name="store_name" xsi:type="string">sales_order.store_name</item> + <item name="customer_id" xsi:type="string">sales_order.customer_id</item> + <item name="base_grand_total" xsi:type="string">sales_order.base_grand_total</item> + <item name="base_total_paid" xsi:type="string">sales_order.base_total_paid</item> + <item name="grand_total" xsi:type="string">sales_order.grand_total</item> + <item name="total_paid" xsi:type="string">sales_order.total_paid</item> + <item name="increment_id" xsi:type="string">sales_order.increment_id</item> + <item name="base_currency_code" xsi:type="string">sales_order.base_currency_code</item> + <item name="order_currency_code" xsi:type="string">sales_order.order_currency_code</item> + <item name="shipping_name" xsi:type="object">ShippingNameAggregator</item> + <item name="billing_name" xsi:type="object">BillingNameAggregator</item> + <item name="created_at" xsi:type="string">sales_order.created_at</item> + <item name="updated_at" xsi:type="string">sales_order.updated_at</item> + <item name="billing_address" xsi:type="object">BillingAddressAggregator</item> + <item name="shipping_address" xsi:type="object">ShippingAddressAggregator</item> + <item name="shipping_information" xsi:type="string">sales_order.shipping_description</item> + <item name="customer_email" xsi:type="string">sales_order.customer_email</item> + <item name="customer_group" xsi:type="string">sales_order.customer_group_id</item> + <item name="subtotal" xsi:type="string">sales_order.base_subtotal</item> + <item name="shipping_and_handling" xsi:type="string">sales_order.base_shipping_amount</item> + <item name="customer_name" xsi:type="object">CustomerNameAggregator</item> + <item name="payment_method" xsi:type="object">PaymentMethodSubSelect</item> + <item name="total_refunded" xsi:type="string">sales_order.total_refunded</item> + </argument> + </arguments> + </virtualType> + <virtualType name="ShipmentGridAggregator" type="Magento\Sales\Model\Resource\Grid"> + <arguments> + <argument name="mainTableName" xsi:type="string">sales_shipment</argument> + <argument name="gridTableName" xsi:type="string">sales_shipment_grid</argument> + <argument name="orderIdField" xsi:type="string">sales_shipment.order_id</argument> + <argument name="joins" xsi:type="array"> + <item name="sales_order" xsi:type="array"> + <item name="table" xsi:type="string">sales_order</item> + <item name="origin_column" xsi:type="string">order_id</item> + <item name="target_column" xsi:type="string">entity_id</item> + </item> + <item name="sales_shipping_address" xsi:type="array"> + <item name="table" xsi:type="string">sales_order_address</item> + <item name="origin_column" xsi:type="string">shipping_address_id</item> + <item name="target_column" xsi:type="string">entity_id</item> + </item> + <item name="sales_billing_address" xsi:type="array"> + <item name="table" xsi:type="string">sales_order_address</item> + <item name="origin_column" xsi:type="string">billing_address_id</item> + <item name="target_column" xsi:type="string">entity_id</item> + </item> + </argument> + <argument name="columns" xsi:type="array"> + <item name="entity_id" xsi:type="string">sales_shipment.entity_id</item> + <item name="increment_id" xsi:type="string">sales_shipment.increment_id</item> + <item name="store_id" xsi:type="string">sales_shipment.store_id</item> + <item name="order_increment_id" xsi:type="string">sales_order.increment_id</item> + <item name="order_created_at" xsi:type="string">sales_order.created_at</item> + <item name="customer_name" xsi:type="object">CustomerNameAggregator</item> + <item name="total_qty" xsi:type="string">sales_shipment.total_qty</item> + <item name="shipment_status" xsi:type="string">sales_shipment.shipment_status</item> + <item name="order_status" xsi:type="string">sales_order.status</item> + <item name="billing_address" xsi:type="object">BillingAddressAggregator</item> + <item name="shipping_address" xsi:type="object">ShippingAddressAggregator</item> + <item name="billing_name" xsi:type="object">BillingNameAggregator</item> + <item name="shipping_name" xsi:type="object">ShippingNameAggregator</item> + <item name="customer_email" xsi:type="string">sales_order.customer_email</item> + <item name="customer_group_id" xsi:type="string">sales_order.customer_group_id</item> + <item name="payment_method" xsi:type="object">PaymentMethodSubSelect</item> + <item name="created_at" xsi:type="string">sales_shipment.created_at</item> + <item name="updated_at" xsi:type="string">sales_shipment.updated_at</item> + <item name="order_id" xsi:type="string">sales_shipment.order_id</item> + <item name="shipping_information" xsi:type="string">sales_order.shipping_description</item> + </argument> + </arguments> + </virtualType> + <virtualType name="CreditmemoGridAggregator" type="Magento\Sales\Model\Resource\Grid"> + <arguments> + <argument name="mainTableName" xsi:type="string">sales_creditmemo</argument> + <argument name="gridTableName" xsi:type="string">sales_creditmemo_grid</argument> + <argument name="orderIdField" xsi:type="string">sales_creditmemo.order_id</argument> + <argument name="joins" xsi:type="array"> + <item name="sales_shipping_address" xsi:type="array"> + <item name="table" xsi:type="string">sales_order_address</item> + <item name="origin_column" xsi:type="string">shipping_address_id</item> + <item name="target_column" xsi:type="string">entity_id</item> + </item> + <item name="sales_billing_address" xsi:type="array"> + <item name="table" xsi:type="string">sales_order_address</item> + <item name="origin_column" xsi:type="string">billing_address_id</item> + <item name="target_column" xsi:type="string">entity_id</item> + </item> + <item name="sales_order" xsi:type="array"> + <item name="table" xsi:type="string">sales_order</item> + <item name="origin_column" xsi:type="string">order_id</item> + <item name="target_column" xsi:type="string">entity_id</item> + </item> + </argument> + <argument name="columns" xsi:type="array"> + <item name="entity_id" xsi:type="string">sales_creditmemo.entity_id</item> + <item name="increment_id" xsi:type="string">sales_creditmemo.increment_id</item> + <item name="created_at" xsi:type="string">sales_creditmemo.created_at</item> + <item name="updated_at" xsi:type="string">sales_creditmemo.updated_at</item> + <item name="order_id" xsi:type="string">sales_order.entity_id</item> + <item name="order_increment_id" xsi:type="string">sales_order.increment_id</item> + <item name="order_created_at" xsi:type="string">sales_order.created_at</item> + <item name="billing_name" xsi:type="object">BillingNameAggregator</item> + <item name="state" xsi:type="string">sales_creditmemo.state</item> + <item name="base_grand_total" xsi:type="string">sales_creditmemo.base_grand_total</item> + <item name="order_status" xsi:type="string">sales_order.status</item> + <item name="store_id" xsi:type="string">sales_creditmemo.store_id</item> + <item name="billing_address" xsi:type="object">BillingAddressAggregator</item> + <item name="shipping_address" xsi:type="object">ShippingAddressAggregator</item> + <item name="customer_name" xsi:type="object">CustomerNameAggregator</item> + <item name="customer_email" xsi:type="string">sales_order.customer_email</item> + <item name="customer_group_id" xsi:type="string">sales_order.customer_group_id</item> + <item name="payment_method" xsi:type="object">PaymentMethodSubSelect</item> + <item name="shipping_information" xsi:type="string">sales_order.shipping_description</item> + <item name="subtotal" xsi:type="string">sales_creditmemo.subtotal</item> + <item name="shipping_and_handling" xsi:type="string">sales_creditmemo.shipping_amount</item> + <item name="adjustment_positive" xsi:type="string">sales_creditmemo.adjustment_positive</item> + <item name="adjustment_negative" xsi:type="string">sales_creditmemo.adjustment_negative</item> + <item name="order_base_grand_total" xsi:type="string">sales_order.base_grand_total</item> + </argument> + </arguments> + </virtualType> + <virtualType name="Magento\Sales\Model\Resource\Order\Invoice\Grid" type="Magento\Sales\Model\Resource\Grid"> + <arguments> + <argument name="mainTableName" xsi:type="string">sales_invoice</argument> + <argument name="gridTableName" xsi:type="string">sales_invoice_grid</argument> + <argument name="orderIdField" xsi:type="string">sales_invoice.order_id</argument> + <argument name="joins" xsi:type="array"> + <item name="sales_order" xsi:type="array"> + <item name="table" xsi:type="string">sales_order</item> + <item name="origin_column" xsi:type="string">order_id</item> + <item name="target_column" xsi:type="string">entity_id</item> + </item> + <item name="sales_shipping_address" xsi:type="array"> + <item name="table" xsi:type="string">sales_order_address</item> + <item name="origin_column" xsi:type="string">shipping_address_id</item> + <item name="target_column" xsi:type="string">entity_id</item> + </item> + <item name="sales_billing_address" xsi:type="array"> + <item name="table" xsi:type="string">sales_order_address</item> + <item name="origin_column" xsi:type="string">billing_address_id</item> + <item name="target_column" xsi:type="string">entity_id</item> + </item> + </argument> + <argument name="columns" xsi:type="array"> + <item name="entity_id" xsi:type="string">sales_invoice.entity_id</item> + <item name="increment_id" xsi:type="string">sales_invoice.increment_id</item> + <item name="state" xsi:type="string">sales_invoice.state</item> + <item name="store_id" xsi:type="string">sales_invoice.store_id</item> + <item name="store_name" xsi:type="string">sales_order.store_name</item> + <item name="order_id" xsi:type="string">sales_invoice.order_id</item> + <item name="order_increment_id" xsi:type="string">sales_order.increment_id</item> + <item name="order_created_at" xsi:type="string">sales_order.created_at</item> + <item name="customer_name" xsi:type="object">CustomerNameAggregator</item> + <item name="customer_email" xsi:type="string">sales_order.customer_email</item> + <item name="customer_group_id" xsi:type="string">sales_order.customer_group_id</item> + <item name="payment_method" xsi:type="object">PaymentMethodSubSelect</item> + <item name="store_currency_code" xsi:type="string">sales_invoice.store_currency_code</item> + <item name="order_currency_code" xsi:type="string">sales_invoice.order_currency_code</item> + <item name="base_currency_code" xsi:type="string">sales_invoice.base_currency_code</item> + <item name="global_currency_code" xsi:type="string">sales_invoice.global_currency_code</item> + <item name="billing_name" xsi:type="object">BillingNameAggregator</item> + <item name="billing_address" xsi:type="object">BillingAddressAggregator</item> + <item name="shipping_address" xsi:type="object">ShippingAddressAggregator</item> + <item name="shipping_information" xsi:type="string">sales_order.shipping_description</item> + <item name="subtotal" xsi:type="string">sales_order.base_subtotal</item> + <item name="shipping_and_handling" xsi:type="string">sales_order.base_shipping_amount</item> + <item name="grand_total" xsi:type="string">sales_invoice.grand_total</item> + <item name="created_at" xsi:type="string">sales_invoice.created_at</item> + <item name="updated_at" xsi:type="string">sales_invoice.updated_at</item> + </argument> + </arguments> + </virtualType> + <virtualType name="CustomerNameAggregator" type="Magento\Sales\Model\Resource\Order\Grid\Sql\Concat"> + <arguments> + <argument name="columns" xsi:type="array"> + <item name="customer_firstname" xsi:type="string">sales_order.customer_firstname</item> + <item name="customer_lastname" xsi:type="string">sales_order.customer_lastname</item> + </argument> + </arguments> + </virtualType> + <virtualType name="ShippingNameAggregator" type="Magento\Sales\Model\Resource\Order\Grid\Sql\Concat"> + <arguments> + <argument name="columns" xsi:type="array"> + <item name="firstname" xsi:type="string">sales_shipping_address.firstname</item> + <item name="lastname" xsi:type="string">sales_shipping_address.lastname</item> + </argument> + </arguments> + </virtualType> + <virtualType name="BillingNameAggregator" type="Magento\Sales\Model\Resource\Order\Grid\Sql\Concat"> + <arguments> + <argument name="columns" xsi:type="array"> + <item name="firstname" xsi:type="string">sales_billing_address.firstname</item> + <item name="lastname" xsi:type="string">sales_billing_address.lastname</item> + </argument> + </arguments> + </virtualType> + <virtualType name="ShippingAddressAggregator" type="Magento\Sales\Model\Resource\Order\Grid\Sql\Concat"> + <arguments> + <argument name="columns" xsi:type="array"> + <item name="street" xsi:type="string">sales_shipping_address.street</item> + <item name="city" xsi:type="string">sales_shipping_address.city</item> + <item name="region" xsi:type="string">sales_shipping_address.region</item> + <item name="postcode" xsi:type="string">sales_shipping_address.postcode</item> + </argument> + <argument name="separator" xsi:type="string">, </argument> + </arguments> + </virtualType> + <virtualType name="BillingAddressAggregator" type="Magento\Sales\Model\Resource\Order\Grid\Sql\Concat"> + <arguments> + <argument name="columns" xsi:type="array"> + <item name="street" xsi:type="string">sales_billing_address.street</item> + <item name="city" xsi:type="string">sales_billing_address.city</item> + <item name="region" xsi:type="string">sales_billing_address.region</item> + <item name="postcode" xsi:type="string">sales_billing_address.postcode</item> + </argument> + <argument name="separator" xsi:type="string">, </argument> + </arguments> + </virtualType> + <virtualType name="PaymentMethodSubSelect" type="Magento\Sales\Model\Resource\Order\Grid\Sql\SubSelect"> + <arguments> + <argument name="connectionName" xsi:type="string">sales_read</argument> + <argument name="table" xsi:type="string">sales_order_payment</argument> + <argument name="columns" xsi:type="array"> + <item name="method" xsi:type="string">method</item> + </argument> + <argument name="originColumn" xsi:type="string">parent_id</argument> + <argument name="targetColumn" xsi:type="string">sales_order.entity_id</argument> + </arguments> + </virtualType> + <type name="Magento\Sales\Model\Resource\GridPool"> + <arguments> + <argument name="grids" xsi:type="array"> + <item name="order_grid" xsi:type="object">Magento\Sales\Model\Resource\Order\Grid</item> + <item name="invoice_grid" xsi:type="object">Magento\Sales\Model\Resource\Order\Invoice\Grid</item> + <item name="shipment_grid" xsi:type="object">ShipmentGridAggregator</item> + <item name="creditmemo_grid" xsi:type="object">CreditmemoGridAggregator</item> + </argument> + </arguments> + </type> + <virtualType name="SalesGirdFilterPool" type="Magento\Framework\View\Element\UiComponent\DataProvider\FilterPool"> + <arguments> + <argument name="appliers" xsi:type="array"> + <item name="regular" xsi:type="object">Magento\Framework\View\Element\UiComponent\DataProvider\RegularFilter</item> + <item name="fulltext" xsi:type="object">Magento\Framework\View\Element\UiComponent\DataProvider\FulltextFilter</item> + </argument> + </arguments> + </virtualType> + <virtualType name="OrderGridDataProvider" type="Magento\Framework\View\Element\UiComponent\DataProvider\DataProvider"> + <arguments> + <argument name="collection" xsi:type="object" shared="false">Magento\Sales\Model\Resource\Order\Grid\Collection</argument> + <argument name="filterPool" xsi:type="object" shared="false">SalesGirdFilterPool</argument> + </arguments> + </virtualType> + <virtualType name="InvoiceGridDataProvider" type="Magento\Framework\View\Element\UiComponent\DataProvider\DataProvider"> + <arguments> + <argument name="collection" xsi:type="object" shared="false">Magento\Sales\Model\Resource\Order\Invoice\Grid\Collection</argument> + <argument name="filterPool" xsi:type="object" shared="false">SalesGirdFilterPool</argument> + </arguments> + </virtualType> + <virtualType name="ShipmentGridDataProvider" type="Magento\Framework\View\Element\UiComponent\DataProvider\DataProvider"> + <arguments> + <argument name="collection" xsi:type="object" shared="false">Magento\Sales\Model\Resource\Order\Shipment\Grid\Collection</argument> + <argument name="filterPool" xsi:type="object" shared="false">SalesGirdFilterPool</argument> + </arguments> + </virtualType> + <virtualType name="CreditmemoGridDataProvider" type="Magento\Framework\View\Element\UiComponent\DataProvider\DataProvider"> + <arguments> + <argument name="collection" xsi:type="object" shared="false">Magento\Sales\Model\Resource\Order\Creditmemo\Grid\Collection</argument> + <argument name="filterPool" xsi:type="object" shared="false">SalesGirdFilterPool</argument> + </arguments> + </virtualType> <type name="Magento\Sales\Model\Order\Config"> <arguments> <argument name="state" xsi:type="object">Magento\Framework\App\State\Proxy</argument> 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 index 84a187236ff659291944f3bfcdadbcb8b124f638..e4cb20d646cbe4539dbf4a76a942de8f5729b6f1 100644 --- 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 @@ -119,12 +119,12 @@ </block> <block class="Magento\Backend\Block\Widget\Grid\Column" as="base_grand_total"> <arguments> - <argument name="id" xsi:type="string">grand_total</argument> + <argument name="id" xsi:type="string">base_grand_total</argument> <argument name="header" xsi:type="string" translate="true">Refunded</argument> <argument name="type" xsi:type="string">currency</argument> <argument name="currency" xsi:type="string">order_currency_code</argument> <argument name="rate" xsi:type="string">1</argument> - <argument name="index" xsi:type="string">grand_total</argument> + <argument name="index" xsi:type="string">base_grand_total</argument> <argument name="header_css_class" xsi:type="string">col-refunded</argument> <argument name="column_css_class" xsi:type="string">col-refunded</argument> </arguments> diff --git a/app/code/Magento/Sales/view/adminhtml/layout/sales_creditmemo_index.xml b/app/code/Magento/Sales/view/adminhtml/layout/sales_creditmemo_index.xml index 6eb3131a354af879f2fa048681a323ee34057b5b..6b970cc8cf956b40389db5876903f3c307cd8aca 100644 --- a/app/code/Magento/Sales/view/adminhtml/layout/sales_creditmemo_index.xml +++ b/app/code/Magento/Sales/view/adminhtml/layout/sales_creditmemo_index.xml @@ -6,10 +6,10 @@ */ --> <page xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../../../../../../../lib/internal/Magento/Framework/View/Layout/etc/page_configuration.xsd"> - <update handle="sales_creditmemo_grid_block"/> + <update handle="styles"/> <body> <referenceContainer name="content"> - <block class="Magento\Sales\Block\Adminhtml\Creditmemo" name="sales_creditmemo.grid.container"/> + <uiComponent name="sales_order_creditmemo_grid"/> </referenceContainer> </body> </page> diff --git a/app/code/Magento/Sales/view/adminhtml/layout/sales_invoice_index.xml b/app/code/Magento/Sales/view/adminhtml/layout/sales_invoice_index.xml index 0ee20f6a09d20ac5667d94da71163087f11c69ac..fd5defa33f9fc9a9aca2c79ebd83dcfaef4ab200 100644 --- a/app/code/Magento/Sales/view/adminhtml/layout/sales_invoice_index.xml +++ b/app/code/Magento/Sales/view/adminhtml/layout/sales_invoice_index.xml @@ -6,10 +6,10 @@ */ --> <page xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../../../../../../../lib/internal/Magento/Framework/View/Layout/etc/page_configuration.xsd"> - <update handle="sales_invoice_grid_block"/> + <update handle="styles"/> <body> <referenceContainer name="content"> - <block class="Magento\Sales\Block\Adminhtml\Invoice" name="sales_invoice.grid.container"/> + <uiComponent name="sales_order_invoice_grid"/> </referenceContainer> </body> </page> diff --git a/app/code/Magento/Sales/view/adminhtml/layout/sales_order_creditmemo_grid_block.xml b/app/code/Magento/Sales/view/adminhtml/layout/sales_order_creditmemo_grid_block.xml index 8efdf7597cfbe6b996fdd848f9d38fc7bd71923c..bdd87e5b84707f48e9c1513713819993e82664df 100644 --- a/app/code/Magento/Sales/view/adminhtml/layout/sales_order_creditmemo_grid_block.xml +++ b/app/code/Magento/Sales/view/adminhtml/layout/sales_order_creditmemo_grid_block.xml @@ -72,7 +72,7 @@ </block> <block class="Magento\Backend\Block\Widget\Grid\Column" as="base_grand_total"> <arguments> - <argument name="id" xsi:type="string">grand_total</argument> + <argument name="id" xsi:type="string">base_grand_total</argument> <argument name="header" xsi:type="string" translate="true">Refunded</argument> <argument name="type" xsi:type="string">currency</argument> <argument name="currency" xsi:type="string">order_currency_code</argument> diff --git a/app/code/Magento/Sales/view/adminhtml/layout/sales_order_index.xml b/app/code/Magento/Sales/view/adminhtml/layout/sales_order_index.xml index a39401798a8fa341eca2cfbe01b67dda12f25fd9..5fd11e69602d1e91a6e46058613a7958660e0749 100644 --- a/app/code/Magento/Sales/view/adminhtml/layout/sales_order_index.xml +++ b/app/code/Magento/Sales/view/adminhtml/layout/sales_order_index.xml @@ -6,10 +6,10 @@ */ --> <page xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../../../../../../../lib/internal/Magento/Framework/View/Layout/etc/page_configuration.xsd"> - <update handle="sales_order_grid_block"/> + <update handle="styles"/> <body> <referenceContainer name="content"> - <block class="Magento\Sales\Block\Adminhtml\Order" name="sales_order.grid.container"/> + <uiComponent name="sales_order_grid"/> </referenceContainer> </body> </page> diff --git a/app/code/Magento/Sales/view/adminhtml/layout/sales_shipment_index.xml b/app/code/Magento/Sales/view/adminhtml/layout/sales_shipment_index.xml index 285e15724f456d53cd7b76a2dd7d4886bdd9545c..8e8a70348b360b45563968bab7bde600d61fe95c 100644 --- a/app/code/Magento/Sales/view/adminhtml/layout/sales_shipment_index.xml +++ b/app/code/Magento/Sales/view/adminhtml/layout/sales_shipment_index.xml @@ -6,10 +6,10 @@ */ --> <page xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../../../../../../../lib/internal/Magento/Framework/View/Layout/etc/page_configuration.xsd"> - <update handle="sales_shipment_grid_block"/> + <update handle="styles"/> <body> <referenceContainer name="content"> - <block class="Magento\Sales\Block\Adminhtml\Shipment" name="sales_shipment.grid.container"/> + <uiComponent name="sales_order_shipment_grid"/> </referenceContainer> </body> -</page> +</page> \ No newline at end of file diff --git a/app/code/Magento/Sales/view/adminhtml/ui_component/sales_order_creditmemo_grid.xml b/app/code/Magento/Sales/view/adminhtml/ui_component/sales_order_creditmemo_grid.xml new file mode 100644 index 0000000000000000000000000000000000000000..99b86384d7c8c1d100b492f837098fcdf5379313 --- /dev/null +++ b/app/code/Magento/Sales/view/adminhtml/ui_component/sales_order_creditmemo_grid.xml @@ -0,0 +1,782 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!-- +/** + * Copyright © 2015 Magento. All rights reserved. + * See COPYING.txt for license details. + */ +--> +<listing xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../../../../Ui/etc/ui_configuration.xsd"> + <argument name="data" xsi:type="array"> + <item name="js_config" xsi:type="array"> + <item name="provider" xsi:type="string">sales_order_creditmemo_grid.sales_order_creditmemo_grid_data_source</item> + <item name="deps" xsi:type="string">sales_order_creditmemo_grid.sales_order_creditmemo_grid_data_source</item> + </item> + <item name="spinner" xsi:type="string">sales_order_creditmemo_columns</item> + </argument> + <dataSource name="sales_order_creditmemo_grid_data_source"> + <argument name="dataProvider" xsi:type="configurableObject"> + <argument name="class" xsi:type="string">CreditmemoGridDataProvider</argument> + <argument name="name" xsi:type="string">sales_order_creditmemo_grid_data_source</argument> + <argument name="primaryFieldName" xsi:type="string">increment_id</argument> + <argument name="requestFieldName" xsi:type="string">id</argument> + <argument name="data" xsi:type="array"> + <item name="config" xsi:type="array"> + <item name="update_url" xsi:type="url" path="mui/index/render"/> + </item> + </argument> + </argument> + <argument name="data" xsi:type="array"> + <item name="js_config" xsi:type="array"> + <item name="component" xsi:type="string">Magento_Ui/js/grid/provider</item> + </item> + </argument> + </dataSource> + <container name="listing_top"> + <argument name="data" xsi:type="array"> + <item name="config" xsi:type="array"> + <item name="template" xsi:type="string">ui/grid/toolbar</item> + </item> + </argument> + <bookmark name="bookmarks"> + <argument name="data" xsi:type="array"> + <item name="config" xsi:type="array"> + <item name="component" xsi:type="string">Magento_Ui/js/grid/controls/bookmarks/bookmarks</item> + <item name="displayArea" xsi:type="string">dataGridActions</item> + <item name="storageConfig" xsi:type="array"> + <item name="saveUrl" xsi:type="url" path="mui/bookmark/save"/> + <item name="deleteUrl" xsi:type="url" path="mui/bookmark/delete"/> + <item name="namespace" xsi:type="string">sales_order_creditmemo_grid</item> + </item> + </item> + </argument> + </bookmark> + <container name="columns_controls"> + <argument name="data" xsi:type="array"> + <item name="config" xsi:type="array"> + <item name="columnsData" xsi:type="array"> + <item name="provider" xsi:type="string">sales_order_creditmemo_grid.sales_order_creditmemo_grid.sales_order_creditmemo_columns</item> + </item> + <item name="component" xsi:type="string">Magento_Ui/js/grid/controls/columns</item> + <item name="displayArea" xsi:type="string">dataGridActions</item> + </item> + </argument> + </container> + <exportButton name="export_button"> + <argument name="data" xsi:type="array"> + <item name="config" xsi:type="array"> + <item name="displayArea" xsi:type="string">dataGridActions</item> + <item name="options" xsi:type="array"> + <item name="cvs" xsi:type="array"> + <item name="value" xsi:type="string">csv</item> + <item name="label" xsi:type="string" translate="true">CSV</item> + <item name="url" xsi:type="string">sales/creditmemo/exportCsv</item> + </item> + <item name="xml" xsi:type="array"> + <item name="value" xsi:type="string">xml</item> + <item name="label" xsi:type="string" translate="true">Excel XML</item> + <item name="url" xsi:type="string">sales/creditmemo/exportExcel</item> + </item> + </item> + </item> + </argument> + </exportButton> + <filterSearch name="fulltext"> + <argument name="data" xsi:type="array"> + <item name="config" xsi:type="array"> + <item name="provider" xsi:type="string">sales_order_creditmemo_grid.sales_order_creditmemo_grid_data_source</item> + <item name="chipsProvider" xsi:type="string">sales_order_creditmemo_grid.sales_order_creditmemo_grid.listing_top.listing_filters_chips</item> + <item name="storageConfig" xsi:type="array"> + <item name="provider" xsi:type="string">sales_order_creditmemo_grid.sales_order_creditmemo_grid.listing_top.bookmarks</item> + <item name="namespace" xsi:type="string">current.search</item> + </item> + </item> + </argument> + </filterSearch> + <filters name="listing_filters"> + <argument name="data" xsi:type="array"> + <item name="config" xsi:type="array"> + <item name="displayArea" xsi:type="string">dataGridFilters</item> + <item name="dataScope" xsi:type="string">filters</item> + <item name="storageConfig" xsi:type="array"> + <item name="provider" xsi:type="string">sales_order_creditmemo_grid.sales_order_creditmemo_grid.listing_top.bookmarks</item> + <item name="namespace" xsi:type="string">current.filters</item> + </item> + <item name="childDefaults" xsi:type="array"> + <item name="provider" xsi:type="string">sales_order_creditmemo_grid.sales_order_creditmemo_grid.listing_top.listing_filters</item> + <item name="imports" xsi:type="array"> + <item name="visible" xsi:type="string">sales_order_creditmemo_grid.sales_order_creditmemo_grid.listing_top.bookmarks:current.columns.${ $.index }.visible</item> + </item> + </item> + </item> + </argument> + <filterInput name="increment_id"> + <argument name="data" xsi:type="array"> + <item name="config" xsi:type="array"> + <item name="dataScope" xsi:type="string">increment_id</item> + <item name="label" xsi:type="string" translate="true">Credit Memo</item> + </item> + </argument> + </filterInput> + <filterRange name="created_at" class="Magento\Ui\Component\Filters\Type\DateRange"> + <argument name="data" xsi:type="array"> + <item name="config" xsi:type="array"> + <item name="dataScope" xsi:type="string">created_at</item> + <item name="label" xsi:type="string" translate="true">Created</item> + <item name="childDefaults" xsi:type="array"> + <item name="provider" xsi:type="string">sales_order_creditmemo_grid.sales_order_creditmemo_grid.listing_top.listing_filters</item> + </item> + </item> + </argument> + <filterDate name="from"> + <argument name="data" xsi:type="array"> + <item name="config" xsi:type="array"> + <item name="dataScope" xsi:type="string">from</item> + <item name="label" xsi:type="string" translate="true">From</item> + <item name="placeholder" xsi:type="string" translate="true">From</item> + <item name="dateFormat" xsi:type="string" translate="true">MM/dd/YYYY</item> + </item> + </argument> + </filterDate> + <filterDate name="to"> + <argument name="data" xsi:type="array"> + <item name="config" xsi:type="array"> + <item name="dataScope" xsi:type="string">to</item> + <item name="label" xsi:type="string" translate="true">To</item> + <item name="placeholder" xsi:type="string" translate="true">To</item> + <item name="dateFormat" xsi:type="string" translate="true">MM/dd/YYYY</item> + </item> + </argument> + </filterDate> + </filterRange> + <filterInput name="order_increment_id"> + <argument name="data" xsi:type="array"> + <item name="config" xsi:type="array"> + <item name="dataScope" xsi:type="string">order_increment_id</item> + <item name="label" xsi:type="string" translate="true">Order</item> + </item> + </argument> + </filterInput> + <filterRange name="order_created_at" class="Magento\Ui\Component\Filters\Type\DateRange"> + <argument name="data" xsi:type="array"> + <item name="config" xsi:type="array"> + <item name="dataScope" xsi:type="string">order_created_at</item> + <item name="label" xsi:type="string" translate="true">Order Date</item> + <item name="childDefaults" xsi:type="array"> + <item name="provider" xsi:type="string">sales_order_creditmemo_grid.sales_order_creditmemo_grid.listing_top.listing_filters</item> + </item> + </item> + </argument> + <filterDate name="from"> + <argument name="data" xsi:type="array"> + <item name="config" xsi:type="array"> + <item name="dataScope" xsi:type="string">from</item> + <item name="label" xsi:type="string" translate="true">From</item> + <item name="placeholder" xsi:type="string" translate="true">From</item> + <item name="dateFormat" xsi:type="string" translate="true">MM/dd/YYYY</item> + </item> + </argument> + </filterDate> + <filterDate name="to"> + <argument name="data" xsi:type="array"> + <item name="config" xsi:type="array"> + <item name="dataScope" xsi:type="string">to</item> + <item name="label" xsi:type="string" translate="true">To</item> + <item name="placeholder" xsi:type="string" translate="true">To</item> + <item name="dateFormat" xsi:type="string" translate="true">MM/dd/YYYY</item> + </item> + </argument> + </filterDate> + </filterRange> + <filterInput name="billing_name"> + <argument name="data" xsi:type="array"> + <item name="config" xsi:type="array"> + <item name="dataScope" xsi:type="string">billing_name</item> + <item name="label" xsi:type="string" translate="true">Bill-to Name</item> + </item> + </argument> + </filterInput> + <filterSelect name="state"> + <argument name="optionsProvider" xsi:type="configurableObject"> + <argument name="class" xsi:type="string">Magento\Sales\Ui\Component\Listing\Column\Creditmemo\State\Options</argument> + </argument> + <argument name="data" xsi:type="array"> + <item name="config" xsi:type="array"> + <item name="caption" xsi:type="string" translate="true">Select...</item> + <item name="dataScope" xsi:type="string">state</item> + <item name="label" xsi:type="string" translate="true">Status</item> + </item> + </argument> + </filterSelect> + <filterRange name="base_grand_total"> + <argument name="data" xsi:type="array"> + <item name="config" xsi:type="array"> + <item name="dataScope" xsi:type="string">base_grand_total</item> + <item name="label" xsi:type="string" translate="true">Refunded</item> + <item name="childDefaults" xsi:type="array"> + <item name="provider" xsi:type="string">sales_order_creditmemo_grid.sales_order_creditmemo_grid.listing_top.listing_filters</item> + </item> + </item> + </argument> + <filterInput name="from"> + <argument name="data" xsi:type="array"> + <item name="config" xsi:type="array"> + <item name="dataScope" xsi:type="string">from</item> + <item name="label" xsi:type="string" translate="true">From</item> + <item name="placeholder" xsi:type="string" translate="true">From</item> + </item> + </argument> + </filterInput> + <filterInput name="to"> + <argument name="data" xsi:type="array"> + <item name="config" xsi:type="array"> + <item name="dataScope" xsi:type="string">to</item> + <item name="label" xsi:type="string" translate="true">To</item> + <item name="placeholder" xsi:type="string" translate="true">To</item> + </item> + </argument> + </filterInput> + </filterRange> + <filterSelect name="order_status"> + <argument name="optionsProvider" xsi:type="configurableObject"> + <argument name="class" xsi:type="string">Magento\Sales\Ui\Component\Listing\Column\Status\Options</argument> + </argument> + <argument name="data" xsi:type="array"> + <item name="config" xsi:type="array"> + <item name="caption" xsi:type="string" translate="true">Select...</item> + <item name="dataScope" xsi:type="string">order_status</item> + <item name="label" xsi:type="string" translate="true">Order Status</item> + </item> + </argument> + </filterSelect> + <filterSelect name="store_id"> + <argument name="optionsProvider" xsi:type="configurableObject"> + <argument name="class" xsi:type="string">Magento\Store\Ui\Component\Listing\Column\Store\Options</argument> + </argument> + <argument name="data" xsi:type="array"> + <item name="config" xsi:type="array"> + <item name="caption" xsi:type="string" translate="true">Select...</item> + <item name="dataScope" xsi:type="string">store_id</item> + <item name="label" xsi:type="string" translate="true">Purchased From</item> + </item> + </argument> + </filterSelect> + <filterInput name="billing_address"> + <argument name="data" xsi:type="array"> + <item name="config" xsi:type="array"> + <item name="dataScope" xsi:type="string">billing_address</item> + <item name="label" xsi:type="string" translate="true">Billing Address</item> + </item> + </argument> + </filterInput> + <filterInput name="shipping_address"> + <argument name="data" xsi:type="array"> + <item name="config" xsi:type="array"> + <item name="dataScope" xsi:type="string">shipping_address</item> + <item name="label" xsi:type="string" translate="true">Shipping Address</item> + </item> + </argument> + </filterInput> + <filterInput name="customer_name"> + <argument name="data" xsi:type="array"> + <item name="config" xsi:type="array"> + <item name="dataScope" xsi:type="string">customer_name</item> + <item name="label" xsi:type="string" translate="true">Customer Name</item> + </item> + </argument> + </filterInput> + <filterInput name="customer_email"> + <argument name="data" xsi:type="array"> + <item name="config" xsi:type="array"> + <item name="dataScope" xsi:type="string">customer_email</item> + <item name="label" xsi:type="string" translate="true">Customer Email</item> + </item> + </argument> + </filterInput> + <filterSelect name="customer_group_id"> + <argument name="optionsProvider" xsi:type="configurableObject"> + <argument name="class" xsi:type="string">Magento\Customer\Ui\Component\Listing\Column\Group\Options</argument> + </argument> + <argument name="data" xsi:type="array"> + <item name="config" xsi:type="array"> + <item name="caption" xsi:type="string" translate="true">Select...</item> + <item name="dataScope" xsi:type="string">customer_group_id</item> + <item name="label" xsi:type="string" translate="true">Customer Group</item> + </item> + </argument> + </filterSelect> + <filterSelect name="payment_method"> + <argument name="optionsProvider" xsi:type="configurableObject"> + <argument name="class" xsi:type="string">Magento\Payment\Ui\Component\Listing\Column\Method\Options</argument> + </argument> + <argument name="data" xsi:type="array"> + <item name="config" xsi:type="array"> + <item name="caption" xsi:type="string" translate="true">Select...</item> + <item name="dataScope" xsi:type="string">payment_method</item> + <item name="label" xsi:type="string" translate="true">Payment Method</item> + </item> + </argument> + </filterSelect> + <filterInput name="shipping_information"> + <argument name="data" xsi:type="array"> + <item name="config" xsi:type="array"> + <item name="dataScope" xsi:type="string">shipping_information</item> + <item name="label" xsi:type="string" translate="true">Shipping Information</item> + </item> + </argument> + </filterInput> + <filterRange name="subtotal"> + <argument name="data" xsi:type="array"> + <item name="config" xsi:type="array"> + <item name="dataScope" xsi:type="string">subtotal</item> + <item name="label" xsi:type="string" translate="true">Subtotal</item> + <item name="childDefaults" xsi:type="array"> + <item name="provider" xsi:type="string">sales_order_creditmemo_grid.sales_order_creditmemo_grid.listing_top.listing_filters</item> + </item> + </item> + </argument> + <filterInput name="from"> + <argument name="data" xsi:type="array"> + <item name="config" xsi:type="array"> + <item name="dataScope" xsi:type="string">from</item> + <item name="label" xsi:type="string" translate="true">From</item> + <item name="placeholder" xsi:type="string" translate="true">From</item> + </item> + </argument> + </filterInput> + <filterInput name="to"> + <argument name="data" xsi:type="array"> + <item name="config" xsi:type="array"> + <item name="dataScope" xsi:type="string">to</item> + <item name="label" xsi:type="string" translate="true">To</item> + <item name="placeholder" xsi:type="string" translate="true">To</item> + </item> + </argument> + </filterInput> + </filterRange> + <filterRange name="shipping_and_handling"> + <argument name="data" xsi:type="array"> + <item name="config" xsi:type="array"> + <item name="dataScope" xsi:type="string">shipping_and_handling</item> + <item name="label" xsi:type="string" translate="true">Shipping and Handling</item> + <item name="childDefaults" xsi:type="array"> + <item name="provider" xsi:type="string">sales_order_creditmemo_grid.sales_order_creditmemo_grid.listing_top.listing_filters</item> + </item> + </item> + </argument> + <filterInput name="from"> + <argument name="data" xsi:type="array"> + <item name="config" xsi:type="array"> + <item name="dataScope" xsi:type="string">from</item> + <item name="label" xsi:type="string" translate="true">From</item> + <item name="placeholder" xsi:type="string" translate="true">From</item> + </item> + </argument> + </filterInput> + <filterInput name="to"> + <argument name="data" xsi:type="array"> + <item name="config" xsi:type="array"> + <item name="dataScope" xsi:type="string">to</item> + <item name="label" xsi:type="string" translate="true">To</item> + <item name="placeholder" xsi:type="string" translate="true">To</item> + </item> + </argument> + </filterInput> + </filterRange> + <filterRange name="order_base_grand_total"> + <argument name="data" xsi:type="array"> + <item name="config" xsi:type="array"> + <item name="dataScope" xsi:type="string">order_base_grand_total</item> + <item name="label" xsi:type="string" translate="true">Grand Total</item> + <item name="childDefaults" xsi:type="array"> + <item name="provider" xsi:type="string">sales_order_creditmemo_grid.sales_order_creditmemo_grid.listing_top.listing_filters</item> + </item> + </item> + </argument> + <filterInput name="from"> + <argument name="data" xsi:type="array"> + <item name="config" xsi:type="array"> + <item name="dataScope" xsi:type="string">from</item> + <item name="label" xsi:type="string" translate="true">From</item> + <item name="placeholder" xsi:type="string" translate="true">From</item> + </item> + </argument> + </filterInput> + <filterInput name="to"> + <argument name="data" xsi:type="array"> + <item name="config" xsi:type="array"> + <item name="dataScope" xsi:type="string">to</item> + <item name="label" xsi:type="string" translate="true">To</item> + <item name="placeholder" xsi:type="string" translate="true">To</item> + </item> + </argument> + </filterInput> + </filterRange> + </filters> + <massaction name="listing_massaction"> + <argument name="data" xsi:type="array"> + <item name="config" xsi:type="array"> + <item name="selectProvider" xsi:type="string">sales_order_creditmemo_grid.sales_order_creditmemo_grid.sales_order_creditmemo_columns.ids</item> + <item name="displayArea" xsi:type="string">bottom</item> + <item name="actions" xsi:type="array"> + <item name="pdfcreditmemos_order" xsi:type="array"> + <item name="type" xsi:type="string">pdfcreditmemos_order</item> + <item name="label" xsi:type="string" translate="true">PDF Creditmemos</item> + <item name="url" xsi:type="string">sales/creditmemo/pdfcreditmemos</item> + </item> + </item> + <item name="indexField" xsi:type="string">entity_id</item> + </item> + </argument> + </massaction> + <paging name="listing_paging"> + <argument name="data" xsi:type="array"> + <item name="config" xsi:type="array"> + <item name="storageConfig" xsi:type="array"> + <item name="provider" xsi:type="string">sales_order_creditmemo_grid.sales_order_creditmemo_grid.listing_top.bookmarks</item> + <item name="namespace" xsi:type="string">current.paging</item> + </item> + <item name="selectProvider" xsi:type="string">sales_order_creditmemo_grid.sales_order_creditmemo_grid.sales_order_creditmemo_columns.ids</item> + <item name="displayArea" xsi:type="string">bottom</item> + <item name="options" xsi:type="array"> + <item name="20" xsi:type="array"> + <item name="value" xsi:type="number">20</item> + <item name="label" xsi:type="string" translate="true">20</item> + </item> + <item name="30" xsi:type="array"> + <item name="value" xsi:type="number">30</item> + <item name="label" xsi:type="string" translate="true">30</item> + </item> + <item name="50" xsi:type="array"> + <item name="value" xsi:type="number">50</item> + <item name="label" xsi:type="string" translate="true">50</item> + </item> + <item name="100" xsi:type="array"> + <item name="value" xsi:type="number">100</item> + <item name="label" xsi:type="string" translate="true">100</item> + </item> + <item name="200" xsi:type="array"> + <item name="value" xsi:type="number">200</item> + <item name="label" xsi:type="string" translate="true">200</item> + </item> + </item> + </item> + </argument> + </paging> + </container> + <columns name="sales_order_creditmemo_columns"> + <argument name="data" xsi:type="array"> + <item name="config" xsi:type="array"> + <item name="storageConfig" xsi:type="array"> + <item name="provider" xsi:type="string">sales_order_creditmemo_grid.sales_order_creditmemo_grid.listing_top.bookmarks</item> + <item name="namespace" xsi:type="string">current</item> + </item> + <item name="childDefaults" xsi:type="array"> + <item name="controlVisibility" xsi:type="boolean">true</item> + <item name="actionField" xsi:type="string">actions</item> + <item name="clickAction" xsi:type="string">view</item> + <item name="storageConfig" xsi:type="array"> + <item name="provider" xsi:type="string">sales_order_creditmemo_grid.sales_order_creditmemo_grid.listing_top.bookmarks</item> + <item name="root" xsi:type="string">columns.${ $.index }</item> + <item name="namespace" xsi:type="string">current.${ $.storageConfig.root}</item> + </item> + </item> + </item> + </argument> + <column name="ids" class="Magento\Ui\Component\MassAction\Columns\Column"> + <argument name="data" xsi:type="array"> + <item name="js_config" xsi:type="array"> + <item name="component" xsi:type="string">Magento_Ui/js/grid/columns/multiselect</item> + </item> + <item name="config" xsi:type="array"> + <item name="draggable" xsi:type="boolean">false</item> + <item name="indexField" xsi:type="string">entity_id</item> + <item name="controlVisibility" xsi:type="boolean">false</item> + </item> + </argument> + </column> + <column name="increment_id"> + <argument name="data" xsi:type="array"> + <item name="js_config" xsi:type="array"> + <item name="component" xsi:type="string">Magento_Ui/js/grid/columns/column</item> + </item> + <item name="config" xsi:type="array"> + <item name="dataType" xsi:type="string">text</item> + <item name="align" xsi:type="string">left</item> + <item name="label" xsi:type="string" translate="true">Credit Memo</item> + </item> + </argument> + </column> + <column name="created_at"> + <argument name="data" xsi:type="array"> + <item name="js_config" xsi:type="array"> + <item name="component" xsi:type="string">Magento_Ui/js/grid/columns/date</item> + </item> + <item name="config" xsi:type="array"> + <item name="dataType" xsi:type="string">date</item> + <item name="align" xsi:type="string">left</item> + <item name="label" xsi:type="string" translate="true">Created</item> + </item> + </argument> + </column> + <column name="order_increment_id"> + <argument name="data" xsi:type="array"> + <item name="js_config" xsi:type="array"> + <item name="component" xsi:type="string">Magento_Ui/js/grid/columns/column</item> + </item> + <item name="config" xsi:type="array"> + <item name="dataType" xsi:type="string">text</item> + <item name="align" xsi:type="string">left</item> + <item name="label" xsi:type="string" translate="true">Order</item> + </item> + </argument> + </column> + <column name="order_created_at"> + <argument name="data" xsi:type="array"> + <item name="js_config" xsi:type="array"> + <item name="component" xsi:type="string">Magento_Ui/js/grid/columns/date</item> + </item> + <item name="config" xsi:type="array"> + <item name="dataType" xsi:type="string">date</item> + <item name="align" xsi:type="string">left</item> + <item name="label" xsi:type="string" translate="true">Order Date</item> + </item> + </argument> + </column> + <column name="billing_name"> + <argument name="data" xsi:type="array"> + <item name="js_config" xsi:type="array"> + <item name="component" xsi:type="string">Magento_Ui/js/grid/columns/column</item> + </item> + <item name="config" xsi:type="array"> + <item name="dataType" xsi:type="string">text</item> + <item name="align" xsi:type="string">left</item> + <item name="label" xsi:type="string" translate="true">Bill-to Name</item> + </item> + </argument> + </column> + <column name="state" class="Magento\Sales\Ui\Component\Listing\Column\Creditmemo\State"> + <argument name="data" xsi:type="array"> + <item name="js_config" xsi:type="array"> + <item name="component" xsi:type="string">Magento_Ui/js/grid/columns/select</item> + </item> + <item name="config" xsi:type="array"> + <item name="dataType" xsi:type="string">text</item> + <item name="align" xsi:type="string">left</item> + <item name="label" xsi:type="string" translate="true">Status</item> + </item> + </argument> + </column> + <column name="base_grand_total" class="Magento\Sales\Ui\Component\Listing\Column\Price"> + <argument name="data" xsi:type="array"> + <item name="js_config" xsi:type="array"> + <item name="component" xsi:type="string">Magento_Ui/js/grid/columns/column</item> + </item> + <item name="config" xsi:type="array"> + <item name="dataType" xsi:type="string">text</item> + <item name="align" xsi:type="string">left</item> + <item name="label" xsi:type="string" translate="true">Refunded</item> + </item> + </argument> + </column> + <column name="order_status" class="Magento\Sales\Ui\Component\Listing\Column\Status"> + <argument name="data" xsi:type="array"> + <item name="js_config" xsi:type="array"> + <item name="component" xsi:type="string">Magento_Ui/js/grid/columns/select</item> + </item> + <item name="config" xsi:type="array"> + <item name="visible" xsi:type="boolean">false</item> + <item name="dataType" xsi:type="string">text</item> + <item name="align" xsi:type="string">left</item> + <item name="label" xsi:type="string" translate="true">Order Status</item> + </item> + </argument> + </column> + <column name="store_id" class="Magento\Store\Ui\Component\Listing\Column\Store"> + <argument name="data" xsi:type="array"> + <item name="js_config" xsi:type="array"> + <item name="component" xsi:type="string">Magento_Ui/js/grid/columns/column</item> + </item> + <item name="config" xsi:type="array"> + <item name="bodyTmpl" xsi:type="string">ui/grid/cells/html</item> + <item name="visible" xsi:type="boolean">false</item> + <item name="sortable" xsi:type="boolean">false</item> + <item name="dataType" xsi:type="string">text</item> + <item name="align" xsi:type="string">left</item> + <item name="label" xsi:type="string" translate="true">Purchased From</item> + </item> + </argument> + </column> + <column name="billing_address" class="Magento\Sales\Ui\Component\Listing\Column\Address"> + <argument name="data" xsi:type="array"> + <item name="js_config" xsi:type="array"> + <item name="component" xsi:type="string">Magento_Ui/js/grid/columns/column</item> + </item> + <item name="config" xsi:type="array"> + <item name="bodyTmpl" xsi:type="string">ui/grid/cells/html</item> + <item name="visible" xsi:type="boolean">false</item> + <item name="dataType" xsi:type="string">text</item> + <item name="align" xsi:type="string">left</item> + <item name="label" xsi:type="string" translate="true">Billing Address</item> + </item> + </argument> + </column> + <column name="shipping_address" class="Magento\Sales\Ui\Component\Listing\Column\Address"> + <argument name="data" xsi:type="array"> + <item name="js_config" xsi:type="array"> + <item name="component" xsi:type="string">Magento_Ui/js/grid/columns/column</item> + </item> + <item name="config" xsi:type="array"> + <item name="bodyTmpl" xsi:type="string">ui/grid/cells/html</item> + <item name="visible" xsi:type="boolean">false</item> + <item name="dataType" xsi:type="string">text</item> + <item name="align" xsi:type="string">left</item> + <item name="label" xsi:type="string" translate="true">Shipping Address</item> + </item> + </argument> + </column> + <column name="customer_name"> + <argument name="data" xsi:type="array"> + <item name="js_config" xsi:type="array"> + <item name="component" xsi:type="string">Magento_Ui/js/grid/columns/column</item> + </item> + <item name="config" xsi:type="array"> + <item name="visible" xsi:type="boolean">false</item> + <item name="dataType" xsi:type="string">text</item> + <item name="align" xsi:type="string">left</item> + <item name="label" xsi:type="string" translate="true">Customer Name</item> + </item> + </argument> + </column> + <column name="customer_email"> + <argument name="data" xsi:type="array"> + <item name="js_config" xsi:type="array"> + <item name="component" xsi:type="string">Magento_Ui/js/grid/columns/column</item> + </item> + <item name="config" xsi:type="array"> + <item name="visible" xsi:type="boolean">false</item> + <item name="dataType" xsi:type="string">text</item> + <item name="align" xsi:type="string">left</item> + <item name="label" xsi:type="string" translate="true">Email</item> + </item> + </argument> + </column> + <column name="customer_group_id" class="Magento\Sales\Ui\Component\Listing\Column\CustomerGroup"> + <argument name="data" xsi:type="array"> + <item name="js_config" xsi:type="array"> + <item name="component" xsi:type="string">Magento_Ui/js/grid/columns/column</item> + </item> + <item name="config" xsi:type="array"> + <item name="visible" xsi:type="boolean">false</item> + <item name="dataType" xsi:type="string">text</item> + <item name="align" xsi:type="string">left</item> + <item name="label" xsi:type="string" translate="true">Customer Group</item> + </item> + </argument> + </column> + <column name="payment_method" class="Magento\Sales\Ui\Component\Listing\Column\PaymentMethod"> + <argument name="data" xsi:type="array"> + <item name="js_config" xsi:type="array"> + <item name="component" xsi:type="string">Magento_Ui/js/grid/columns/column</item> + </item> + <item name="config" xsi:type="array"> + <item name="visible" xsi:type="boolean">false</item> + <item name="dataType" xsi:type="string">text</item> + <item name="align" xsi:type="string">left</item> + <item name="label" xsi:type="string" translate="true">Payment Method</item> + </item> + </argument> + </column> + <column name="shipping_information"> + <argument name="data" xsi:type="array"> + <item name="js_config" xsi:type="array"> + <item name="component" xsi:type="string">Magento_Ui/js/grid/columns/column</item> + </item> + <item name="config" xsi:type="array"> + <item name="visible" xsi:type="boolean">false</item> + <item name="dataType" xsi:type="string">text</item> + <item name="align" xsi:type="string">left</item> + <item name="label" xsi:type="string" translate="true">Shipping Information</item> + </item> + </argument> + </column> + <column name="subtotal" class="Magento\Sales\Ui\Component\Listing\Column\Price"> + <argument name="data" xsi:type="array"> + <item name="js_config" xsi:type="array"> + <item name="component" xsi:type="string">Magento_Ui/js/grid/columns/column</item> + </item> + <item name="config" xsi:type="array"> + <item name="visible" xsi:type="boolean">false</item> + <item name="dataType" xsi:type="string">text</item> + <item name="align" xsi:type="string">left</item> + <item name="label" xsi:type="string" translate="true">Subtotal</item> + </item> + </argument> + </column> + <column name="shipping_and_handling" class="Magento\Sales\Ui\Component\Listing\Column\Price"> + <argument name="data" xsi:type="array"> + <item name="js_config" xsi:type="array"> + <item name="component" xsi:type="string">Magento_Ui/js/grid/columns/column</item> + </item> + <item name="config" xsi:type="array"> + <item name="visible" xsi:type="boolean">false</item> + <item name="dataType" xsi:type="string">text</item> + <item name="align" xsi:type="string">left</item> + <item name="label" xsi:type="string" translate="true">Shipping & Handling</item> + </item> + </argument> + </column> + <column name="adjustment_positive" class="Magento\Sales\Ui\Component\Listing\Column\Price"> + <argument name="data" xsi:type="array"> + <item name="js_config" xsi:type="array"> + <item name="component" xsi:type="string">Magento_Ui/js/grid/columns/column</item> + </item> + <item name="config" xsi:type="array"> + <item name="visible" xsi:type="boolean">false</item> + <item name="dataType" xsi:type="string">text</item> + <item name="align" xsi:type="string">left</item> + <item name="label" xsi:type="string" translate="true">Adjustment Refund</item> + </item> + </argument> + </column> + <column name="adjustment_negative" class="Magento\Sales\Ui\Component\Listing\Column\Price"> + <argument name="data" xsi:type="array"> + <item name="js_config" xsi:type="array"> + <item name="component" xsi:type="string">Magento_Ui/js/grid/columns/column</item> + </item> + <item name="config" xsi:type="array"> + <item name="visible" xsi:type="boolean">false</item> + <item name="dataType" xsi:type="string">text</item> + <item name="align" xsi:type="string">left</item> + <item name="label" xsi:type="string" translate="true">Adjustment Fee</item> + </item> + </argument> + </column> + <column name="order_base_grand_total" class="Magento\Sales\Ui\Component\Listing\Column\Price"> + <argument name="data" xsi:type="array"> + <item name="js_config" xsi:type="array"> + <item name="component" xsi:type="string">Magento_Ui/js/grid/columns/column</item> + </item> + <item name="config" xsi:type="array"> + <item name="visible" xsi:type="boolean">false</item> + <item name="dataType" xsi:type="string">text</item> + <item name="align" xsi:type="string">left</item> + <item name="label" xsi:type="string" translate="true">Grand Total</item> + </item> + </argument> + </column> + <column name="actions" class="Magento\Sales\Ui\Component\Listing\Column\OrderCreditmemoActions"> + <argument name="data" xsi:type="array"> + <item name="config" xsi:type="array"> + <item name="draggable" xsi:type="boolean">false</item> + <item name="dataType" xsi:type="string">actions</item> + <item name="indexField" xsi:type="string">entity_id</item> + <item name="align" xsi:type="string">left</item> + <item name="label" xsi:type="string" translate="true">Action</item> + <item name="data_type" xsi:type="string">actions</item> + <item name="filterable" xsi:type="boolean">false</item> + <item name="sortable" xsi:type="boolean">false</item> + </item> + </argument> + </column> + </columns> +</listing> diff --git a/app/code/Magento/Sales/view/adminhtml/ui_component/sales_order_grid.xml b/app/code/Magento/Sales/view/adminhtml/ui_component/sales_order_grid.xml new file mode 100644 index 0000000000000000000000000000000000000000..788f556036cfb0fcef36af34ec35e5019f3cd741 --- /dev/null +++ b/app/code/Magento/Sales/view/adminhtml/ui_component/sales_order_grid.xml @@ -0,0 +1,621 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!-- +/** + * Copyright © 2015 Magento. All rights reserved. + * See COPYING.txt for license details. + */ +--> +<listing xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../../../../Ui/etc/ui_configuration.xsd"> + <argument name="data" xsi:type="array"> + <item name="js_config" xsi:type="array"> + <item name="provider" xsi:type="string">sales_order_grid.sales_order_grid_data_source</item> + <item name="deps" xsi:type="string">sales_order_grid.sales_order_grid_data_source</item> + </item> + <item name="spinner" xsi:type="string">sales_order_columns</item> + <item name="buttons" xsi:type="array"> + <item name="add" xsi:type="array"> + <item name="name" xsi:type="string">add</item> + <item name="label" xsi:type="string" translate="true">Create New Order</item> + <item name="class" xsi:type="string">primary</item> + <item name="url" xsi:type="string">sales/order_create/start</item> + </item> + </item> + </argument> + <dataSource name="sales_order_grid_data_source"> + <argument name="dataProvider" xsi:type="configurableObject"> + <argument name="class" xsi:type="string">OrderGridDataProvider</argument> + <argument name="name" xsi:type="string">sales_order_grid_data_source</argument> + <argument name="primaryFieldName" xsi:type="string">increment_id</argument> + <argument name="requestFieldName" xsi:type="string">id</argument> + <argument name="data" xsi:type="array"> + <item name="config" xsi:type="array"> + <item name="update_url" xsi:type="url" path="mui/index/render"/> + </item> + </argument> + </argument> + <argument name="data" xsi:type="array"> + <item name="js_config" xsi:type="array"> + <item name="component" xsi:type="string">Magento_Ui/js/grid/provider</item> + </item> + </argument> + </dataSource> + <container name="listing_top"> + <argument name="data" xsi:type="array"> + <item name="config" xsi:type="array"> + <item name="template" xsi:type="string">ui/grid/toolbar</item> + </item> + </argument> + <bookmark name="bookmarks"> + <argument name="data" xsi:type="array"> + <item name="config" xsi:type="array"> + <item name="component" xsi:type="string">Magento_Ui/js/grid/controls/bookmarks/bookmarks</item> + <item name="displayArea" xsi:type="string">dataGridActions</item> + <item name="storageConfig" xsi:type="array"> + <item name="saveUrl" xsi:type="url" path="mui/bookmark/save"/> + <item name="deleteUrl" xsi:type="url" path="mui/bookmark/delete"/> + <item name="namespace" xsi:type="string">sales_order_grid</item> + </item> + </item> + </argument> + </bookmark> + <container name="columns_controls"> + <argument name="data" xsi:type="array"> + <item name="config" xsi:type="array"> + <item name="columnsData" xsi:type="array"> + <item name="provider" xsi:type="string">sales_order_grid.sales_order_grid.sales_order_columns</item> + </item> + <item name="component" xsi:type="string">Magento_Ui/js/grid/controls/columns</item> + <item name="displayArea" xsi:type="string">dataGridActions</item> + </item> + </argument> + </container> + <exportButton name="export_button"> + <argument name="data" xsi:type="array"> + <item name="config" xsi:type="array"> + <item name="displayArea" xsi:type="string">dataGridActions</item> + <item name="options" xsi:type="array"> + <item name="cvs" xsi:type="array"> + <item name="value" xsi:type="string">csv</item> + <item name="label" xsi:type="string" translate="true">CSV</item> + <item name="url" xsi:type="string">sales/order/exportCsv</item> + </item> + <item name="xml" xsi:type="array"> + <item name="value" xsi:type="string">xml</item> + <item name="label" xsi:type="string" translate="true">Excel XML</item> + <item name="url" xsi:type="string">sales/order/exportExcel</item> + </item> + </item> + </item> + </argument> + </exportButton> + <filterSearch name="fulltext"> + <argument name="data" xsi:type="array"> + <item name="config" xsi:type="array"> + <item name="provider" xsi:type="string">sales_order_grid.sales_order_grid_data_source</item> + <item name="chipsProvider" xsi:type="string">sales_order_grid.sales_order_grid.listing_top.listing_filters_chips</item> + <item name="storageConfig" xsi:type="array"> + <item name="provider" xsi:type="string">sales_order_grid.sales_order_grid.listing_top.bookmarks</item> + <item name="namespace" xsi:type="string">current.search</item> + </item> + </item> + </argument> + </filterSearch> + <filters name="listing_filters"> + <argument name="data" xsi:type="array"> + <item name="config" xsi:type="array"> + <item name="displayArea" xsi:type="string">dataGridFilters</item> + <item name="dataScope" xsi:type="string">filters</item> + <item name="storageConfig" xsi:type="array"> + <item name="provider" xsi:type="string">sales_order_grid.sales_order_grid.listing_top.bookmarks</item> + <item name="namespace" xsi:type="string">current.filters</item> + </item> + <item name="childDefaults" xsi:type="array"> + <item name="provider" xsi:type="string">sales_order_grid.sales_order_grid.listing_top.listing_filters</item> + <item name="imports" xsi:type="array"> + <item name="visible" xsi:type="string">sales_order_grid.sales_order_grid.listing_top.bookmarks:current.columns.${ $.index }.visible</item> + </item> + </item> + </item> + </argument> + <filterInput name="increment_id"> + <argument name="data" xsi:type="array"> + <item name="config" xsi:type="array"> + <item name="dataScope" xsi:type="string">increment_id</item> + <item name="label" xsi:type="string" translate="true">ID</item> + </item> + </argument> + </filterInput> + <filterSelect name="store_id"> + <argument name="optionsProvider" xsi:type="configurableObject"> + <argument name="class" xsi:type="string">Magento\Store\Ui\Component\Listing\Column\Store\Options</argument> + </argument> + <argument name="data" xsi:type="array"> + <item name="config" xsi:type="array"> + <item name="caption" xsi:type="string" translate="true">Select...</item> + <item name="dataScope" xsi:type="string">store_id</item> + <item name="label" xsi:type="string" translate="true">Purchase Point</item> + </item> + </argument> + </filterSelect> + <filterRange name="created_at" class="Magento\Ui\Component\Filters\Type\DateRange"> + <argument name="data" xsi:type="array"> + <item name="config" xsi:type="array"> + <item name="dataScope" xsi:type="string">created_at</item> + <item name="label" xsi:type="string" translate="true">Purchase Date</item> + <item name="childDefaults" xsi:type="array"> + <item name="provider" xsi:type="string">cms_block_listing.cms_block_listing.listing_top.listing_filters</item> + </item> + </item> + </argument> + <filterDate name="from"> + <argument name="data" xsi:type="array"> + <item name="config" xsi:type="array"> + <item name="dataScope" xsi:type="string">from</item> + <item name="label" xsi:type="string" translate="true">From</item> + <item name="placeholder" xsi:type="string" translate="true">From</item> + <item name="dateFormat" xsi:type="string" translate="true">MM/dd/YYYY</item> + </item> + </argument> + </filterDate> + <filterDate name="to"> + <argument name="data" xsi:type="array"> + <item name="config" xsi:type="array"> + <item name="dataScope" xsi:type="string">to</item> + <item name="label" xsi:type="string" translate="true">To</item> + <item name="placeholder" xsi:type="string" translate="true">To</item> + <item name="dateFormat" xsi:type="string" translate="true">MM/dd/YYYY</item> + </item> + </argument> + </filterDate> + </filterRange> + <filterInput name="billing_name"> + <argument name="data" xsi:type="array"> + <item name="config" xsi:type="array"> + <item name="dataScope" xsi:type="string">billing_name</item> + <item name="label" xsi:type="string" translate="true">Bill-to Name</item> + </item> + </argument> + </filterInput> + <filterInput name="shipping_name"> + <argument name="data" xsi:type="array"> + <item name="config" xsi:type="array"> + <item name="dataScope" xsi:type="string">shipping_name</item> + <item name="label" xsi:type="string" translate="true">Ship-to Name</item> + </item> + </argument> + </filterInput> + <filterRange name="base_grand_total"> + <argument name="data" xsi:type="array"> + <item name="config" xsi:type="array"> + <item name="dataScope" xsi:type="string">base_grand_total</item> + <item name="label" xsi:type="string" translate="true">Grand Total (Base)</item> + <item name="childDefaults" xsi:type="array"> + <item name="provider" xsi:type="string">sales_order_grid.sales_order_grid.listing_top.listing_filters</item> + </item> + </item> + </argument> + <filterInput name="from"> + <argument name="data" xsi:type="array"> + <item name="config" xsi:type="array"> + <item name="dataScope" xsi:type="string">from</item> + <item name="label" xsi:type="string" translate="true">From</item> + <item name="placeholder" xsi:type="string" translate="true">From</item> + </item> + </argument> + </filterInput> + <filterInput name="to"> + <argument name="data" xsi:type="array"> + <item name="config" xsi:type="array"> + <item name="dataScope" xsi:type="string">to</item> + <item name="label" xsi:type="string" translate="true">To</item> + <item name="placeholder" xsi:type="string" translate="true">To</item> + </item> + </argument> + </filterInput> + </filterRange> + <filterRange name="grand_total"> + <argument name="data" xsi:type="array"> + <item name="config" xsi:type="array"> + <item name="dataScope" xsi:type="string">grand_total</item> + <item name="label" xsi:type="string" translate="true">Grand Total (Purchased)</item> + <item name="childDefaults" xsi:type="array"> + <item name="provider" xsi:type="string">sales_order_grid.sales_order_grid.listing_top.listing_filters</item> + </item> + </item> + </argument> + <filterInput name="from"> + <argument name="data" xsi:type="array"> + <item name="config" xsi:type="array"> + <item name="dataScope" xsi:type="string">from</item> + <item name="label" xsi:type="string" translate="true">From</item> + <item name="placeholder" xsi:type="string" translate="true">From</item> + </item> + </argument> + </filterInput> + <filterInput name="to"> + <argument name="data" xsi:type="array"> + <item name="config" xsi:type="array"> + <item name="dataScope" xsi:type="string">to</item> + <item name="label" xsi:type="string" translate="true">To</item> + <item name="placeholder" xsi:type="string" translate="true">To</item> + </item> + </argument> + </filterInput> + </filterRange> + <filterSelect name="status"> + <argument name="optionsProvider" xsi:type="configurableObject"> + <argument name="class" xsi:type="string">Magento\Sales\Ui\Component\Listing\Column\Status\Options</argument> + </argument> + <argument name="data" xsi:type="array"> + <item name="config" xsi:type="array"> + <item name="caption" xsi:type="string" translate="true">Select...</item> + <item name="dataScope" xsi:type="string">status</item> + <item name="label" xsi:type="string" translate="true">Status</item> + </item> + </argument> + </filterSelect> + </filters> + <massaction name="listing_massaction"> + <argument name="data" xsi:type="array"> + <item name="config" xsi:type="array"> + <item name="selectProvider" xsi:type="string">sales_order_grid.sales_order_grid.sales_order_columns.ids</item> + <item name="displayArea" xsi:type="string">bottom</item> + <item name="actions" xsi:type="array"> + <item name="cancel" xsi:type="array"> + <item name="type" xsi:type="string">cancel</item> + <item name="label" xsi:type="string" translate="true">Cancel</item> + <item name="url" xsi:type="string">sales/order/massCancel</item> + </item> + <item name="hold_order" xsi:type="array"> + <item name="type" xsi:type="string">hold_order</item> + <item name="label" xsi:type="string" translate="true">Hold</item> + <item name="url" xsi:type="string">sales/order/massHold</item> + </item> + <item name="unhold_order" xsi:type="array"> + <item name="type" xsi:type="string">unhold_order</item> + <item name="label" xsi:type="string" translate="true">Unhold</item> + <item name="url" xsi:type="string">sales/order/massUnhold</item> + </item> + <item name="pdfinvoices_order" xsi:type="array"> + <item name="type" xsi:type="string">pdfinvoices_order</item> + <item name="label" xsi:type="string" translate="true">Print Invoices</item> + <item name="url" xsi:type="string">sales/order/pdfinvoices</item> + </item> + <item name="pdfshipments_order" xsi:type="array"> + <item name="type" xsi:type="string">pdfshipments_order</item> + <item name="label" xsi:type="string" translate="true">Print Packing Slips</item> + <item name="url" xsi:type="string">sales/order/pdfshipments</item> + </item> + <item name="pdfcreditmemos_order" xsi:type="array"> + <item name="type" xsi:type="string">pdfcreditmemos_order</item> + <item name="label" xsi:type="string" translate="true">Print Credit Memos</item> + <item name="url" xsi:type="string">sales/order/pdfcreditmemos</item> + </item> + <item name="pdfdocs_order" xsi:type="array"> + <item name="type" xsi:type="string">pdfdocs_order</item> + <item name="label" xsi:type="string" translate="true">Print All</item> + <item name="url" xsi:type="string">sales/order/pdfdocs</item> + </item> + <item name="print_shipping_label" xsi:type="array"> + <item name="type" xsi:type="string">print_shipping_label</item> + <item name="label" xsi:type="string" translate="true">Print Shipping Labels</item> + <item name="url" xsi:type="string">adminhtml/order_shipment/massPrintShippingLabel</item> + </item> + </item> + <item name="indexField" xsi:type="string">entity_id</item> + </item> + </argument> + </massaction> + <paging name="listing_paging"> + <argument name="data" xsi:type="array"> + <item name="config" xsi:type="array"> + <item name="storageConfig" xsi:type="array"> + <item name="provider" xsi:type="string">sales_order_grid.sales_order_grid.listing_top.bookmarks</item> + <item name="namespace" xsi:type="string">current.paging</item> + </item> + <item name="selectProvider" xsi:type="string">sales_order_grid.sales_order_grid.sales_order_columns.ids</item> + <item name="displayArea" xsi:type="string">bottom</item> + <item name="options" xsi:type="array"> + <item name="20" xsi:type="array"> + <item name="value" xsi:type="number">20</item> + <item name="label" xsi:type="string" translate="true">20</item> + </item> + <item name="30" xsi:type="array"> + <item name="value" xsi:type="number">30</item> + <item name="label" xsi:type="string" translate="true">30</item> + </item> + <item name="50" xsi:type="array"> + <item name="value" xsi:type="number">50</item> + <item name="label" xsi:type="string" translate="true">50</item> + </item> + <item name="100" xsi:type="array"> + <item name="value" xsi:type="number">100</item> + <item name="label" xsi:type="string" translate="true">100</item> + </item> + <item name="200" xsi:type="array"> + <item name="value" xsi:type="number">200</item> + <item name="label" xsi:type="string" translate="true">200</item> + </item> + </item> + </item> + </argument> + </paging> + </container> + <columns name="sales_order_columns"> + <argument name="data" xsi:type="array"> + <item name="config" xsi:type="array"> + <item name="storageConfig" xsi:type="array"> + <item name="provider" xsi:type="string">sales_order_grid.sales_order_grid.listing_top.bookmarks</item> + <item name="namespace" xsi:type="string">current</item> + </item> + <item name="childDefaults" xsi:type="array"> + <item name="controlVisibility" xsi:type="boolean">true</item> + <item name="actionField" xsi:type="string">actions</item> + <item name="clickAction" xsi:type="string">view</item> + <item name="storageConfig" xsi:type="array"> + <item name="provider" xsi:type="string">sales_order_grid.sales_order_grid.listing_top.bookmarks</item> + <item name="root" xsi:type="string">columns.${ $.index }</item> + <item name="namespace" xsi:type="string">current.${ $.storageConfig.root}</item> + </item> + </item> + </item> + </argument> + <column name="ids" class="Magento\Ui\Component\MassAction\Columns\Column"> + <argument name="data" xsi:type="array"> + <item name="js_config" xsi:type="array"> + <item name="component" xsi:type="string">Magento_Ui/js/grid/columns/multiselect</item> + </item> + <item name="config" xsi:type="array"> + <item name="draggable" xsi:type="boolean">false</item> + <item name="indexField" xsi:type="string">entity_id</item> + <item name="controlVisibility" xsi:type="boolean">false</item> + </item> + </argument> + </column> + <column name="increment_id"> + <argument name="data" xsi:type="array"> + <item name="js_config" xsi:type="array"> + <item name="component" xsi:type="string">Magento_Ui/js/grid/columns/column</item> + </item> + <item name="config" xsi:type="array"> + <item name="dataType" xsi:type="string">text</item> + <item name="sorting" xsi:type="string">asc</item> + <item name="align" xsi:type="string">left</item> + <item name="label" xsi:type="string" translate="true">ID</item> + </item> + </argument> + </column> + <column name="store_id" class="Magento\Store\Ui\Component\Listing\Column\Store"> + <argument name="data" xsi:type="array"> + <item name="js_config" xsi:type="array"> + <item name="component" xsi:type="string">Magento_Ui/js/grid/columns/column</item> + </item> + <item name="config" xsi:type="array"> + <item name="bodyTmpl" xsi:type="string">ui/grid/cells/html</item> + <item name="sortable" xsi:type="boolean">false</item> + <item name="dataType" xsi:type="string">text</item> + <item name="align" xsi:type="string">left</item> + <item name="label" xsi:type="string" translate="true">Purchase Point</item> + </item> + </argument> + </column> + <column name="created_at"> + <argument name="data" xsi:type="array"> + <item name="js_config" xsi:type="array"> + <item name="component" xsi:type="string">Magento_Ui/js/grid/columns/date</item> + </item> + <item name="config" xsi:type="array"> + <item name="dataType" xsi:type="string">date</item> + <item name="align" xsi:type="string">left</item> + <item name="label" xsi:type="string" translate="true">Purchase Date</item> + </item> + </argument> + </column> + <column name="billing_name"> + <argument name="data" xsi:type="array"> + <item name="js_config" xsi:type="array"> + <item name="component" xsi:type="string">Magento_Ui/js/grid/columns/column</item> + </item> + <item name="config" xsi:type="array"> + <item name="dataType" xsi:type="string">text</item> + <item name="align" xsi:type="string">left</item> + <item name="label" xsi:type="string" translate="true">Bill-to Name</item> + </item> + </argument> + </column> + <column name="shipping_name"> + <argument name="data" xsi:type="array"> + <item name="js_config" xsi:type="array"> + <item name="component" xsi:type="string">Magento_Ui/js/grid/columns/column</item> + </item> + <item name="config" xsi:type="array"> + <item name="dataType" xsi:type="string">text</item> + <item name="align" xsi:type="string">left</item> + <item name="label" xsi:type="string" translate="true">Ship-to Name</item> + </item> + </argument> + </column> + <column name="base_grand_total" class="Magento\Sales\Ui\Component\Listing\Column\Price"> + <argument name="data" xsi:type="array"> + <item name="js_config" xsi:type="array"> + <item name="component" xsi:type="string">Magento_Ui/js/grid/columns/column</item> + </item> + <item name="config" xsi:type="array"> + <item name="dataType" xsi:type="string">text</item> + <item name="align" xsi:type="string">left</item> + <item name="label" xsi:type="string" translate="true">Grand Total (Base)</item> + </item> + </argument> + </column> + <column name="grand_total" class="Magento\Sales\Ui\Component\Listing\Column\Price"> + <argument name="data" xsi:type="array"> + <item name="js_config" xsi:type="array"> + <item name="component" xsi:type="string">Magento_Ui/js/grid/columns/column</item> + </item> + <item name="config" xsi:type="array"> + <item name="dataType" xsi:type="string">text</item> + <item name="align" xsi:type="string">left</item> + <item name="label" xsi:type="string" translate="true">Grand Total (Purchased)</item> + </item> + </argument> + </column> + <column name="status" class="Magento\Sales\Ui\Component\Listing\Column\Status"> + <argument name="data" xsi:type="array"> + <item name="js_config" xsi:type="array"> + <item name="component" xsi:type="string">Magento_Ui/js/grid/columns/select</item> + </item> + <item name="config" xsi:type="array"> + <item name="dataType" xsi:type="string">text</item> + <item name="align" xsi:type="string">left</item> + <item name="label" xsi:type="string" translate="true">Status</item> + </item> + </argument> + </column> + <column name="billing_address" class="Magento\Sales\Ui\Component\Listing\Column\Address"> + <argument name="data" xsi:type="array"> + <item name="js_config" xsi:type="array"> + <item name="component" xsi:type="string">Magento_Ui/js/grid/columns/column</item> + </item> + <item name="config" xsi:type="array"> + <item name="bodyTmpl" xsi:type="string">ui/grid/cells/html</item> + <item name="visible" xsi:type="boolean">false</item> + <item name="dataType" xsi:type="string">text</item> + <item name="align" xsi:type="string">left</item> + <item name="label" xsi:type="string" translate="true">Billing Address</item> + </item> + </argument> + </column> + <column name="shipping_address" class="Magento\Sales\Ui\Component\Listing\Column\Address"> + <argument name="data" xsi:type="array"> + <item name="js_config" xsi:type="array"> + <item name="component" xsi:type="string">Magento_Ui/js/grid/columns/column</item> + </item> + <item name="config" xsi:type="array"> + <item name="bodyTmpl" xsi:type="string">ui/grid/cells/html</item> + <item name="visible" xsi:type="boolean">false</item> + <item name="dataType" xsi:type="string">text</item> + <item name="align" xsi:type="string">left</item> + <item name="label" xsi:type="string" translate="true">Shipping Address</item> + </item> + </argument> + </column> + <column name="shipping_information"> + <argument name="data" xsi:type="array"> + <item name="js_config" xsi:type="array"> + <item name="component" xsi:type="string">Magento_Ui/js/grid/columns/column</item> + </item> + <item name="config" xsi:type="array"> + <item name="visible" xsi:type="boolean">false</item> + <item name="dataType" xsi:type="string">text</item> + <item name="align" xsi:type="string">left</item> + <item name="label" xsi:type="string" translate="true">Shipping Information</item> + </item> + </argument> + </column> + <column name="customer_email"> + <argument name="data" xsi:type="array"> + <item name="js_config" xsi:type="array"> + <item name="component" xsi:type="string">Magento_Ui/js/grid/columns/column</item> + </item> + <item name="config" xsi:type="array"> + <item name="visible" xsi:type="boolean">false</item> + <item name="dataType" xsi:type="string">text</item> + <item name="align" xsi:type="string">left</item> + <item name="label" xsi:type="string" translate="true">Customer Email</item> + </item> + </argument> + </column> + <column name="customer_group" class="Magento\Sales\Ui\Component\Listing\Column\CustomerGroup"> + <argument name="data" xsi:type="array"> + <item name="js_config" xsi:type="array"> + <item name="component" xsi:type="string">Magento_Ui/js/grid/columns/column</item> + </item> + <item name="config" xsi:type="array"> + <item name="visible" xsi:type="boolean">false</item> + <item name="dataType" xsi:type="string">text</item> + <item name="align" xsi:type="string">left</item> + <item name="label" xsi:type="string" translate="true">Customer Group</item> + </item> + </argument> + </column> + <column name="subtotal" class="Magento\Sales\Ui\Component\Listing\Column\Price"> + <argument name="data" xsi:type="array"> + <item name="js_config" xsi:type="array"> + <item name="component" xsi:type="string">Magento_Ui/js/grid/columns/column</item> + </item> + <item name="config" xsi:type="array"> + <item name="visible" xsi:type="boolean">false</item> + <item name="dataType" xsi:type="string">text</item> + <item name="align" xsi:type="string">left</item> + <item name="label" xsi:type="string" translate="true">Subtotal</item> + </item> + </argument> + </column> + <column name="shipping_and_handling" class="Magento\Sales\Ui\Component\Listing\Column\Price"> + <argument name="data" xsi:type="array"> + <item name="js_config" xsi:type="array"> + <item name="component" xsi:type="string">Magento_Ui/js/grid/columns/column</item> + </item> + <item name="config" xsi:type="array"> + <item name="visible" xsi:type="boolean">false</item> + <item name="dataType" xsi:type="string">text</item> + <item name="align" xsi:type="string">left</item> + <item name="label" xsi:type="string" translate="true">Shipping and Handling</item> + </item> + </argument> + </column> + <column name="customer_name"> + <argument name="data" xsi:type="array"> + <item name="js_config" xsi:type="array"> + <item name="component" xsi:type="string">Magento_Ui/js/grid/columns/column</item> + </item> + <item name="config" xsi:type="array"> + <item name="visible" xsi:type="boolean">false</item> + <item name="dataType" xsi:type="string">text</item> + <item name="align" xsi:type="string">left</item> + <item name="label" xsi:type="string" translate="true">Customer Name</item> + </item> + </argument> + </column> + <column name="payment_method" class="Magento\Sales\Ui\Component\Listing\Column\PaymentMethod"> + <argument name="data" xsi:type="array"> + <item name="js_config" xsi:type="array"> + <item name="component" xsi:type="string">Magento_Ui/js/grid/columns/column</item> + </item> + <item name="config" xsi:type="array"> + <item name="visible" xsi:type="boolean">false</item> + <item name="dataType" xsi:type="string">text</item> + <item name="align" xsi:type="string">left</item> + <item name="label" xsi:type="string" translate="true">Payment Method</item> + </item> + </argument> + </column> + <column name="total_refunded" class="Magento\Sales\Ui\Component\Listing\Column\Price"> + <argument name="data" xsi:type="array"> + <item name="js_config" xsi:type="array"> + <item name="component" xsi:type="string">Magento_Ui/js/grid/columns/column</item> + </item> + <item name="config" xsi:type="array"> + <item name="visible" xsi:type="boolean">false</item> + <item name="dataType" xsi:type="string">text</item> + <item name="align" xsi:type="string">left</item> + <item name="label" xsi:type="string" translate="true">Total Refunded</item> + </item> + </argument> + </column> + <column name="actions" class="Magento\Sales\Ui\Component\Listing\Column\OrderActions"> + <argument name="data" xsi:type="array"> + <item name="config" xsi:type="array"> + <item name="draggable" xsi:type="boolean">false</item> + <item name="dataType" xsi:type="string">actions</item> + <item name="indexField" xsi:type="string">increment_id</item> + <item name="align" xsi:type="string">left</item> + <item name="label" xsi:type="string" translate="true">Action</item> + <item name="data_type" xsi:type="string">actions</item> + <item name="filterable" xsi:type="boolean">false</item> + <item name="sortable" xsi:type="boolean">false</item> + </item> + </argument> + </column> + </columns> +</listing> diff --git a/app/code/Magento/Sales/view/adminhtml/ui_component/sales_order_invoice_grid.xml b/app/code/Magento/Sales/view/adminhtml/ui_component/sales_order_invoice_grid.xml new file mode 100644 index 0000000000000000000000000000000000000000..7b39dd42a49ea014f2dbd7e64eaa46b60054c88e --- /dev/null +++ b/app/code/Magento/Sales/view/adminhtml/ui_component/sales_order_invoice_grid.xml @@ -0,0 +1,733 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!-- +/** + * Copyright © 2015 Magento. All rights reserved. + * See COPYING.txt for license details. + */ +--> +<listing xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../../../../Ui/etc/ui_configuration.xsd"> + <argument name="data" xsi:type="array"> + <item name="js_config" xsi:type="array"> + <item name="provider" xsi:type="string">sales_order_invoice_grid.sales_order_invoice_grid_data_source</item> + <item name="deps" xsi:type="string">sales_order_invoice_grid.sales_order_invoice_grid_data_source</item> + </item> + <item name="spinner" xsi:type="string">sales_order_invoice_columns</item> + </argument> + <dataSource name="sales_order_invoice_grid_data_source"> + <argument name="dataProvider" xsi:type="configurableObject"> + <argument name="class" xsi:type="string">InvoiceGridDataProvider</argument> + <argument name="name" xsi:type="string">sales_order_invoice_grid_data_source</argument> + <argument name="primaryFieldName" xsi:type="string">increment_id</argument> + <argument name="requestFieldName" xsi:type="string">id</argument> + <argument name="data" xsi:type="array"> + <item name="config" xsi:type="array"> + <item name="update_url" xsi:type="url" path="mui/index/render"/> + </item> + </argument> + </argument> + <argument name="data" xsi:type="array"> + <item name="js_config" xsi:type="array"> + <item name="component" xsi:type="string">Magento_Ui/js/grid/provider</item> + </item> + </argument> + </dataSource> + <container name="listing_top"> + <argument name="data" xsi:type="array"> + <item name="config" xsi:type="array"> + <item name="template" xsi:type="string">ui/grid/toolbar</item> + </item> + </argument> + <bookmark name="bookmarks"> + <argument name="data" xsi:type="array"> + <item name="config" xsi:type="array"> + <item name="component" xsi:type="string">Magento_Ui/js/grid/controls/bookmarks/bookmarks</item> + <item name="displayArea" xsi:type="string">dataGridActions</item> + <item name="storageConfig" xsi:type="array"> + <item name="saveUrl" xsi:type="url" path="mui/bookmark/save"/> + <item name="deleteUrl" xsi:type="url" path="mui/bookmark/delete"/> + <item name="namespace" xsi:type="string">sales_order_invoice_grid</item> + </item> + </item> + </argument> + </bookmark> + <container name="columns_controls"> + <argument name="data" xsi:type="array"> + <item name="config" xsi:type="array"> + <item name="columnsData" xsi:type="array"> + <item name="provider" xsi:type="string">sales_order_invoice_grid.sales_order_invoice_grid.sales_order_invoice_columns</item> + </item> + <item name="component" xsi:type="string">Magento_Ui/js/grid/controls/columns</item> + <item name="displayArea" xsi:type="string">dataGridActions</item> + </item> + </argument> + </container> + <exportButton name="export_button"> + <argument name="data" xsi:type="array"> + <item name="config" xsi:type="array"> + <item name="displayArea" xsi:type="string">dataGridActions</item> + <item name="options" xsi:type="array"> + <item name="cvs" xsi:type="array"> + <item name="value" xsi:type="string">csv</item> + <item name="label" xsi:type="string" translate="true">CSV</item> + <item name="url" xsi:type="string">sales/invoice/exportCsv</item> + </item> + <item name="xml" xsi:type="array"> + <item name="value" xsi:type="string">xml</item> + <item name="label" xsi:type="string" translate="true">Excel XML</item> + <item name="url" xsi:type="string">sales/invoice/exportExcel</item> + </item> + </item> + </item> + </argument> + </exportButton> + <filterSearch name="fulltext"> + <argument name="data" xsi:type="array"> + <item name="config" xsi:type="array"> + <item name="provider" xsi:type="string">sales_order_invoice_grid.sales_order_invoice_grid_data_source</item> + <item name="chipsProvider" xsi:type="string">sales_order_invoice_grid.sales_order_invoice_grid.listing_top.listing_filters_chips</item> + <item name="storageConfig" xsi:type="array"> + <item name="provider" xsi:type="string">sales_order_invoice_grid.sales_order_invoice_grid.listing_top.bookmarks</item> + <item name="namespace" xsi:type="string">current.search</item> + </item> + </item> + </argument> + </filterSearch> + <filters name="listing_filters"> + <argument name="data" xsi:type="array"> + <item name="config" xsi:type="array"> + <item name="displayArea" xsi:type="string">dataGridFilters</item> + <item name="dataScope" xsi:type="string">filters</item> + <item name="storageConfig" xsi:type="array"> + <item name="provider" xsi:type="string">sales_order_invoice_grid.sales_order_invoice_grid.listing_top.bookmarks</item> + <item name="namespace" xsi:type="string">current.filters</item> + </item> + <item name="childDefaults" xsi:type="array"> + <item name="provider" xsi:type="string">sales_order_invoice_grid.sales_order_invoice_grid.listing_top.listing_filters</item> + <item name="imports" xsi:type="array"> + <item name="visible" xsi:type="string">sales_order_invoice_grid.sales_order_invoice_grid.listing_top.bookmarks:current.columns.${ $.index }.visible</item> + </item> + </item> + </item> + </argument> + <filterRange name="increment_id"> + <argument name="data" xsi:type="array"> + <item name="config" xsi:type="array"> + <item name="dataScope" xsi:type="string">increment_id</item> + <item name="label" xsi:type="string" translate="true">Invoice</item> + <item name="childDefaults" xsi:type="array"> + <item name="provider" xsi:type="string">sales_order_invoice_grid.sales_order_invoice_grid.listing_top.listing_filters</item> + </item> + </item> + </argument> + <filterInput name="from"> + <argument name="data" xsi:type="array"> + <item name="config" xsi:type="array"> + <item name="dataScope" xsi:type="string">from</item> + <item name="label" xsi:type="string" translate="true">From</item> + <item name="placeholder" xsi:type="string" translate="true">From</item> + </item> + </argument> + </filterInput> + <filterInput name="to"> + <argument name="data" xsi:type="array"> + <item name="config" xsi:type="array"> + <item name="dataScope" xsi:type="string">to</item> + <item name="label" xsi:type="string" translate="true">To</item> + <item name="placeholder" xsi:type="string" translate="true">To</item> + </item> + </argument> + </filterInput> + </filterRange> + <filterRange name="created_at" class="Magento\Ui\Component\Filters\Type\DateRange"> + <argument name="data" xsi:type="array"> + <item name="config" xsi:type="array"> + <item name="dataScope" xsi:type="string">created_at</item> + <item name="label" xsi:type="string" translate="true">Invoice Date</item> + <item name="childDefaults" xsi:type="array"> + <item name="provider" xsi:type="string">sales_order_invoice_grid.sales_order_invoice_grid.listing_top.listing_filters</item> + </item> + </item> + </argument> + <filterDate name="from"> + <argument name="data" xsi:type="array"> + <item name="config" xsi:type="array"> + <item name="dataScope" xsi:type="string">from</item> + <item name="label" xsi:type="string" translate="true">From</item> + <item name="placeholder" xsi:type="string" translate="true">From</item> + <item name="dateFormat" xsi:type="string" translate="true">MM/dd/YYYY</item> + </item> + </argument> + </filterDate> + <filterDate name="to"> + <argument name="data" xsi:type="array"> + <item name="config" xsi:type="array"> + <item name="dataScope" xsi:type="string">to</item> + <item name="label" xsi:type="string" translate="true">To</item> + <item name="placeholder" xsi:type="string" translate="true">To</item> + <item name="dateFormat" xsi:type="string" translate="true">MM/dd/YYYY</item> + </item> + </argument> + </filterDate> + </filterRange> + <filterRange name="order_increment_id"> + <argument name="data" xsi:type="array"> + <item name="config" xsi:type="array"> + <item name="dataScope" xsi:type="string">order_increment_id</item> + <item name="label" xsi:type="string" translate="true">Order #</item> + <item name="childDefaults" xsi:type="array"> + <item name="provider" xsi:type="string">sales_order_invoice_grid.sales_order_invoice_grid.listing_top.listing_filters</item> + </item> + </item> + </argument> + <filterInput name="from"> + <argument name="data" xsi:type="array"> + <item name="config" xsi:type="array"> + <item name="dataScope" xsi:type="string">from</item> + <item name="label" xsi:type="string" translate="true">From</item> + <item name="placeholder" xsi:type="string" translate="true">From</item> + </item> + </argument> + </filterInput> + <filterInput name="to"> + <argument name="data" xsi:type="array"> + <item name="config" xsi:type="array"> + <item name="dataScope" xsi:type="string">to</item> + <item name="label" xsi:type="string" translate="true">To</item> + <item name="placeholder" xsi:type="string" translate="true">To</item> + </item> + </argument> + </filterInput> + </filterRange> + <filterRange name="order_created_at" class="Magento\Ui\Component\Filters\Type\DateRange"> + <argument name="data" xsi:type="array"> + <item name="config" xsi:type="array"> + <item name="dataScope" xsi:type="string">order_created_at</item> + <item name="label" xsi:type="string" translate="true">Order Date</item> + <item name="childDefaults" xsi:type="array"> + <item name="provider" xsi:type="string">sales_order_invoice_grid.sales_order_invoice_grid.listing_top.listing_filters</item> + </item> + </item> + </argument> + <filterDate name="from"> + <argument name="data" xsi:type="array"> + <item name="config" xsi:type="array"> + <item name="dataScope" xsi:type="string">from</item> + <item name="label" xsi:type="string" translate="true">From</item> + <item name="placeholder" xsi:type="string" translate="true">From</item> + <item name="dateFormat" xsi:type="string" translate="true">MM/dd/YYYY</item> + </item> + </argument> + </filterDate> + <filterDate name="to"> + <argument name="data" xsi:type="array"> + <item name="config" xsi:type="array"> + <item name="dataScope" xsi:type="string">to</item> + <item name="label" xsi:type="string" translate="true">To</item> + <item name="placeholder" xsi:type="string" translate="true">To</item> + <item name="dateFormat" xsi:type="string" translate="true">MM/dd/YYYY</item> + </item> + </argument> + </filterDate> + </filterRange> + <filterInput name="billing_name"> + <argument name="data" xsi:type="array"> + <item name="config" xsi:type="array"> + <item name="dataScope" xsi:type="string">billing_name</item> + <item name="label" xsi:type="string" translate="true">Bill-to Name</item> + </item> + </argument> + </filterInput> + <filterSelect name="state"> + <argument name="optionsProvider" xsi:type="configurableObject"> + <argument name="class" xsi:type="string">Magento\Sales\Ui\Component\Listing\Column\Invoice\State\Options</argument> + </argument> + <argument name="data" xsi:type="array"> + <item name="config" xsi:type="array"> + <item name="caption" xsi:type="string" translate="true">Select...</item> + <item name="dataScope" xsi:type="string">state</item> + <item name="label" xsi:type="string" translate="true">Status</item> + </item> + </argument> + </filterSelect> + <filterSelect name="store_id"> + <argument name="optionsProvider" xsi:type="configurableObject"> + <argument name="class" xsi:type="string">Magento\Store\Ui\Component\Listing\Column\Store\Options</argument> + </argument> + <argument name="data" xsi:type="array"> + <item name="config" xsi:type="array"> + <item name="caption" xsi:type="string" translate="true">Select...</item> + <item name="dataScope" xsi:type="string">store_id</item> + <item name="label" xsi:type="string" translate="true">Purchased From</item> + </item> + </argument> + </filterSelect> + <filterInput name="billing_address"> + <argument name="data" xsi:type="array"> + <item name="config" xsi:type="array"> + <item name="dataScope" xsi:type="string">billing_address</item> + <item name="label" xsi:type="string" translate="true">Billing Address</item> + </item> + </argument> + </filterInput> + <filterInput name="shipping_address"> + <argument name="data" xsi:type="array"> + <item name="config" xsi:type="array"> + <item name="dataScope" xsi:type="string">shipping_address</item> + <item name="label" xsi:type="string" translate="true">Shipping Address</item> + </item> + </argument> + </filterInput> + <filterInput name="customer_name"> + <argument name="data" xsi:type="array"> + <item name="config" xsi:type="array"> + <item name="dataScope" xsi:type="string">customer_name</item> + <item name="label" xsi:type="string" translate="true">Customer Name</item> + </item> + </argument> + </filterInput> + <filterInput name="customer_email"> + <argument name="data" xsi:type="array"> + <item name="config" xsi:type="array"> + <item name="dataScope" xsi:type="string">customer_email</item> + <item name="label" xsi:type="string" translate="true">Customer Email</item> + </item> + </argument> + </filterInput> + <filterSelect name="customer_group_id"> + <argument name="optionsProvider" xsi:type="configurableObject"> + <argument name="class" xsi:type="string">Magento\Customer\Ui\Component\Listing\Column\Group\Options</argument> + </argument> + <argument name="data" xsi:type="array"> + <item name="config" xsi:type="array"> + <item name="caption" xsi:type="string" translate="true">Select...</item> + <item name="dataScope" xsi:type="string">customer_group_id</item> + <item name="label" xsi:type="string" translate="true">Customer Group</item> + </item> + </argument> + </filterSelect> + <filterSelect name="payment_method"> + <argument name="optionsProvider" xsi:type="configurableObject"> + <argument name="class" xsi:type="string">Magento\Payment\Ui\Component\Listing\Column\Method\Options</argument> + </argument> + <argument name="data" xsi:type="array"> + <item name="config" xsi:type="array"> + <item name="caption" xsi:type="string" translate="true">Select...</item> + <item name="dataScope" xsi:type="string">payment_method</item> + <item name="label" xsi:type="string" translate="true">Payment Method</item> + </item> + </argument> + </filterSelect> + <filterInput name="shipping_information"> + <argument name="data" xsi:type="array"> + <item name="config" xsi:type="array"> + <item name="dataScope" xsi:type="string">shipping_information</item> + <item name="label" xsi:type="string" translate="true">Shipping Information</item> + </item> + </argument> + </filterInput> + <filterRange name="subtotal"> + <argument name="data" xsi:type="array"> + <item name="config" xsi:type="array"> + <item name="dataScope" xsi:type="string">subtotal</item> + <item name="label" xsi:type="string" translate="true">Subtotal</item> + <item name="childDefaults" xsi:type="array"> + <item name="provider" xsi:type="string">sales_order_invoice_grid.sales_order_invoice_grid.listing_top.listing_filters</item> + </item> + </item> + </argument> + <filterInput name="from"> + <argument name="data" xsi:type="array"> + <item name="config" xsi:type="array"> + <item name="dataScope" xsi:type="string">from</item> + <item name="label" xsi:type="string" translate="true">From</item> + <item name="placeholder" xsi:type="string" translate="true">From</item> + </item> + </argument> + </filterInput> + <filterInput name="to"> + <argument name="data" xsi:type="array"> + <item name="config" xsi:type="array"> + <item name="dataScope" xsi:type="string">to</item> + <item name="label" xsi:type="string" translate="true">To</item> + <item name="placeholder" xsi:type="string" translate="true">To</item> + </item> + </argument> + </filterInput> + </filterRange> + <filterRange name="shipping_and_handling"> + <argument name="data" xsi:type="array"> + <item name="config" xsi:type="array"> + <item name="dataScope" xsi:type="string">shipping_and_handling</item> + <item name="label" xsi:type="string" translate="true">Shipping and Handling</item> + <item name="childDefaults" xsi:type="array"> + <item name="provider" xsi:type="string">sales_order_invoice_grid.sales_order_invoice_grid.listing_top.listing_filters</item> + </item> + </item> + </argument> + <filterInput name="from"> + <argument name="data" xsi:type="array"> + <item name="config" xsi:type="array"> + <item name="dataScope" xsi:type="string">from</item> + <item name="label" xsi:type="string" translate="true">From</item> + <item name="placeholder" xsi:type="string" translate="true">From</item> + </item> + </argument> + </filterInput> + <filterInput name="to"> + <argument name="data" xsi:type="array"> + <item name="config" xsi:type="array"> + <item name="dataScope" xsi:type="string">to</item> + <item name="label" xsi:type="string" translate="true">To</item> + <item name="placeholder" xsi:type="string" translate="true">To</item> + </item> + </argument> + </filterInput> + </filterRange> + <filterRange name="grand_total"> + <argument name="data" xsi:type="array"> + <item name="config" xsi:type="array"> + <item name="dataScope" xsi:type="string">grand_total</item> + <item name="label" xsi:type="string" translate="true">Grand Total</item> + <item name="childDefaults" xsi:type="array"> + <item name="provider" xsi:type="string">sales_order_invoice_grid.sales_order_invoice_grid.listing_top.listing_filters</item> + </item> + </item> + </argument> + <filterInput name="from"> + <argument name="data" xsi:type="array"> + <item name="config" xsi:type="array"> + <item name="dataScope" xsi:type="string">from</item> + <item name="label" xsi:type="string" translate="true">From</item> + <item name="placeholder" xsi:type="string" translate="true">From</item> + </item> + </argument> + </filterInput> + <filterInput name="to"> + <argument name="data" xsi:type="array"> + <item name="config" xsi:type="array"> + <item name="dataScope" xsi:type="string">to</item> + <item name="label" xsi:type="string" translate="true">To</item> + <item name="placeholder" xsi:type="string" translate="true">To</item> + </item> + </argument> + </filterInput> + </filterRange> + </filters> + <massaction name="listing_massaction"> + <argument name="data" xsi:type="array"> + <item name="config" xsi:type="array"> + <item name="selectProvider" xsi:type="string">sales_order_invoice_grid.sales_order_invoice_grid.sales_order_invoice_columns.ids</item> + <item name="displayArea" xsi:type="string">bottom</item> + <item name="actions" xsi:type="array"> + <item name="pdfinvoices_order" xsi:type="array"> + <item name="type" xsi:type="string">pdfinvoices_order</item> + <item name="label" xsi:type="string" translate="true">PDF Invoices</item> + <item name="url" xsi:type="string">sales/invoice/pdfinvoices</item> + </item> + </item> + <item name="indexField" xsi:type="string">entity_id</item> + </item> + </argument> + </massaction> + <paging name="listing_paging"> + <argument name="data" xsi:type="array"> + <item name="config" xsi:type="array"> + <item name="storageConfig" xsi:type="array"> + <item name="provider" xsi:type="string">sales_order_invoice_grid.sales_order_invoice_grid.listing_top.bookmarks</item> + <item name="namespace" xsi:type="string">current.paging</item> + </item> + <item name="selectProvider" xsi:type="string">sales_order_invoice_grid.sales_order_invoice_grid.sales_order_invoice_columns.ids</item> + <item name="displayArea" xsi:type="string">bottom</item> + <item name="options" xsi:type="array"> + <item name="20" xsi:type="array"> + <item name="value" xsi:type="number">20</item> + <item name="label" xsi:type="string" translate="true">20</item> + </item> + <item name="30" xsi:type="array"> + <item name="value" xsi:type="number">30</item> + <item name="label" xsi:type="string" translate="true">30</item> + </item> + <item name="50" xsi:type="array"> + <item name="value" xsi:type="number">50</item> + <item name="label" xsi:type="string" translate="true">50</item> + </item> + <item name="100" xsi:type="array"> + <item name="value" xsi:type="number">100</item> + <item name="label" xsi:type="string" translate="true">100</item> + </item> + <item name="200" xsi:type="array"> + <item name="value" xsi:type="number">200</item> + <item name="label" xsi:type="string" translate="true">200</item> + </item> + </item> + </item> + </argument> + </paging> + </container> + <columns name="sales_order_invoice_columns"> + <argument name="data" xsi:type="array"> + <item name="config" xsi:type="array"> + <item name="storageConfig" xsi:type="array"> + <item name="provider" xsi:type="string">sales_order_invoice_grid.sales_order_invoice_grid.listing_top.bookmarks</item> + <item name="namespace" xsi:type="string">current</item> + </item> + <item name="childDefaults" xsi:type="array"> + <item name="controlVisibility" xsi:type="boolean">true</item> + <item name="actionField" xsi:type="string">actions</item> + <item name="clickAction" xsi:type="string">view</item> + <item name="storageConfig" xsi:type="array"> + <item name="provider" xsi:type="string">sales_order_invoice_grid.sales_order_invoice_grid.listing_top.bookmarks</item> + <item name="root" xsi:type="string">columns.${ $.index }</item> + <item name="namespace" xsi:type="string">current.${ $.storageConfig.root}</item> + </item> + </item> + </item> + </argument> + <column name="ids" class="Magento\Ui\Component\MassAction\Columns\Column"> + <argument name="data" xsi:type="array"> + <item name="js_config" xsi:type="array"> + <item name="component" xsi:type="string">Magento_Ui/js/grid/columns/multiselect</item> + </item> + <item name="config" xsi:type="array"> + <item name="draggable" xsi:type="boolean">false</item> + <item name="indexField" xsi:type="string">entity_id</item> + <item name="controlVisibility" xsi:type="boolean">false</item> + </item> + </argument> + </column> + <column name="increment_id"> + <argument name="data" xsi:type="array"> + <item name="js_config" xsi:type="array"> + <item name="component" xsi:type="string">Magento_Ui/js/grid/columns/column</item> + </item> + <item name="config" xsi:type="array"> + <item name="dataType" xsi:type="string">text</item> + <item name="sorting" xsi:type="string">asc</item> + <item name="align" xsi:type="string">left</item> + <item name="label" xsi:type="string" translate="true">Invoice</item> + </item> + </argument> + </column> + <column name="created_at"> + <argument name="data" xsi:type="array"> + <item name="js_config" xsi:type="array"> + <item name="component" xsi:type="string">Magento_Ui/js/grid/columns/date</item> + </item> + <item name="config" xsi:type="array"> + <item name="dataType" xsi:type="string">date</item> + <item name="align" xsi:type="string">left</item> + <item name="label" xsi:type="string" translate="true">Invoice Date</item> + </item> + </argument> + </column> + <column name="order_increment_id"> + <argument name="data" xsi:type="array"> + <item name="js_config" xsi:type="array"> + <item name="component" xsi:type="string">Magento_Ui/js/grid/columns/column</item> + </item> + <item name="config" xsi:type="array"> + <item name="dataType" xsi:type="string">text</item> + <item name="sorting" xsi:type="string">asc</item> + <item name="align" xsi:type="string">left</item> + <item name="label" xsi:type="string" translate="true">Order #</item> + </item> + </argument> + </column> + <column name="order_created_at"> + <argument name="data" xsi:type="array"> + <item name="js_config" xsi:type="array"> + <item name="component" xsi:type="string">Magento_Ui/js/grid/columns/date</item> + </item> + <item name="config" xsi:type="array"> + <item name="dataType" xsi:type="string">date</item> + <item name="align" xsi:type="string">left</item> + <item name="label" xsi:type="string" translate="true">Order Date</item> + </item> + </argument> + </column> + <column name="billing_name"> + <argument name="data" xsi:type="array"> + <item name="js_config" xsi:type="array"> + <item name="component" xsi:type="string">Magento_Ui/js/grid/columns/column</item> + </item> + <item name="config" xsi:type="array"> + <item name="dataType" xsi:type="string">text</item> + <item name="align" xsi:type="string">left</item> + <item name="label" xsi:type="string" translate="true">Bill-to Name</item> + </item> + </argument> + </column> + <column name="state" class="Magento\Sales\Ui\Component\Listing\Column\Invoice\State"> + <argument name="data" xsi:type="array"> + <item name="js_config" xsi:type="array"> + <item name="component" xsi:type="string">Magento_Ui/js/grid/columns/select</item> + </item> + <item name="config" xsi:type="array"> + <item name="dataType" xsi:type="string">text</item> + <item name="align" xsi:type="string">left</item> + <item name="label" xsi:type="string" translate="true">Status</item> + </item> + </argument> + </column> + <column name="grand_total" class="Magento\Sales\Ui\Component\Listing\Column\Price"> + <argument name="data" xsi:type="array"> + <item name="js_config" xsi:type="array"> + <item name="component" xsi:type="string">Magento_Ui/js/grid/columns/column</item> + </item> + <item name="config" xsi:type="array"> + <item name="dataType" xsi:type="string">text</item> + <item name="align" xsi:type="string">left</item> + <item name="label" xsi:type="string" translate="true">Amount</item> + </item> + </argument> + </column> + <column name="store_id" class="Magento\Store\Ui\Component\Listing\Column\Store"> + <argument name="data" xsi:type="array"> + <item name="js_config" xsi:type="array"> + <item name="component" xsi:type="string">Magento_Ui/js/grid/columns/column</item> + </item> + <item name="config" xsi:type="array"> + <item name="bodyTmpl" xsi:type="string">ui/grid/cells/html</item> + <item name="visible" xsi:type="boolean">false</item> + <item name="sortable" xsi:type="boolean">false</item> + <item name="dataType" xsi:type="string">text</item> + <item name="align" xsi:type="string">left</item> + <item name="label" xsi:type="string" translate="true">Purchased From</item> + </item> + </argument> + </column> + <column name="billing_address" class="Magento\Sales\Ui\Component\Listing\Column\Address"> + <argument name="data" xsi:type="array"> + <item name="js_config" xsi:type="array"> + <item name="component" xsi:type="string">Magento_Ui/js/grid/columns/column</item> + </item> + <item name="config" xsi:type="array"> + <item name="bodyTmpl" xsi:type="string">ui/grid/cells/html</item> + <item name="visible" xsi:type="boolean">false</item> + <item name="dataType" xsi:type="string">text</item> + <item name="align" xsi:type="string">left</item> + <item name="label" xsi:type="string" translate="true">Billing Address</item> + </item> + </argument> + </column> + <column name="shipping_address" class="Magento\Sales\Ui\Component\Listing\Column\Address"> + <argument name="data" xsi:type="array"> + <item name="js_config" xsi:type="array"> + <item name="component" xsi:type="string">Magento_Ui/js/grid/columns/column</item> + </item> + <item name="config" xsi:type="array"> + <item name="bodyTmpl" xsi:type="string">ui/grid/cells/html</item> + <item name="visible" xsi:type="boolean">false</item> + <item name="dataType" xsi:type="string">text</item> + <item name="align" xsi:type="string">left</item> + <item name="label" xsi:type="string" translate="true">Shipping Address</item> + </item> + </argument> + </column> + <column name="customer_name"> + <argument name="data" xsi:type="array"> + <item name="js_config" xsi:type="array"> + <item name="component" xsi:type="string">Magento_Ui/js/grid/columns/column</item> + </item> + <item name="config" xsi:type="array"> + <item name="visible" xsi:type="boolean">false</item> + <item name="dataType" xsi:type="string">text</item> + <item name="align" xsi:type="string">left</item> + <item name="label" xsi:type="string" translate="true">Customer Name</item> + </item> + </argument> + </column> + <column name="customer_email"> + <argument name="data" xsi:type="array"> + <item name="js_config" xsi:type="array"> + <item name="component" xsi:type="string">Magento_Ui/js/grid/columns/column</item> + </item> + <item name="config" xsi:type="array"> + <item name="visible" xsi:type="boolean">false</item> + <item name="dataType" xsi:type="string">text</item> + <item name="align" xsi:type="string">left</item> + <item name="label" xsi:type="string" translate="true">Email</item> + </item> + </argument> + </column> + <column name="customer_group_id" class="Magento\Sales\Ui\Component\Listing\Column\CustomerGroup"> + <argument name="data" xsi:type="array"> + <item name="js_config" xsi:type="array"> + <item name="component" xsi:type="string">Magento_Ui/js/grid/columns/column</item> + </item> + <item name="config" xsi:type="array"> + <item name="visible" xsi:type="boolean">false</item> + <item name="dataType" xsi:type="string">text</item> + <item name="align" xsi:type="string">left</item> + <item name="label" xsi:type="string" translate="true">Customer Group</item> + </item> + </argument> + </column> + <column name="payment_method" class="Magento\Sales\Ui\Component\Listing\Column\PaymentMethod"> + <argument name="data" xsi:type="array"> + <item name="js_config" xsi:type="array"> + <item name="component" xsi:type="string">Magento_Ui/js/grid/columns/column</item> + </item> + <item name="config" xsi:type="array"> + <item name="visible" xsi:type="boolean">false</item> + <item name="dataType" xsi:type="string">text</item> + <item name="align" xsi:type="string">left</item> + <item name="label" xsi:type="string" translate="true">Payment Method</item> + </item> + </argument> + </column> + <column name="shipping_information"> + <argument name="data" xsi:type="array"> + <item name="js_config" xsi:type="array"> + <item name="component" xsi:type="string">Magento_Ui/js/grid/columns/column</item> + </item> + <item name="config" xsi:type="array"> + <item name="visible" xsi:type="boolean">false</item> + <item name="dataType" xsi:type="string">text</item> + <item name="align" xsi:type="string">left</item> + <item name="label" xsi:type="string" translate="true">Shipping Information</item> + </item> + </argument> + </column> + <column name="subtotal" class="Magento\Sales\Ui\Component\Listing\Column\Price"> + <argument name="data" xsi:type="array"> + <item name="js_config" xsi:type="array"> + <item name="component" xsi:type="string">Magento_Ui/js/grid/columns/column</item> + </item> + <item name="config" xsi:type="array"> + <item name="visible" xsi:type="boolean">false</item> + <item name="dataType" xsi:type="string">text</item> + <item name="align" xsi:type="string">left</item> + <item name="label" xsi:type="string" translate="true">Subtotal</item> + </item> + </argument> + </column> + <column name="shipping_and_handling" class="Magento\Sales\Ui\Component\Listing\Column\Price"> + <argument name="data" xsi:type="array"> + <item name="js_config" xsi:type="array"> + <item name="component" xsi:type="string">Magento_Ui/js/grid/columns/column</item> + </item> + <item name="config" xsi:type="array"> + <item name="visible" xsi:type="boolean">false</item> + <item name="dataType" xsi:type="string">text</item> + <item name="align" xsi:type="string">left</item> + <item name="label" xsi:type="string" translate="true">Shipping and Handling</item> + </item> + </argument> + </column> + <column name="actions" class="Magento\Sales\Ui\Component\Listing\Column\OrderInvoiceActions"> + <argument name="data" xsi:type="array"> + <item name="config" xsi:type="array"> + <item name="draggable" xsi:type="boolean">false</item> + <item name="dataType" xsi:type="string">actions</item> + <item name="indexField" xsi:type="string">increment_id</item> + <item name="align" xsi:type="string">left</item> + <item name="label" xsi:type="string" translate="true">Action</item> + <item name="data_type" xsi:type="string">actions</item> + <item name="filterable" xsi:type="boolean">false</item> + <item name="sortable" xsi:type="boolean">false</item> + </item> + </argument> + </column> + </columns> +</listing> diff --git a/app/code/Magento/Sales/view/adminhtml/ui_component/sales_order_shipment_grid.xml b/app/code/Magento/Sales/view/adminhtml/ui_component/sales_order_shipment_grid.xml new file mode 100644 index 0000000000000000000000000000000000000000..b1c51a0d3484804fd00541fcd4d84405db993e06 --- /dev/null +++ b/app/code/Magento/Sales/view/adminhtml/ui_component/sales_order_shipment_grid.xml @@ -0,0 +1,650 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!-- +/** + * Copyright © 2015 Magento. All rights reserved. + * See COPYING.txt for license details. + */ +--> +<listing xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../../../../Ui/etc/ui_configuration.xsd"> + <argument name="data" xsi:type="array"> + <item name="js_config" xsi:type="array"> + <item name="provider" xsi:type="string">sales_order_shipment_grid.sales_order_shipment_grid_data_source</item> + <item name="deps" xsi:type="string">sales_order_shipment_grid.sales_order_shipment_grid_data_source</item> + </item> + <item name="spinner" xsi:type="string">sales_order_shipment_columns</item> + </argument> + <dataSource name="sales_order_shipment_grid_data_source"> + <argument name="dataProvider" xsi:type="configurableObject"> + <argument name="class" xsi:type="string">ShipmentGridDataProvider</argument> + <argument name="name" xsi:type="string">sales_order_shipment_grid_data_source</argument> + <argument name="primaryFieldName" xsi:type="string">increment_id</argument> + <argument name="requestFieldName" xsi:type="string">id</argument> + <argument name="data" xsi:type="array"> + <item name="config" xsi:type="array"> + <item name="update_url" xsi:type="url" path="mui/index/render"/> + </item> + </argument> + </argument> + <argument name="data" xsi:type="array"> + <item name="js_config" xsi:type="array"> + <item name="component" xsi:type="string">Magento_Ui/js/grid/provider</item> + </item> + </argument> + </dataSource> + <container name="listing_top"> + <argument name="data" xsi:type="array"> + <item name="config" xsi:type="array"> + <item name="template" xsi:type="string">ui/grid/toolbar</item> + </item> + </argument> + <bookmark name="bookmarks"> + <argument name="data" xsi:type="array"> + <item name="config" xsi:type="array"> + <item name="component" xsi:type="string">Magento_Ui/js/grid/controls/bookmarks/bookmarks</item> + <item name="displayArea" xsi:type="string">dataGridActions</item> + <item name="storageConfig" xsi:type="array"> + <item name="saveUrl" xsi:type="url" path="mui/bookmark/save"/> + <item name="deleteUrl" xsi:type="url" path="mui/bookmark/delete"/> + <item name="namespace" xsi:type="string">sales_order_shipment_grid</item> + </item> + </item> + </argument> + </bookmark> + <container name="columns_controls"> + <argument name="data" xsi:type="array"> + <item name="config" xsi:type="array"> + <item name="columnsData" xsi:type="array"> + <item name="provider" xsi:type="string">sales_order_shipment_grid.sales_order_shipment_grid.sales_order_shipment_columns</item> + </item> + <item name="component" xsi:type="string">Magento_Ui/js/grid/controls/columns</item> + <item name="displayArea" xsi:type="string">dataGridActions</item> + </item> + </argument> + </container> + <exportButton name="export_button"> + <argument name="data" xsi:type="array"> + <item name="config" xsi:type="array"> + <item name="displayArea" xsi:type="string">dataGridActions</item> + <item name="options" xsi:type="array"> + <item name="cvs" xsi:type="array"> + <item name="value" xsi:type="string">csv</item> + <item name="label" xsi:type="string" translate="true">CSV</item> + <item name="url" xsi:type="string">sales/shipment/exportCsv</item> + </item> + <item name="xml" xsi:type="array"> + <item name="value" xsi:type="string">xml</item> + <item name="label" xsi:type="string" translate="true">Excel XML</item> + <item name="url" xsi:type="string">sales/shipment/exportExcel</item> + </item> + </item> + </item> + </argument> + </exportButton> + <filterSearch name="fulltext"> + <argument name="data" xsi:type="array"> + <item name="config" xsi:type="array"> + <item name="provider" xsi:type="string">sales_order_shipment_grid.sales_order_shipment_grid_data_source</item> + <item name="chipsProvider" xsi:type="string">sales_order_shipment_grid.sales_order_shipment_grid.listing_top.listing_filters_chips</item> + <item name="storageConfig" xsi:type="array"> + <item name="provider" xsi:type="string">sales_order_shipment_grid.sales_order_shipment_grid.listing_top.bookmarks</item> + <item name="namespace" xsi:type="string">current.search</item> + </item> + </item> + </argument> + </filterSearch> + <filters name="listing_filters"> + <argument name="data" xsi:type="array"> + <item name="config" xsi:type="array"> + <item name="displayArea" xsi:type="string">dataGridFilters</item> + <item name="dataScope" xsi:type="string">filters</item> + <item name="storageConfig" xsi:type="array"> + <item name="provider" xsi:type="string">sales_order_shipment_grid.sales_order_shipment_grid.listing_top.bookmarks</item> + <item name="namespace" xsi:type="string">current.filters</item> + </item> + <item name="childDefaults" xsi:type="array"> + <item name="provider" xsi:type="string">sales_order_shipment_grid.sales_order_shipment_grid.listing_top.listing_filters</item> + <item name="imports" xsi:type="array"> + <item name="visible" xsi:type="string">sales_order_shipment_grid.sales_order_shipment_grid.listing_top.bookmarks:current.columns.${ $.index }.visible</item> + </item> + </item> + </item> + </argument> + <filterRange name="increment_id"> + <argument name="data" xsi:type="array"> + <item name="config" xsi:type="array"> + <item name="dataScope" xsi:type="string">increment_id</item> + <item name="label" xsi:type="string" translate="true">Shipment</item> + <item name="childDefaults" xsi:type="array"> + <item name="provider" xsi:type="string">sales_order_shipment_grid.sales_order_shipment_grid.listing_top.listing_filters</item> + </item> + </item> + </argument> + <filterInput name="from"> + <argument name="data" xsi:type="array"> + <item name="config" xsi:type="array"> + <item name="dataScope" xsi:type="string">from</item> + <item name="label" xsi:type="string" translate="true">From</item> + <item name="placeholder" xsi:type="string" translate="true">From</item> + </item> + </argument> + </filterInput> + <filterInput name="to"> + <argument name="data" xsi:type="array"> + <item name="config" xsi:type="array"> + <item name="dataScope" xsi:type="string">to</item> + <item name="label" xsi:type="string" translate="true">To</item> + <item name="placeholder" xsi:type="string" translate="true">To</item> + </item> + </argument> + </filterInput> + </filterRange> + <filterRange name="created_at" class="Magento\Ui\Component\Filters\Type\DateRange"> + <argument name="data" xsi:type="array"> + <item name="config" xsi:type="array"> + <item name="dataScope" xsi:type="string">created_at</item> + <item name="label" xsi:type="string" translate="true">Ship Date</item> + <item name="childDefaults" xsi:type="array"> + <item name="provider" xsi:type="string">sales_order_shipment_grid.sales_order_shipment_grid.listing_top.listing_filters</item> + </item> + </item> + </argument> + <filterDate name="from"> + <argument name="data" xsi:type="array"> + <item name="config" xsi:type="array"> + <item name="dataScope" xsi:type="string">from</item> + <item name="label" xsi:type="string" translate="true">From</item> + <item name="placeholder" xsi:type="string" translate="true">From</item> + <item name="dateFormat" xsi:type="string" translate="true">MM/dd/YYYY</item> + </item> + </argument> + </filterDate> + <filterDate name="to"> + <argument name="data" xsi:type="array"> + <item name="config" xsi:type="array"> + <item name="dataScope" xsi:type="string">to</item> + <item name="label" xsi:type="string" translate="true">To</item> + <item name="placeholder" xsi:type="string" translate="true">To</item> + <item name="dateFormat" xsi:type="string" translate="true">MM/dd/YYYY</item> + </item> + </argument> + </filterDate> + </filterRange> + <filterRange name="order_increment_id"> + <argument name="data" xsi:type="array"> + <item name="config" xsi:type="array"> + <item name="dataScope" xsi:type="string">order_increment_id</item> + <item name="label" xsi:type="string" translate="true">Order</item> + <item name="childDefaults" xsi:type="array"> + <item name="provider" xsi:type="string">sales_order_shipment_grid.sales_order_shipment_grid.listing_top.listing_filters</item> + </item> + </item> + </argument> + <filterInput name="from"> + <argument name="data" xsi:type="array"> + <item name="config" xsi:type="array"> + <item name="dataScope" xsi:type="string">from</item> + <item name="label" xsi:type="string" translate="true">From</item> + <item name="placeholder" xsi:type="string" translate="true">From</item> + </item> + </argument> + </filterInput> + <filterInput name="to"> + <argument name="data" xsi:type="array"> + <item name="config" xsi:type="array"> + <item name="dataScope" xsi:type="string">to</item> + <item name="label" xsi:type="string" translate="true">To</item> + <item name="placeholder" xsi:type="string" translate="true">To</item> + </item> + </argument> + </filterInput> + </filterRange> + <filterRange name="order_created_at" class="Magento\Ui\Component\Filters\Type\DateRange"> + <argument name="data" xsi:type="array"> + <item name="config" xsi:type="array"> + <item name="dataScope" xsi:type="string">order_created_at</item> + <item name="label" xsi:type="string" translate="true">Order Date</item> + <item name="childDefaults" xsi:type="array"> + <item name="provider" xsi:type="string">sales_order_shipment_grid.sales_order_shipment_grid.listing_top.listing_filters</item> + </item> + </item> + </argument> + <filterDate name="from"> + <argument name="data" xsi:type="array"> + <item name="config" xsi:type="array"> + <item name="dataScope" xsi:type="string">from</item> + <item name="label" xsi:type="string" translate="true">From</item> + <item name="placeholder" xsi:type="string" translate="true">From</item> + <item name="dateFormat" xsi:type="string" translate="true">MM/dd/YYYY</item> + </item> + </argument> + </filterDate> + <filterDate name="to"> + <argument name="data" xsi:type="array"> + <item name="config" xsi:type="array"> + <item name="dataScope" xsi:type="string">to</item> + <item name="label" xsi:type="string" translate="true">To</item> + <item name="placeholder" xsi:type="string" translate="true">To</item> + <item name="dateFormat" xsi:type="string" translate="true">MM/dd/YYYY</item> + </item> + </argument> + </filterDate> + </filterRange> + <filterInput name="shipping_name"> + <argument name="data" xsi:type="array"> + <item name="config" xsi:type="array"> + <item name="dataScope" xsi:type="string">shipping_name</item> + <item name="label" xsi:type="string" translate="true">Ship-to Name</item> + </item> + </argument> + </filterInput> + <filterRange name="total_qty"> + <argument name="data" xsi:type="array"> + <item name="config" xsi:type="array"> + <item name="dataScope" xsi:type="string">total_qty</item> + <item name="label" xsi:type="string" translate="true">Total Quantity</item> + <item name="childDefaults" xsi:type="array"> + <item name="provider" xsi:type="string">sales_order_shipment_grid.sales_order_shipment_grid.listing_top.listing_filters</item> + </item> + </item> + </argument> + <filterInput name="from"> + <argument name="data" xsi:type="array"> + <item name="config" xsi:type="array"> + <item name="dataScope" xsi:type="string">from</item> + <item name="label" xsi:type="string" translate="true">From</item> + <item name="placeholder" xsi:type="string" translate="true">From</item> + </item> + </argument> + </filterInput> + <filterInput name="to"> + <argument name="data" xsi:type="array"> + <item name="config" xsi:type="array"> + <item name="dataScope" xsi:type="string">to</item> + <item name="label" xsi:type="string" translate="true">To</item> + <item name="placeholder" xsi:type="string" translate="true">To</item> + </item> + </argument> + </filterInput> + </filterRange> + <filterSelect name="order_status"> + <argument name="optionsProvider" xsi:type="configurableObject"> + <argument name="class" xsi:type="string">Magento\Sales\Ui\Component\Listing\Column\Status\Options</argument> + </argument> + <argument name="data" xsi:type="array"> + <item name="config" xsi:type="array"> + <item name="caption" xsi:type="string" translate="true">Select...</item> + <item name="dataScope" xsi:type="string">order_status</item> + <item name="label" xsi:type="string" translate="true">Order Status</item> + </item> + </argument> + </filterSelect> + <filterSelect name="store_id"> + <argument name="optionsProvider" xsi:type="configurableObject"> + <argument name="class" xsi:type="string">Magento\Store\Ui\Component\Listing\Column\Store\Options</argument> + </argument> + <argument name="data" xsi:type="array"> + <item name="config" xsi:type="array"> + <item name="caption" xsi:type="string" translate="true">Select...</item> + <item name="dataScope" xsi:type="string">store_id</item> + <item name="label" xsi:type="string" translate="true">Purchased From</item> + </item> + </argument> + </filterSelect> + <filterInput name="customer_name"> + <argument name="data" xsi:type="array"> + <item name="config" xsi:type="array"> + <item name="dataScope" xsi:type="string">customer_name</item> + <item name="label" xsi:type="string" translate="true">Customer Name</item> + </item> + </argument> + </filterInput> + <filterInput name="customer_email"> + <argument name="data" xsi:type="array"> + <item name="config" xsi:type="array"> + <item name="dataScope" xsi:type="string">customer_email</item> + <item name="label" xsi:type="string" translate="true">Customer Email</item> + </item> + </argument> + </filterInput> + <filterSelect name="customer_group_id"> + <argument name="optionsProvider" xsi:type="configurableObject"> + <argument name="class" xsi:type="string">Magento\Customer\Ui\Component\Listing\Column\Group\Options</argument> + </argument> + <argument name="data" xsi:type="array"> + <item name="config" xsi:type="array"> + <item name="caption" xsi:type="string" translate="true">Select...</item> + <item name="dataScope" xsi:type="string">customer_group_id</item> + <item name="label" xsi:type="string" translate="true">Customer Group</item> + </item> + </argument> + </filterSelect> + <filterInput name="billing_address"> + <argument name="data" xsi:type="array"> + <item name="config" xsi:type="array"> + <item name="dataScope" xsi:type="string">billing_address</item> + <item name="label" xsi:type="string" translate="true">Billing Address</item> + </item> + </argument> + </filterInput> + <filterInput name="shipping_address"> + <argument name="data" xsi:type="array"> + <item name="config" xsi:type="array"> + <item name="dataScope" xsi:type="string">shipping_address</item> + <item name="label" xsi:type="string" translate="true">Shipping Address</item> + </item> + </argument> + </filterInput> + <filterSelect name="payment_method"> + <argument name="optionsProvider" xsi:type="configurableObject"> + <argument name="class" xsi:type="string">Magento\Payment\Ui\Component\Listing\Column\Method\Options</argument> + </argument> + <argument name="data" xsi:type="array"> + <item name="config" xsi:type="array"> + <item name="caption" xsi:type="string" translate="true">Select...</item> + <item name="dataScope" xsi:type="string">payment_method</item> + <item name="label" xsi:type="string" translate="true">Payment Method</item> + </item> + </argument> + </filterSelect> + <filterInput name="shipping_information"> + <argument name="data" xsi:type="array"> + <item name="config" xsi:type="array"> + <item name="dataScope" xsi:type="string">shipping_information</item> + <item name="label" xsi:type="string" translate="true">Shipping Information</item> + </item> + </argument> + </filterInput> + </filters> + <massaction name="listing_massaction"> + <argument name="data" xsi:type="array"> + <item name="config" xsi:type="array"> + <item name="selectProvider" xsi:type="string">sales_order_shipment_grid.sales_order_shipment_grid.sales_order_shipment_columns.ids</item> + <item name="displayArea" xsi:type="string">bottom</item> + <item name="actions" xsi:type="array"> + <item name="pdfshipments_order" xsi:type="array"> + <item name="type" xsi:type="string">pdfshipments_order</item> + <item name="label" xsi:type="string" translate="true">PDF Shipments</item> + <item name="url" xsi:type="string">sales/shipment/pdfshipments</item> + </item> + </item> + <item name="indexField" xsi:type="string">entity_id</item> + </item> + </argument> + </massaction> + <paging name="listing_paging"> + <argument name="data" xsi:type="array"> + <item name="config" xsi:type="array"> + <item name="storageConfig" xsi:type="array"> + <item name="provider" xsi:type="string">sales_order_shipment_grid.sales_order_shipment_grid.listing_top.bookmarks</item> + <item name="namespace" xsi:type="string">current.paging</item> + </item> + <item name="selectProvider" xsi:type="string">sales_order_shipment_grid.sales_order_shipment_grid.sales_order_shipment_columns.ids</item> + <item name="displayArea" xsi:type="string">bottom</item> + <item name="options" xsi:type="array"> + <item name="20" xsi:type="array"> + <item name="value" xsi:type="number">20</item> + <item name="label" xsi:type="string" translate="true">20</item> + </item> + <item name="30" xsi:type="array"> + <item name="value" xsi:type="number">30</item> + <item name="label" xsi:type="string" translate="true">30</item> + </item> + <item name="50" xsi:type="array"> + <item name="value" xsi:type="number">50</item> + <item name="label" xsi:type="string" translate="true">50</item> + </item> + <item name="100" xsi:type="array"> + <item name="value" xsi:type="number">100</item> + <item name="label" xsi:type="string" translate="true">100</item> + </item> + <item name="200" xsi:type="array"> + <item name="value" xsi:type="number">200</item> + <item name="label" xsi:type="string" translate="true">200</item> + </item> + </item> + </item> + </argument> + </paging> + </container> + <columns name="sales_order_shipment_columns"> + <argument name="data" xsi:type="array"> + <item name="config" xsi:type="array"> + <item name="storageConfig" xsi:type="array"> + <item name="provider" xsi:type="string">sales_order_shipment_grid.sales_order_shipment_grid.listing_top.bookmarks</item> + <item name="namespace" xsi:type="string">current</item> + </item> + <item name="childDefaults" xsi:type="array"> + <item name="controlVisibility" xsi:type="boolean">true</item> + <item name="actionField" xsi:type="string">actions</item> + <item name="clickAction" xsi:type="string">view</item> + <item name="storageConfig" xsi:type="array"> + <item name="provider" xsi:type="string">sales_order_shipment_grid.sales_order_shipment_grid.listing_top.bookmarks</item> + <item name="root" xsi:type="string">columns.${ $.index }</item> + <item name="namespace" xsi:type="string">current.${ $.storageConfig.root}</item> + </item> + </item> + </item> + </argument> + <column name="ids" class="Magento\Ui\Component\MassAction\Columns\Column"> + <argument name="data" xsi:type="array"> + <item name="js_config" xsi:type="array"> + <item name="component" xsi:type="string">Magento_Ui/js/grid/columns/multiselect</item> + </item> + <item name="config" xsi:type="array"> + <item name="draggable" xsi:type="boolean">false</item> + <item name="indexField" xsi:type="string">entity_id</item> + <item name="controlVisibility" xsi:type="boolean">false</item> + </item> + </argument> + </column> + <column name="increment_id"> + <argument name="data" xsi:type="array"> + <item name="js_config" xsi:type="array"> + <item name="component" xsi:type="string">Magento_Ui/js/grid/columns/column</item> + </item> + <item name="config" xsi:type="array"> + <item name="dataType" xsi:type="string">text</item> + <item name="sorting" xsi:type="string">asc</item> + <item name="align" xsi:type="string">left</item> + <item name="label" xsi:type="string" translate="true">Shipment</item> + </item> + </argument> + </column> + <column name="created_at"> + <argument name="data" xsi:type="array"> + <item name="js_config" xsi:type="array"> + <item name="component" xsi:type="string">Magento_Ui/js/grid/columns/date</item> + </item> + <item name="config" xsi:type="array"> + <item name="dataType" xsi:type="string">date</item> + <item name="align" xsi:type="string">left</item> + <item name="label" xsi:type="string" translate="true">Ship Date</item> + </item> + </argument> + </column> + <column name="order_increment_id"> + <argument name="data" xsi:type="array"> + <item name="js_config" xsi:type="array"> + <item name="component" xsi:type="string">Magento_Ui/js/grid/columns/column</item> + </item> + <item name="config" xsi:type="array"> + <item name="dataType" xsi:type="string">text</item> + <item name="sorting" xsi:type="string">asc</item> + <item name="align" xsi:type="string">left</item> + <item name="label" xsi:type="string" translate="true">Order</item> + </item> + </argument> + </column> + <column name="order_created_at"> + <argument name="data" xsi:type="array"> + <item name="js_config" xsi:type="array"> + <item name="component" xsi:type="string">Magento_Ui/js/grid/columns/date</item> + </item> + <item name="config" xsi:type="array"> + <item name="dataType" xsi:type="string">date</item> + <item name="align" xsi:type="string">left</item> + <item name="label" xsi:type="string" translate="true">Order Date</item> + </item> + </argument> + </column> + <column name="shipping_name"> + <argument name="data" xsi:type="array"> + <item name="js_config" xsi:type="array"> + <item name="component" xsi:type="string">Magento_Ui/js/grid/columns/column</item> + </item> + <item name="config" xsi:type="array"> + <item name="dataType" xsi:type="string">text</item> + <item name="align" xsi:type="string">left</item> + <item name="label" xsi:type="string" translate="true">Ship-to Name</item> + </item> + </argument> + </column> + <column name="total_qty"> + <argument name="data" xsi:type="array"> + <item name="js_config" xsi:type="array"> + <item name="component" xsi:type="string">Magento_Ui/js/grid/columns/column</item> + </item> + <item name="config" xsi:type="array"> + <item name="dataType" xsi:type="string">text</item> + <item name="align" xsi:type="string">left</item> + <item name="label" xsi:type="string" translate="true">Total Quantity</item> + </item> + </argument> + </column> + <column name="order_status" class="Magento\Sales\Ui\Component\Listing\Column\Status"> + <argument name="data" xsi:type="array"> + <item name="js_config" xsi:type="array"> + <item name="component" xsi:type="string">Magento_Ui/js/grid/columns/select</item> + </item> + <item name="config" xsi:type="array"> + <item name="visible" xsi:type="boolean">false</item> + <item name="dataType" xsi:type="string">text</item> + <item name="align" xsi:type="string">left</item> + <item name="label" xsi:type="string" translate="true">Order Status</item> + </item> + </argument> + </column> + <column name="store_id" class="Magento\Store\Ui\Component\Listing\Column\Store"> + <argument name="data" xsi:type="array"> + <item name="js_config" xsi:type="array"> + <item name="component" xsi:type="string">Magento_Ui/js/grid/columns/column</item> + </item> + <item name="config" xsi:type="array"> + <item name="bodyTmpl" xsi:type="string">ui/grid/cells/html</item> + <item name="visible" xsi:type="boolean">false</item> + <item name="sortable" xsi:type="boolean">false</item> + <item name="dataType" xsi:type="string">text</item> + <item name="align" xsi:type="string">left</item> + <item name="label" xsi:type="string" translate="true">Purchased From</item> + </item> + </argument> + </column> + <column name="customer_name"> + <argument name="data" xsi:type="array"> + <item name="js_config" xsi:type="array"> + <item name="component" xsi:type="string">Magento_Ui/js/grid/columns/column</item> + </item> + <item name="config" xsi:type="array"> + <item name="visible" xsi:type="boolean">false</item> + <item name="dataType" xsi:type="string">text</item> + <item name="align" xsi:type="string">left</item> + <item name="label" xsi:type="string" translate="true">Customer Name</item> + </item> + </argument> + </column> + <column name="customer_email"> + <argument name="data" xsi:type="array"> + <item name="js_config" xsi:type="array"> + <item name="component" xsi:type="string">Magento_Ui/js/grid/columns/column</item> + </item> + <item name="config" xsi:type="array"> + <item name="visible" xsi:type="boolean">false</item> + <item name="dataType" xsi:type="string">text</item> + <item name="align" xsi:type="string">left</item> + <item name="label" xsi:type="string" translate="true">Email</item> + </item> + </argument> + </column> + <column name="customer_group_id" class="Magento\Sales\Ui\Component\Listing\Column\CustomerGroup"> + <argument name="data" xsi:type="array"> + <item name="js_config" xsi:type="array"> + <item name="component" xsi:type="string">Magento_Ui/js/grid/columns/column</item> + </item> + <item name="config" xsi:type="array"> + <item name="visible" xsi:type="boolean">false</item> + <item name="dataType" xsi:type="string">text</item> + <item name="align" xsi:type="string">left</item> + <item name="label" xsi:type="string" translate="true">Customer Group</item> + </item> + </argument> + </column> + <column name="billing_address" class="Magento\Sales\Ui\Component\Listing\Column\Address"> + <argument name="data" xsi:type="array"> + <item name="js_config" xsi:type="array"> + <item name="component" xsi:type="string">Magento_Ui/js/grid/columns/column</item> + </item> + <item name="config" xsi:type="array"> + <item name="bodyTmpl" xsi:type="string">ui/grid/cells/html</item> + <item name="visible" xsi:type="boolean">false</item> + <item name="dataType" xsi:type="string">text</item> + <item name="align" xsi:type="string">left</item> + <item name="label" xsi:type="string" translate="true">Billing Address</item> + </item> + </argument> + </column> + <column name="shipping_address" class="Magento\Sales\Ui\Component\Listing\Column\Address"> + <argument name="data" xsi:type="array"> + <item name="js_config" xsi:type="array"> + <item name="component" xsi:type="string">Magento_Ui/js/grid/columns/column</item> + </item> + <item name="config" xsi:type="array"> + <item name="bodyTmpl" xsi:type="string">ui/grid/cells/html</item> + <item name="visible" xsi:type="boolean">false</item> + <item name="dataType" xsi:type="string">text</item> + <item name="align" xsi:type="string">left</item> + <item name="label" xsi:type="string" translate="true">Shipping Address</item> + </item> + </argument> + </column> + <column name="payment_method" class="Magento\Sales\Ui\Component\Listing\Column\PaymentMethod"> + <argument name="data" xsi:type="array"> + <item name="js_config" xsi:type="array"> + <item name="component" xsi:type="string">Magento_Ui/js/grid/columns/column</item> + </item> + <item name="config" xsi:type="array"> + <item name="visible" xsi:type="boolean">false</item> + <item name="dataType" xsi:type="string">text</item> + <item name="align" xsi:type="string">left</item> + <item name="label" xsi:type="string" translate="true">Payment Method</item> + </item> + </argument> + </column> + <column name="shipping_information"> + <argument name="data" xsi:type="array"> + <item name="js_config" xsi:type="array"> + <item name="component" xsi:type="string">Magento_Ui/js/grid/columns/column</item> + </item> + <item name="config" xsi:type="array"> + <item name="visible" xsi:type="boolean">false</item> + <item name="dataType" xsi:type="string">text</item> + <item name="align" xsi:type="string">left</item> + <item name="label" xsi:type="string" translate="true">Shipping Information</item> + </item> + </argument> + </column> + <column name="actions" class="Magento\Sales\Ui\Component\Listing\Column\OrderShipmentActions"> + <argument name="data" xsi:type="array"> + <item name="config" xsi:type="array"> + <item name="draggable" xsi:type="boolean">false</item> + <item name="dataType" xsi:type="string">actions</item> + <item name="indexField" xsi:type="string">entity_id</item> + <item name="align" xsi:type="string">left</item> + <item name="label" xsi:type="string" translate="true">Action</item> + <item name="data_type" xsi:type="string">actions</item> + <item name="filterable" xsi:type="boolean">false</item> + <item name="sortable" xsi:type="boolean">false</item> + </item> + </argument> + </column> + </columns> +</listing> diff --git a/app/code/Magento/Shipping/Controller/Adminhtml/Order/Shipment/MassPrintShippingLabel.php b/app/code/Magento/Shipping/Controller/Adminhtml/Order/Shipment/MassPrintShippingLabel.php index 09b92ee211a1ce0cb121e81304945b947a6c744f..8c3b4d1115ab0e5197d8d1d152922ed4ca728971 100644 --- a/app/code/Magento/Shipping/Controller/Adminhtml/Order/Shipment/MassPrintShippingLabel.php +++ b/app/code/Magento/Shipping/Controller/Adminhtml/Order/Shipment/MassPrintShippingLabel.php @@ -9,8 +9,9 @@ namespace Magento\Shipping\Controller\Adminhtml\Order\Shipment; use Magento\Backend\App\Action; use Magento\Framework\App\ResponseInterface; use Magento\Framework\App\Filesystem\DirectoryList; +use Magento\Framework\Model\Resource\Db\Collection\AbstractCollection; -class MassPrintShippingLabel extends \Magento\Backend\App\Action +class MassPrintShippingLabel extends \Magento\Sales\Controller\Adminhtml\Order\AbstractMassAction { /** * @var \Magento\Shipping\Model\Shipping\LabelGenerator @@ -49,13 +50,14 @@ class MassPrintShippingLabel extends \Magento\Backend\App\Action * Batch print shipping labels for whole shipments. * Push pdf document with shipping labels to user browser * + * @param AbstractCollection $collection * @return ResponseInterface|void * @SuppressWarnings(PHPMD.CyclomaticComplexity) */ - public function execute() + protected function massAction(AbstractCollection $collection) { $request = $this->getRequest(); - $ids = $request->getParam('order_ids'); + $ids = $collection->getAllIds(); $createdFromOrders = !empty($ids); $shipments = null; $labelsContent = []; diff --git a/app/code/Magento/Shipping/view/adminhtml/web/order/packaging.js b/app/code/Magento/Shipping/view/adminhtml/web/order/packaging.js index fca9b0553afa7a9de06030524a0259bdc4bca504..2639eb623fe358282898cf06dd5ea1abd799110a 100644 --- a/app/code/Magento/Shipping/view/adminhtml/web/order/packaging.js +++ b/app/code/Magento/Shipping/view/adminhtml/web/order/packaging.js @@ -748,7 +748,7 @@ Packaging.prototype = { _observeQty: function() { /** this = input[type="checkbox"] */ - var tr = this.parentNode.parentNode, + var tr = jQuery(this).closest('tr')[0], qty = $(tr.cells[tr.cells.length - 1]).select('input[name="qty"]')[0]; if (qty.disabled = !this.checked) { diff --git a/app/code/Magento/Store/Ui/Component/Listing/Column/Store/Options.php b/app/code/Magento/Store/Ui/Component/Listing/Column/Store/Options.php index 308a21b9f3100446ae33487823ae10e73ffcc2e6..4cbef52f9fc6cd6c513c33277229834cb2f5d5ea 100644 --- a/app/code/Magento/Store/Ui/Component/Listing/Column/Store/Options.php +++ b/app/code/Magento/Store/Ui/Component/Listing/Column/Store/Options.php @@ -59,12 +59,7 @@ class Options implements OptionSourceInterface $groupCollection = $this->systemStore->getGroupCollection(); $storeCollection = $this->systemStore->getStoreCollection(); - $currentOptions = [ - (string)__('All Store Views') => [ - 'label' => __('All Store Views'), - 'value' => 0, - ], - ]; + $currentOptions = []; /** @var \Magento\Store\Model\Website $website */ foreach ($websiteCollection as $website) { $groups = []; diff --git a/app/code/Magento/Tax/Test/Unit/Model/Plugin/OrderSaveTest.php b/app/code/Magento/Tax/Test/Unit/Model/Plugin/OrderSaveTest.php index f50e79c9658b377c088ab51aed488d2494ee8f82..3fb38e128d986704a02e5caafdd59d325b073847 100644 --- a/app/code/Magento/Tax/Test/Unit/Model/Plugin/OrderSaveTest.php +++ b/app/code/Magento/Tax/Test/Unit/Model/Plugin/OrderSaveTest.php @@ -90,7 +90,7 @@ class OrderSaveTest extends \PHPUnit_Framework_TestCase 'getConvertingFromQuote', 'getItemAppliedTaxes', ] - )->getMock(); + )->getMockForAbstractClass(); return $orderExtensionAttributeMock; } diff --git a/app/code/Magento/Tax/Test/Unit/Model/Quote/ToOrderConverterTest.php b/app/code/Magento/Tax/Test/Unit/Model/Quote/ToOrderConverterTest.php index cc72250a496783692451f8c12ecc610f9de28d43..4d8139360f4b5347d6561a66deea4bf119c9b1ba 100644 --- a/app/code/Magento/Tax/Test/Unit/Model/Quote/ToOrderConverterTest.php +++ b/app/code/Magento/Tax/Test/Unit/Model/Quote/ToOrderConverterTest.php @@ -69,7 +69,7 @@ class ToOrderConverterTest extends \PHPUnit_Framework_TestCase 'setConvertingFromQuote', 'setItemAppliedTaxes' ] - )->getMock(); + )->getMockForAbstractClass(); return $orderExtensionAttributeMock; } diff --git a/app/code/Magento/Ui/Component/Bookmark.php b/app/code/Magento/Ui/Component/Bookmark.php index 7c8d54889f13ae6a1028dc2d61e6544f5ba464f1..3f4abe68275fcd4963c6881aac7b869edde9a089 100644 --- a/app/code/Magento/Ui/Component/Bookmark.php +++ b/app/code/Magento/Ui/Component/Bookmark.php @@ -75,17 +75,11 @@ class Bookmark extends AbstractComponent $bookmarks = $this->bookmarkManagement->loadByNamespace($namespace); /** @var \Magento\Ui\Api\Data\BookmarkInterface $bookmark */ foreach ($bookmarks->getItems() as $bookmark) { - $activeIndex = ($bookmark->isCurrent() ? $bookmark->getIdentifier() : false); - - if ($bookmark->getIdentifier() == 'current') { - $config['current'] = $bookmark->getConfig(); - } else { - $config['views'][$bookmark->getIdentifier()] = $bookmark->getConfig(); + if ($bookmark->isCurrent()) { + $config['activeIndex'] = $bookmark->getIdentifier(); } - if ($activeIndex !== false) { - $config['activeIndex'] = $activeIndex; - } + $config = array_merge_recursive($config, $bookmark->getConfig()); } } diff --git a/app/code/Magento/Ui/Component/ExportButton.php b/app/code/Magento/Ui/Component/ExportButton.php new file mode 100644 index 0000000000000000000000000000000000000000..c050df2e8ae749268fc59cd71222b9804e383f3c --- /dev/null +++ b/app/code/Magento/Ui/Component/ExportButton.php @@ -0,0 +1,69 @@ +<?php +/** + * Copyright © 2015 Magento. All rights reserved. + * See COPYING.txt for license details. + */ +namespace Magento\Ui\Component; + +use Magento\Framework\View\Element\UiComponent\ContextInterface; +use Magento\Framework\UrlInterface; + +/** + * Class ExportButton + */ +class ExportButton extends AbstractComponent +{ + /** + * Component name + */ + const NAME = 'exportButton'; + + /** + * @var \Magento\Framework\UrlInterface + */ + protected $urlBuilder; + + /** + * @param ContextInterface $context + * @param UrlInterface $urlBuilder + * @param array $components + * @param array $data + */ + public function __construct( + ContextInterface $context, + UrlInterface $urlBuilder, + array $components = [], + array $data = [] + ) { + parent::__construct($context, $components, $data); + $this->urlBuilder = $urlBuilder; + } + + /** + * Get component name + * + * @return string + */ + public function getComponentName() + { + return static::NAME; + } + + /** + * @return void + */ + public function prepare() + { + $config = $this->getData('config'); + if (isset($config['options'])) { + $options = []; + foreach ($config['options'] as $option) { + $option['url'] = $this->urlBuilder->getUrl($option['url']); + $options[] = $option; + } + $config['options'] = $options; + $this->setData('config', $config); + } + parent::prepare(); + } +} diff --git a/app/code/Magento/Ui/Component/Filters/Type/Date.php b/app/code/Magento/Ui/Component/Filters/Type/Date.php index 28dd600474e24a83741e8ff3de78f44564f68319..e38e2d056fbc68074388a3252348b6ebec2f87e3 100644 --- a/app/code/Magento/Ui/Component/Filters/Type/Date.php +++ b/app/code/Magento/Ui/Component/Filters/Type/Date.php @@ -75,7 +75,7 @@ class Date extends AbstractFilter { $condition = $this->getCondition(); if ($condition !== null) { - $this->getContext()->getDataProvider()->addFilter($this->getName(), $condition); + $this->getContext()->getDataProvider()->addFilter($condition, $this->getName()); } } diff --git a/app/code/Magento/Ui/Component/Filters/Type/DateRange.php b/app/code/Magento/Ui/Component/Filters/Type/DateRange.php index 30b62739212cbffbda960677a0d3e8fd217243d9..a9628228fefbd153885706bc30ae11cd7779539a 100644 --- a/app/code/Magento/Ui/Component/Filters/Type/DateRange.php +++ b/app/code/Magento/Ui/Component/Filters/Type/DateRange.php @@ -61,7 +61,7 @@ class DateRange extends AbstractFilter { $condition = $this->getCondition(); if ($condition !== null) { - $this->getContext()->getDataProvider()->addFilter($this->getName(), $condition); + $this->getContext()->getDataProvider()->addFilter($condition, $this->getName()); } } diff --git a/app/code/Magento/Ui/Component/Filters/Type/Input.php b/app/code/Magento/Ui/Component/Filters/Type/Input.php index c20768cb281d66747e4f611852c6a77f6ab587f6..a9ba7a317942ca5493137d0de5b502c4cff7a2a0 100644 --- a/app/code/Magento/Ui/Component/Filters/Type/Input.php +++ b/app/code/Magento/Ui/Component/Filters/Type/Input.php @@ -75,7 +75,7 @@ class Input extends AbstractFilter { $condition = $this->getCondition(); if ($condition !== null) { - $this->getContext()->getDataProvider()->addFilter($this->getName(), $condition); + $this->getContext()->getDataProvider()->addFilter($condition, $this->getName()); } } diff --git a/app/code/Magento/Ui/Component/Filters/Type/Range.php b/app/code/Magento/Ui/Component/Filters/Type/Range.php index a147bc0f6ed631067a0cafdc875c622c705e63e2..bfdf5116f5755d1c5ef6393cd60de9ec2f6cfa69 100644 --- a/app/code/Magento/Ui/Component/Filters/Type/Range.php +++ b/app/code/Magento/Ui/Component/Filters/Type/Range.php @@ -43,7 +43,7 @@ class Range extends AbstractFilter { $condition = $this->getCondition(); if ($condition !== null) { - $this->getContext()->getDataProvider()->addFilter($this->getName(), $condition); + $this->getContext()->getDataProvider()->addFilter($condition, $this->getName()); } } diff --git a/app/code/Magento/Ui/Component/Filters/Type/Search.php b/app/code/Magento/Ui/Component/Filters/Type/Search.php new file mode 100644 index 0000000000000000000000000000000000000000..1795b5ccaf5b020e23edd3c30c60eedcc053844b --- /dev/null +++ b/app/code/Magento/Ui/Component/Filters/Type/Search.php @@ -0,0 +1,49 @@ +<?php +/** + * Copyright © 2015 Magento. All rights reserved. + * See COPYING.txt for license details. + */ + +namespace Magento\Ui\Component\Filters\Type; + +/** + * Class Input + */ +class Search extends \Magento\Ui\Component\Filters\Type\AbstractFilter +{ + /** + * Get component name + * + * @return string + */ + public function getComponentName() + { + return 'keyword_search'; + } + + /** + * Prepare component configuration + * + * @return void + */ + public function prepare() + { + $this->applyFilter(); + + parent::prepare(); + } + + /** + * Transfer filters to dataProvider + * + * @return void + */ + protected function applyFilter() + { + $keyword = $this->getContext()->getRequestParam('search'); + if ($keyword) { + $this->getContext()->getDataProvider()->addFilter($keyword, null, 'fulltext'); + } + + } +} diff --git a/app/code/Magento/Ui/Component/Filters/Type/Select.php b/app/code/Magento/Ui/Component/Filters/Type/Select.php index 27154bb23f881fdd6c8cbfe3c72d26b0ebbf357c..f07f672f37e58e89041a90547aebece5a28c2ad6 100644 --- a/app/code/Magento/Ui/Component/Filters/Type/Select.php +++ b/app/code/Magento/Ui/Component/Filters/Type/Select.php @@ -103,7 +103,7 @@ class Select extends AbstractFilter { $condition = $this->getCondition(); if ($condition !== null) { - $this->getContext()->getDataProvider()->addFilter($this->getName(), $condition); + $this->getContext()->getDataProvider()->addFilter($condition, $this->getName()); } } diff --git a/app/code/Magento/Ui/Controller/Adminhtml/Bookmark/Save.php b/app/code/Magento/Ui/Controller/Adminhtml/Bookmark/Save.php index 2128543535b2b0d6823d60046ef60c21001913ce..dc3dca608612ef69c89354fdd8c86163596cbb2b 100644 --- a/app/code/Magento/Ui/Controller/Adminhtml/Bookmark/Save.php +++ b/app/code/Magento/Ui/Controller/Adminhtml/Bookmark/Save.php @@ -7,14 +7,18 @@ namespace Magento\Ui\Controller\Adminhtml\Bookmark; use Magento\Authorization\Model\UserContextInterface; use Magento\Backend\App\Action\Context; +use Magento\Framework\Json\DecoderInterface; use Magento\Framework\View\Element\UiComponentFactory; use Magento\Ui\Api\BookmarkManagementInterface; use Magento\Ui\Api\BookmarkRepositoryInterface; use Magento\Ui\Api\Data\BookmarkInterface; +use Magento\Ui\Api\Data\BookmarkInterfaceFactory; use Magento\Ui\Controller\Adminhtml\AbstractAction; /** * Class Save action + * + * @SuppressWarnings(PHPMD.CouplingBetweenObjects) */ class Save extends AbstractAction { @@ -38,7 +42,7 @@ class Save extends AbstractAction protected $bookmarkManagement; /** - * @var \Magento\Ui\Api\Data\BookmarkInterfaceFactory + * @var BookmarkInterfaceFactory */ protected $bookmarkFactory; @@ -47,27 +51,35 @@ class Save extends AbstractAction */ protected $userContext; + /** + * @var DecoderInterface + */ + protected $jsonDecoder; + /** * @param Context $context * @param UiComponentFactory $factory * @param BookmarkRepositoryInterface $bookmarkRepository * @param BookmarkManagementInterface $bookmarkManagement - * @param \Magento\Ui\Api\Data\BookmarkInterfaceFactory $bookmarkFactory + * @param BookmarkInterfaceFactory $bookmarkFactory * @param UserContextInterface $userContext + * @param DecoderInterface $jsonDecoder */ public function __construct( Context $context, UiComponentFactory $factory, BookmarkRepositoryInterface $bookmarkRepository, BookmarkManagementInterface $bookmarkManagement, - \Magento\Ui\Api\Data\BookmarkInterfaceFactory $bookmarkFactory, - UserContextInterface $userContext + BookmarkInterfaceFactory $bookmarkFactory, + UserContextInterface $userContext, + DecoderInterface $jsonDecoder ) { parent::__construct($context, $factory); $this->bookmarkRepository = $bookmarkRepository; $this->bookmarkManagement = $bookmarkManagement; $this->bookmarkFactory = $bookmarkFactory; $this->userContext = $userContext; + $this->jsonDecoder = $jsonDecoder; } /** @@ -78,7 +90,8 @@ class Save extends AbstractAction public function execute() { $bookmark = $this->bookmarkFactory->create(); - $data = $this->_request->getParam('data'); + $jsonData = $this->_request->getParam('data'); + $data = $this->jsonDecoder->decode($jsonData); $action = key($data); switch($action) { case self::ACTIVE_IDENTIFIER: @@ -90,7 +103,7 @@ class Save extends AbstractAction $bookmark, $action, $bookmark->getTitle(), - $data[$action] + $jsonData ); break; @@ -101,7 +114,7 @@ class Save extends AbstractAction $bookmark, $identifier, isset($data['label']) ? $data['label'] : '', - $data + $jsonData ); $this->updateCurrentBookmark($identifier); } @@ -119,13 +132,11 @@ class Save extends AbstractAction * @param BookmarkInterface $bookmark * @param string $identifier * @param string $title - * @param array $config + * @param string $config * @return void */ - protected function updateBookmark(BookmarkInterface $bookmark, $identifier, $title, array $config = []) + protected function updateBookmark(BookmarkInterface $bookmark, $identifier, $title, $config) { - $this->filterVars($config); - $updateBookmark = $this->checkBookmark($identifier); if ($updateBookmark !== false) { $bookmark = $updateBookmark; @@ -179,27 +190,4 @@ class Save extends AbstractAction return $result; } - - /** - * Filter boolean vars - * - * @param array $data - * @return void - */ - protected function filterVars(array & $data = []) - { - foreach ($data as & $value) { - if (is_array($value)) { - $this->filterVars($value); - } else { - if ($value == 'true') { - $value = true; - } elseif ($value == 'false') { - $value = false; - } elseif (is_numeric($value)) { - $value = (int) $value; - } - } - } - } } diff --git a/app/code/Magento/Ui/Model/Bookmark.php b/app/code/Magento/Ui/Model/Bookmark.php index 2a7c7791add8834c89b281f4b476674741fa7546..7ff285d93437af5e3aca4f8507952029d22ee0ff 100644 --- a/app/code/Magento/Ui/Model/Bookmark.php +++ b/app/code/Magento/Ui/Model/Bookmark.php @@ -5,8 +5,7 @@ */ namespace Magento\Ui\Model; -use Magento\Framework\Json\Decoder; -use Magento\Framework\Json\Encoder; +use Magento\Framework\Json\DecoderInterface; use Magento\Framework\Model\AbstractModel; use Magento\Framework\Model\Context; use Magento\Framework\Registry; @@ -20,18 +19,12 @@ use Magento\Ui\Model\Resource\Bookmark as ResourceBookmark; class Bookmark extends AbstractModel implements BookmarkInterface { /** - * @var Encoder - */ - protected $jsonEncoder; - - /** - * @var Decoder + * @var DecoderInterface */ protected $jsonDecoder; /** - * @param Encoder $jsonEncoder - * @param Decoder $jsonDecoder + * @param DecoderInterface $jsonDecoder * @param Context $context * @param Registry $registry * @param ResourceBookmark $resource @@ -43,11 +36,9 @@ class Bookmark extends AbstractModel implements BookmarkInterface Registry $registry, ResourceBookmark $resource, Collection $resourceCollection, - Encoder $jsonEncoder, - Decoder $jsonDecoder, + DecoderInterface $jsonDecoder, array $data = [] ) { - $this->jsonEncoder = $jsonEncoder; $this->jsonDecoder = $jsonDecoder; parent::__construct($context, $registry, $resource, $resourceCollection, $data); } @@ -211,12 +202,12 @@ class Bookmark extends AbstractModel implements BookmarkInterface /** * Set config * - * @param array $config + * @param string $config * @return $this */ public function setConfig($config) { - return $this->setData(self::CONFIG, $this->jsonEncoder->encode($config)); + return $this->setData(self::CONFIG, $config); } /** diff --git a/app/code/Magento/Ui/Test/Unit/Component/ExportButtonTest.php b/app/code/Magento/Ui/Test/Unit/Component/ExportButtonTest.php new file mode 100644 index 0000000000000000000000000000000000000000..0e65e804ce8583c7ab67147c31c46a575156edd7 --- /dev/null +++ b/app/code/Magento/Ui/Test/Unit/Component/ExportButtonTest.php @@ -0,0 +1,62 @@ +<?php +/** + * Copyright © 2015 Magento. All rights reserved. + * See COPYING.txt for license details. + */ +namespace Magento\Ui\Test\Unit\Component; + +use Magento\Framework\TestFramework\Unit\Helper\ObjectManager; + +/** + * Class ExportButtonTest + */ +class ExportButtonTest extends \PHPUnit_Framework_TestCase +{ + /** + * @var \PHPUnit_Framework_MockObject_MockObject + */ + protected $urlBuilderMock; + + /** + * @var ObjectManager + */ + protected $objectManager; + + /** + * @var \Magento\Ui\Component\ExportButton + */ + protected $model; + + protected function setUp() + { + $this->objectManager = new ObjectManager($this); + + $this->urlBuilderMock = $this->getMockBuilder('Magento\Framework\UrlInterface') + ->disableOriginalConstructor() + ->getMock(); + $this->model = $this->objectManager->getObject( + 'Magento\Ui\Component\ExportButton', + [ + 'urlBuilder' => $this->urlBuilderMock + ] + ); + } + + public function testGetComponentName() + { + $this->assertEquals(\Magento\Ui\Component\ExportButton::NAME, $this->model->getComponentName()); + } + + public function testPrepare() + { + $option = ['label' => 'test label', 'value' => 'test value', 'url' => 'test_url']; + $data = ['config' => ['options' => [$option]]]; + $this->model->setData($data); + + $this->urlBuilderMock->expects($this->once()) + ->method('getUrl') + ->with('test_url') + ->willReturnArgument(0); + $this->assertNull($this->model->prepare()); + } +} diff --git a/app/code/Magento/Ui/Test/Unit/Component/Filters/Type/DateRangeTest.php b/app/code/Magento/Ui/Test/Unit/Component/Filters/Type/DateRangeTest.php index 2d79d212eee94e69b828beba77557b9347bcf429..af5c717a86fc61dd2b51bd54844ac06c2cc094f7 100644 --- a/app/code/Magento/Ui/Test/Unit/Component/Filters/Type/DateRangeTest.php +++ b/app/code/Magento/Ui/Test/Unit/Component/Filters/Type/DateRangeTest.php @@ -105,7 +105,7 @@ class DateRangeTest extends \PHPUnit_Framework_TestCase ); $dataProvider->expects($this->any()) ->method('addFilter') - ->with($name, $expectedCondition); + ->with($expectedCondition, $name); $this->contextMock->expects($this->any()) ->method('getDataProvider') diff --git a/app/code/Magento/Ui/Test/Unit/Component/Filters/Type/DateTest.php b/app/code/Magento/Ui/Test/Unit/Component/Filters/Type/DateTest.php index c692455000430201a501d8f5fa4f8576d3c0dc75..e249f54885f05ec4da975c3f5e4383cf562f83ff 100644 --- a/app/code/Magento/Ui/Test/Unit/Component/Filters/Type/DateTest.php +++ b/app/code/Magento/Ui/Test/Unit/Component/Filters/Type/DateTest.php @@ -105,7 +105,7 @@ class DateTest extends \PHPUnit_Framework_TestCase ); $dataProvider->expects($this->any()) ->method('addFilter') - ->with($name, $expectedCondition); + ->with($expectedCondition, $name); $this->contextMock->expects($this->any()) ->method('getDataProvider') diff --git a/app/code/Magento/Ui/Test/Unit/Component/Filters/Type/InputTest.php b/app/code/Magento/Ui/Test/Unit/Component/Filters/Type/InputTest.php index 37ec5ef6f4e090e82a2adb8ebf17edd6d56ce74b..a5247faaec4bbaa26100d44717b579c3738c4a7e 100644 --- a/app/code/Magento/Ui/Test/Unit/Component/Filters/Type/InputTest.php +++ b/app/code/Magento/Ui/Test/Unit/Component/Filters/Type/InputTest.php @@ -104,7 +104,7 @@ class InputTest extends \PHPUnit_Framework_TestCase ); $dataProvider->expects($this->any()) ->method('addFilter') - ->with($name, $expectedCondition); + ->with($expectedCondition, $name); $this->contextMock->expects($this->any()) ->method('getDataProvider') diff --git a/app/code/Magento/Ui/Test/Unit/Component/Filters/Type/RangeTest.php b/app/code/Magento/Ui/Test/Unit/Component/Filters/Type/RangeTest.php index 6edf06ab58f4f3f27666e1497fdd02d0fded5301..d73ee93c474be0f7f7de69aa734f7110de53f9c1 100644 --- a/app/code/Magento/Ui/Test/Unit/Component/Filters/Type/RangeTest.php +++ b/app/code/Magento/Ui/Test/Unit/Component/Filters/Type/RangeTest.php @@ -91,7 +91,7 @@ class RangeTest extends \PHPUnit_Framework_TestCase ); $dataProvider->expects($this->any()) ->method('addFilter') - ->with($name, $expectedCondition); + ->with($expectedCondition, $name); $this->contextMock->expects($this->any()) ->method('getDataProvider') diff --git a/app/code/Magento/Ui/Test/Unit/Component/Filters/Type/SelectTest.php b/app/code/Magento/Ui/Test/Unit/Component/Filters/Type/SelectTest.php index 92c8f7e1fbd2caed14ad9694819aebb5e87c4b3c..4ea56669f2d923ebda99af642717f988be079c02 100644 --- a/app/code/Magento/Ui/Test/Unit/Component/Filters/Type/SelectTest.php +++ b/app/code/Magento/Ui/Test/Unit/Component/Filters/Type/SelectTest.php @@ -104,7 +104,7 @@ class SelectTest extends \PHPUnit_Framework_TestCase ); $dataProvider->expects($this->any()) ->method('addFilter') - ->with($name, $expectedCondition); + ->with($expectedCondition, $name); $this->contextMock->expects($this->any()) ->method('getDataProvider') diff --git a/app/code/Magento/Ui/etc/ui_components.xsd b/app/code/Magento/Ui/etc/ui_components.xsd index 17a80e2f4ac37e725e061d347aeb431e23162244..862f0a82573db274e6cf4a5307c3a318bf378218 100644 --- a/app/code/Magento/Ui/etc/ui_components.xsd +++ b/app/code/Magento/Ui/etc/ui_components.xsd @@ -109,6 +109,11 @@ <xs:extension base="input"/> </xs:complexContent> </xs:complexType> + <xs:complexType name="filterSearch"> + <xs:complexContent> + <xs:extension base="input"/> + </xs:complexContent> + </xs:complexType> <xs:complexType name="container"> <xs:complexContent> <xs:extension base="ui_element"> @@ -296,6 +301,15 @@ </xs:extension> </xs:complexContent> </xs:complexType> + <xs:complexType name="exportButton" xml:base="ui_element"> + <xs:complexContent> + <xs:extension base="ui_element"> + <xs:choice minOccurs="0" maxOccurs="unbounded"> + <xs:group ref="configurable"/> + </xs:choice> + </xs:extension> + </xs:complexContent> + </xs:complexType> <!-- Global groups --> <xs:group name="configurable"> <xs:sequence> diff --git a/app/code/Magento/Ui/etc/ui_configuration.xsd b/app/code/Magento/Ui/etc/ui_configuration.xsd index 22f503046e315c03671266f81a9c1ae63652fd38..97a0cafb0f6c1e433afcdef5683bd63df12fa723 100644 --- a/app/code/Magento/Ui/etc/ui_configuration.xsd +++ b/app/code/Magento/Ui/etc/ui_configuration.xsd @@ -32,6 +32,8 @@ <xs:element type="dataSource" name="dataSource"/> <xs:element type="argumentType" name="argument"/> <xs:element type="bookmark" name="bookmark"/> + <xs:element name="filterSearch" type="filterSearch" /> + <xs:element type="exportButton" name="exportButton"/> </xs:choice> </xs:extension> </xs:complexContent> @@ -85,7 +87,6 @@ <xs:complexContent> <xs:extension base="filters"> <xs:choice minOccurs="0" maxOccurs="unbounded"> - <xs:element name="filterDate" type="filterDate" /> <xs:element name="filterInput" type="filterInput" /> <xs:element name="filterRange" type="filterRangeConfiguration" /> <xs:element name="filterSelect" type="filterSelect" /> diff --git a/app/code/Magento/Ui/etc/ui_definition.xsd b/app/code/Magento/Ui/etc/ui_definition.xsd index f0154eecb99647f17d7bb96c9c9c7c554806f0d1..cc055ef94b91f4e0138bd43af108b9ce04df86bc 100644 --- a/app/code/Magento/Ui/etc/ui_definition.xsd +++ b/app/code/Magento/Ui/etc/ui_definition.xsd @@ -30,6 +30,7 @@ <xs:element type="columns" name="columns"/> <xs:element type="column" name="column"/> <xs:element type="filterSelect" name="filterSelect"/> + <xs:element type="filterSearch" name="filterSearch"/> <xs:element type="filterRange" name="filterRange"/> <xs:element type="filterInput" name="filterInput"/> <xs:element type="filterDate" name="filterDate"/> @@ -50,6 +51,7 @@ <xs:element type="nav" name="nav"/> <xs:element type="actions" name="actions"/> <xs:element type="bookmark" name="bookmark"/> + <xs:element type="exportButton" name="exportButton"/> </xs:all> </xs:complexType> <!-- Custom configuration --> diff --git a/app/code/Magento/Ui/view/base/ui_component/etc/definition.xml b/app/code/Magento/Ui/view/base/ui_component/etc/definition.xml index df5cfa21eca0a080805e940d75726c60f188141f..092ddb8d4053e2025ff9e1ea6ef052967bbad09c 100644 --- a/app/code/Magento/Ui/view/base/ui_component/etc/definition.xml +++ b/app/code/Magento/Ui/view/base/ui_component/etc/definition.xml @@ -34,6 +34,15 @@ </item> </argument> </filters> + <filterSearch class="Magento\Ui\Component\Filters\Type\Search"> + <argument name="data" xsi:type="array"> + <item name="config" xsi:type="array"> + <item name="component" xsi:type="string">Magento_Ui/js/grid/search/search</item> + <item name="displayArea" xsi:type="string">dataGridFilters</item> + + </item> + </argument> + </filterSearch> <filterSelect class="Magento\Ui\Component\Filters\Type\Select"> <argument name="data" xsi:type="array"> <item name="config" xsi:type="array"> @@ -62,7 +71,6 @@ </item> </argument> </filterDate> - <container class="Magento\Ui\Component\Container"> <argument name="data" xsi:type="array"> <item name="js_config" xsi:type="array"> @@ -263,4 +271,12 @@ <argument name="data" xsi:type="array"> </argument> </bookmark> + <exportButton class="Magento\Ui\Component\ExportButton"> + <argument name="data" xsi:type="array"> + <item name="template" xsi:type="string">templates/export/button</item> + <item name="js_config" xsi:type="array"> + <item name="component" xsi:type="string">Magento_Ui/js/grid/export</item> + </item> + </argument> + </exportButton> </components> diff --git a/app/code/Magento/Ui/view/base/ui_component/templates/export/button.xhtml b/app/code/Magento/Ui/view/base/ui_component/templates/export/button.xhtml new file mode 100644 index 0000000000000000000000000000000000000000..d370d9ee333fa6d98f261a64cc1b1897476333dc --- /dev/null +++ b/app/code/Magento/Ui/view/base/ui_component/templates/export/button.xhtml @@ -0,0 +1,12 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!-- +/** + * Copyright © 2015 Magento. All rights reserved. + * See COPYING.txt for license details. + */ +--> +<div xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../../../../../../Ui/etc/ui_template.xsd"> + <div data-bind="scope: '{{getName()}}.areas'"> + <!-- ko template: getTemplate() --><!-- /ko --> + </div> +</div> \ No newline at end of file diff --git a/app/code/Magento/Ui/view/base/web/js/grid/controls/bookmarks/bookmarks.js b/app/code/Magento/Ui/view/base/web/js/grid/controls/bookmarks/bookmarks.js index e2dfe8c64b3cfe9f63faf916a61e73a1b80ffe01..a684f5eece069704ff3361ef02eb43c7d98f6a04 100644 --- a/app/code/Magento/Ui/view/base/web/js/grid/controls/bookmarks/bookmarks.js +++ b/app/code/Magento/Ui/view/base/web/js/grid/controls/bookmarks/bookmarks.js @@ -14,7 +14,7 @@ define([ /** * Removes 'current' namespace from a 'path' string. * - * @param {String} path + * @param {String} path * @returns {String} Path without namespace. */ function removeStateNs(path) { diff --git a/app/code/Magento/Ui/view/base/web/js/grid/controls/bookmarks/storage.js b/app/code/Magento/Ui/view/base/web/js/grid/controls/bookmarks/storage.js index bba2a7cbfc1695a2d6a51b54a7f9ebc699f6ace1..ac0656ec5a4636d838f293fbd76f9c3e736de5ae 100644 --- a/app/code/Magento/Ui/view/base/web/js/grid/controls/bookmarks/storage.js +++ b/app/code/Magento/Ui/view/base/web/js/grid/controls/bookmarks/storage.js @@ -39,19 +39,17 @@ define([ */ set: function (path, value) { var property = removeNs(this.namespace, path), + data = {}, config; - config = { - data: { - data: {} - } - }; - - utils.nested(config.data.data, property, value); + utils.nested(data, property, value); config = utils.extend({ - url: this.saveUrl - }, this.ajaxSettings, config); + url: this.saveUrl, + data: { + data: JSON.stringify(data) + } + }, this.ajaxSettings); $.ajax(config); }, @@ -65,15 +63,12 @@ define([ var property = removeNs(this.namespace, path), config; - config = { + config = utils.extend({ + url: this.deleteUrl, data: { data: property } - }; - - config = utils.extend({ - url: this.deleteUrl - }, this.ajaxSettings, config); + }, this.ajaxSettings); $.ajax(config); } diff --git a/app/code/Magento/Ui/view/base/web/js/grid/export.js b/app/code/Magento/Ui/view/base/web/js/grid/export.js new file mode 100644 index 0000000000000000000000000000000000000000..d94649e3cd1d1f009e51bfb72c74f47a9132e929 --- /dev/null +++ b/app/code/Magento/Ui/view/base/web/js/grid/export.js @@ -0,0 +1,55 @@ +/** + * Copyright © 2015 Magento. All rights reserved. + * See COPYING.txt for license details. + */ +define([ + 'jquery', + 'underscore', + 'ko', + 'Magento_Ui/js/lib/collapsible' +], function ($, _, ko, Collapsible) { + 'use strict'; + + return Collapsible.extend({ + + defaults: { + template: 'ui/grid/exportButton', + checked: '', + params: { + filters: {} + }, + filtersConfig: { + provider: '${ $.provider }', + path: 'params.filters' + }, + imports: { + 'params.filters': '${ $.filtersConfig.provider }:${ $.filtersConfig.path }' + } + }, + + initialize: function () { + this._super() + .observe('checked') + .initChecked(); + }, + + initChecked: function () { + if (!this.checked()) { + this.checked( + this.options[0].value + ); + } + return this; + }, + + applyOption: function () { + var option = _.filter(this.options, function (op) { + return op.value === this.checked(); + }, this)[0]; + + location.href = option.url + '?' + $.param({ + 'filters': this.params.filters + }); + } + }); +}); diff --git a/app/code/Magento/Ui/view/base/web/js/grid/filters/filters.js b/app/code/Magento/Ui/view/base/web/js/grid/filters/filters.js index 7cdb49ff39e1c2c414ec93c3b39d2586eeabfaee..13f6704f34d37fb5ae8773e7c2628d402a28a5dd 100644 --- a/app/code/Magento/Ui/view/base/web/js/grid/filters/filters.js +++ b/app/code/Magento/Ui/view/base/web/js/grid/filters/filters.js @@ -40,12 +40,8 @@ define([ return Collapsible.extend({ defaults: { template: 'ui/grid/filters/filters', - applied: { - placeholder: true - }, - filters: { - placeholder: true - }, + applied: {}, + filters: {}, chipsConfig: { name: '${ $.name }_chips', provider: '${ $.chipsConfig.name }', @@ -155,11 +151,25 @@ define([ * @returns {Filters} Chainable. */ cancel: function () { + this.convertToObject(); this.set('filters', utils.copy(this.applied)); return this; }, + /** + * Convert empty array to empty object. + * + * @returns {Filters} Chainable. + */ + convertToObject: function() { + if ( _.isArray(this.applied) && _.isEmpty(this.applied) ) { + this.applied = {}; + } + + return this; + }, + /** * Tells wether filters pannel should be opened. * diff --git a/app/code/Magento/Ui/view/base/web/js/grid/massactions.js b/app/code/Magento/Ui/view/base/web/js/grid/massactions.js index 21e86a6d640b2f43aab310774f09ce31d69583de..b6ba29dfb9f4349995d88a95da33afd41c69c10f 100644 --- a/app/code/Magento/Ui/view/base/web/js/grid/massactions.js +++ b/app/code/Magento/Ui/view/base/web/js/grid/massactions.js @@ -141,16 +141,17 @@ define([ * Default action callback. Sends selections data * via POST request. * - * @param {Object} data - Selections data. * @param {Object} action - Action data. + * @param {Object} data - Selections data. */ - defaultCallback: function (data, action) { - var selections = {}; + defaultCallback: function (action, data) { + var itemsType = data.excludeMode ? 'excluded' : 'selected', + selections = {}; + + selections[itemsType] = data[itemsType]; - if (data.excludeMode) { - selections.excluded = data.excluded; - } else { - selections.selected = data.selected; + if (!selections[itemsType].length) { + selections[itemsType] = false; } utils.submit({ diff --git a/app/code/Magento/Ui/view/base/web/templates/grid/exportButton.html b/app/code/Magento/Ui/view/base/web/templates/grid/exportButton.html new file mode 100644 index 0000000000000000000000000000000000000000..985ae16e58dca1e68706ccc039b1beef01b04674 --- /dev/null +++ b/app/code/Magento/Ui/view/base/web/templates/grid/exportButton.html @@ -0,0 +1,55 @@ +<!-- +/** + * Copyright © 2015 Magento. All rights reserved. + * See COPYING.txt for license details. + */ +--> + +<div + class="admin__action-dropdown-wrap admin__data-grid-action-export" + data-bind="css: {_active: opened, _disabled: !collapsible}, outerClick: close"> + <button + class="admin__action-dropdown" + type="button" + data-bind="click: toggleOpened" + data-toggle="dropdown" + aria-haspopup="true"> + <span class="admin__action-dropdown-text" data-bind="text: $t('Export')"></span> + </button> + <div class="admin__action-dropdown-menu admin__data-grid-action-export-menu"> + <!-- ko foreach: options --> + <div class="admin__field admin__field-option"> + <input + class="admin__control-radio" + data-bind=" + attr: { + id: 'export-field-' + value + $index(), + name: 'export' + }, + checkedValue: value, + checked: $parent.checked" + type="radio"/> + <label + class="admin__field-label" + data-bind=" + text: label, + attr: { + for: 'export-field-' + value + $index() + }"></label> + </div> + <!-- /ko --> + <div class="admin__action-dropdown-footer-main-actions"> + <button + class="action-tertiary" + data-bind="click: close" + type="button"> + <span data-bind="text: $t('Cancel')"></span> + </button> + <button class="action-secondary" + type="button" + data-bind="click: applyOption"> + <span data-bind="text: $t('Export')"></span> + </button> + </div> + </div> +</div> diff --git a/app/code/Magento/Ui/view/base/web/templates/grid/search/search.html b/app/code/Magento/Ui/view/base/web/templates/grid/search/search.html index 0187fb782f1e6d82a3a2bf6aa0a68e49b76c09df..14aebeaedaeb577107b0e3d79d06aea717170395 100644 --- a/app/code/Magento/Ui/view/base/web/templates/grid/search/search.html +++ b/app/code/Magento/Ui/view/base/web/templates/grid/search/search.html @@ -4,7 +4,7 @@ * See COPYING.txt for license details. */ --> -<div class="data-grid-search-control-wrap" style="display: none;"> +<div class="data-grid-search-control-wrap"> <input class="admin__control-text data-grid-search-control" data-bind=" diff --git a/app/design/adminhtml/Magento/backend/Magento_Ui/web/css/source/module/_data-grid.less b/app/design/adminhtml/Magento/backend/Magento_Ui/web/css/source/module/_data-grid.less index 720e23290b460b82f43f609f2f18b6b5cc602f53..91673d9297d49aec92101857ba86d3a5a77e85d1 100644 --- a/app/design/adminhtml/Magento/backend/Magento_Ui/web/css/source/module/_data-grid.less +++ b/app/design/adminhtml/Magento/backend/Magento_Ui/web/css/source/module/_data-grid.less @@ -268,6 +268,7 @@ .data-grid-multiselect-cell { padding: @data-grid-th__padding-horizontal @data-grid-th__padding-vertical @data-grid-th__padding-horizontal - .1rem; text-align: center; + vertical-align: middle; } .data-grid-actions-cell { padding-left: @data-grid-cell__padding-horizontal * 2; diff --git a/app/design/adminhtml/Magento/backend/Magento_Ui/web/css/source/module/data-grid/_data-grid-header.less b/app/design/adminhtml/Magento/backend/Magento_Ui/web/css/source/module/data-grid/_data-grid-header.less index a2dce53bec754a38a7e2ac3f48dc2a609d60ebc4..cb96780369228939687954109189008d6a0b1d48 100644 --- a/app/design/adminhtml/Magento/backend/Magento_Ui/web/css/source/module/data-grid/_data-grid-header.less +++ b/app/design/adminhtml/Magento/backend/Magento_Ui/web/css/source/module/data-grid/_data-grid-header.less @@ -16,6 +16,7 @@ // Actions group @import 'data-grid-header/_data-grid-action-bookmarks.less'; @import 'data-grid-header/_data-grid-action-columns.less'; +@import 'data-grid-header/_data-grid-action-export.less'; // // Variables diff --git a/app/design/adminhtml/Magento/backend/Magento_Ui/web/css/source/module/data-grid/data-grid-header/_data-grid-action-columns.less b/app/design/adminhtml/Magento/backend/Magento_Ui/web/css/source/module/data-grid/data-grid-header/_data-grid-action-columns.less index 9789fc82cddf8fd3dbaa272037756ab2b15b1e4f..0a21d02bf3765877638e9ff3c57f918061539d5d 100644 --- a/app/design/adminhtml/Magento/backend/Magento_Ui/web/css/source/module/data-grid/data-grid-header/_data-grid-action-columns.less +++ b/app/design/adminhtml/Magento/backend/Magento_Ui/web/css/source/module/data-grid/data-grid-header/_data-grid-action-columns.less @@ -33,7 +33,6 @@ &:extend(.abs-icon all); content: @icon-systems__content; font-size: 1.8rem; // Static - left: .3rem; margin-right: @action__outer-indent; vertical-align: top; } diff --git a/app/design/adminhtml/Magento/backend/Magento_Ui/web/css/source/module/data-grid/data-grid-header/_data-grid-action-export.less b/app/design/adminhtml/Magento/backend/Magento_Ui/web/css/source/module/data-grid/data-grid-header/_data-grid-action-export.less new file mode 100644 index 0000000000000000000000000000000000000000..676ae2ce432925229dc7cbd15f409d57b6ae53c8 --- /dev/null +++ b/app/design/adminhtml/Magento/backend/Magento_Ui/web/css/source/module/data-grid/data-grid-header/_data-grid-action-export.less @@ -0,0 +1,36 @@ +// /** +// * Copyright © 2015 Magento. All rights reserved. +// * See COPYING.txt for license details. +// */ + +// +// UI -> Data Grid -> Header -> Export +// _____________________________________________ + +.admin__data-grid-action-export { + &._active { + opacity: @component-modal__opacity; + z-index: @data-grid-action__z-index; + } + .admin__action-dropdown { + &:before { + &:extend(.abs-icon all); + content: @icon-export__content; + font-size: 1.7rem; // Static + left: .3rem; + margin-right: @action__outer-indent; + vertical-align: top; + } + } +} + +.admin__data-grid-action-export-menu { + padding-left: 2rem; + padding-right: 2rem; + padding-top: 1rem; + .admin__action-dropdown-footer-main-actions { + padding-bottom: 2rem; + padding-top: 2.5rem; + white-space: nowrap; + } +} diff --git a/app/design/adminhtml/Magento/backend/web/css/source/actions/_actions-multiselect.less b/app/design/adminhtml/Magento/backend/web/css/source/actions/_actions-multiselect.less index 597a73358d82bb119a8329b8c2d5a435339f1e0d..6bd43c41d6b123e568927abdc9e01dc66dbe0abc 100644 --- a/app/design/adminhtml/Magento/backend/web/css/source/actions/_actions-multiselect.less +++ b/app/design/adminhtml/Magento/backend/web/css/source/actions/_actions-multiselect.less @@ -15,6 +15,7 @@ padding-top: 1px; position: relative; height: @control-checkbox-radio__size; + width: @control-checkbox-radio__size * 2 - .1rem; z-index: @action-multiselect__z-index; &:hover { .admin__control-checkbox + label:before, diff --git a/dev/tests/functional/tests/app/Magento/Cms/Test/Block/Adminhtml/Page/Grid.php b/dev/tests/functional/tests/app/Magento/Cms/Test/Block/Adminhtml/Page/Grid.php index 53402d17d2a4654409dd5a2b7d6937ad7c58422f..4df3a511c2ceb1c2fa3b9066751170f286624e3f 100644 --- a/dev/tests/functional/tests/app/Magento/Cms/Test/Block/Adminhtml/Page/Grid.php +++ b/dev/tests/functional/tests/app/Magento/Cms/Test/Block/Adminhtml/Page/Grid.php @@ -66,7 +66,7 @@ class Grid extends DataGrid * * @var string */ - protected $previewCmsPage = ".//a[contains(@class, 'action-menu-item') and text() = '%s']"; + protected $previewCmsPage = "..//a[contains(@class, 'action-menu-item') and text() = '%s']"; /** * Search item and open it on Frontend. @@ -81,8 +81,10 @@ class Grid extends DataGrid $this->search($filter); $rowItem = $this->_rootElement->find($this->rowItem); if ($rowItem->isVisible()) { - $rowItem->find('.action-select')->click(); - $rowItem->find(sprintf($this->previewCmsPage, $itemName), Locator::SELECTOR_XPATH)->click(); + $selector = sprintf('//tr[td="%s"]//*[@class="action-select"]', $filter['title']); + $selectedRow = $this->_rootElement->find($selector, Locator::SELECTOR_XPATH); + $selectedRow->click(); + $selectedRow->find(sprintf($this->previewCmsPage, $itemName), Locator::SELECTOR_XPATH)->click(); } else { throw new \Exception('Searched item was not found.'); } diff --git a/dev/tests/functional/tests/app/Magento/Sales/Test/Block/Adminhtml/Order/Grid.php b/dev/tests/functional/tests/app/Magento/Sales/Test/Block/Adminhtml/Order/Grid.php index f402dd1f6273ce61c7acdb242a7ac34495b8fe14..ec2f37205a20d30340f86626c890b11b6b1bedde 100644 --- a/dev/tests/functional/tests/app/Magento/Sales/Test/Block/Adminhtml/Order/Grid.php +++ b/dev/tests/functional/tests/app/Magento/Sales/Test/Block/Adminhtml/Order/Grid.php @@ -6,41 +6,75 @@ namespace Magento\Sales\Test\Block\Adminhtml\Order; -use Magento\Backend\Test\Block\Widget\Grid as GridInterface; use Magento\Mtf\Client\Locator; +use Magento\Ui\Test\Block\Adminhtml\DataGrid; /** - * Sales order grid. + * Backend Data Grid for managing "Sales Order" entities. */ -class Grid extends GridInterface +class Grid extends DataGrid { /** - * 'Add New' order button. + * Filters array mapping. * - * @var string + * @var array */ - protected $addNewOrder = "../*[@class='page-actions']//*[@id='add']"; + protected $filters = [ + 'id' => [ + 'selector' => '[name="filters[increment_id]"]', + ], + 'status' => [ + 'selector' => '[name="filters[status]"]', + 'input' => 'select', + ], + 'purchase_date_from' => [ + 'selector' => '[name="filters[created_at][from]"]', + ], + 'purchase_date_to' => [ + 'selector' => '[name="filters[created_at][to]"]', + ], + 'base_grand_total_from' => [ + 'selector' => '[name="filters[base_grand_total][from]"]', + ], + 'base_grand_total_to' => [ + 'selector' => '[name="filters[base_grand_total][to]"]', + ], + 'purchased_gran_total_from' => [ + 'selector' => '[name="filters[grand_total][from]"]', + ], + 'purchased_gran_total_to' => [ + 'selector' => '[name="filters[grand_total][to]"]', + ], + 'purchase_point' => [ + 'selector' => '[name="filters[store_id]"]', + 'input' => 'selectstore' + ], + 'bill_to_name' => [ + 'selector' => '[name="filters[billing_name]"]' + ], + 'ship_to_name' => [ + 'selector' => '[name="filters[shipping_name]"]', + ] + ]; /** - * Purchase Point Filter selector. - * * @var string */ - protected $purchasePointFilter = '//*[@data-ui-id="widget-grid-column-filter-store-0-filter-store-id"]'; + protected $createNewOrder = '[data-ui-id="add-button"]'; /** - * Purchase Point Filter option group elements selector. + * Purchase Point Filter selector. * * @var string */ - protected $purchasePointOptGroup = '//*[@data-ui-id="widget-grid-column-filter-store-0-filter-store-id"]/optgroup'; + protected $purchasePointFilter = '[name="filters[store_id]"]'; /** * Order Id td selector. * * @var string */ - protected $editLink = 'td[class*=col-action] a'; + protected $editLink = 'a.action-menu-item'; /** * First row selector. @@ -49,27 +83,12 @@ class Grid extends GridInterface */ protected $firstRowSelector = '//tbody/tr[1]//a'; - /** - * Filters array mapping. - * - * @var array - */ - protected $filters = [ - 'id' => [ - 'selector' => 'input[name="real_order_id"]', - ], - 'status' => [ - 'selector' => 'select[name="status"]', - 'input' => 'select', - ], - ]; - /** * Start to create new order. */ public function addNewOrder() { - $this->_rootElement->find($this->addNewOrder, Locator::SELECTOR_XPATH)->click(); + $this->_rootElement->find($this->createNewOrder)->click(); } /** @@ -79,12 +98,13 @@ class Grid extends GridInterface */ public function getPurchasePointStoreGroups() { - $storeGroupElements = $this->_rootElement->find($this->purchasePointFilter, Locator::SELECTOR_XPATH) - ->getElements('.//optgroup[./option]', Locator::SELECTOR_XPATH); + $this->openFilterBlock(); + $storeGroupElements = $this->_rootElement->find($this->purchasePointFilter) + ->getElements('//option/preceding-sibling::optgroup[1]', Locator::SELECTOR_XPATH); $result = []; foreach ($storeGroupElements as $storeGroupElement) { - $result[] = trim($storeGroupElement->getAttribute('label'), ' '); + $result[] = trim($storeGroupElement->getAttribute('label')); } return $result; diff --git a/dev/tests/functional/tests/app/Magento/Sales/Test/Page/Adminhtml/OrderIndex.xml b/dev/tests/functional/tests/app/Magento/Sales/Test/Page/Adminhtml/OrderIndex.xml index cc43bf98007a00ce7a997de7e158816ae41c5a9c..ad56dea2c043b559305be1fb6290c259afac2c99 100644 --- a/dev/tests/functional/tests/app/Magento/Sales/Test/Page/Adminhtml/OrderIndex.xml +++ b/dev/tests/functional/tests/app/Magento/Sales/Test/Page/Adminhtml/OrderIndex.xml @@ -8,7 +8,7 @@ <config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../../../../../../../vendor/magento/mtf/etc/pages.xsd"> <page name="OrderIndex" area="Adminhtml" mca="sales/order/index" module="Magento_Sales"> <block name="gridPageActions" class="Magento\Backend\Test\Block\GridPageActions" locator=".page-main-actions" strategy="css selector"/> - <block name="salesOrderGrid" class="Magento\Sales\Test\Block\Adminhtml\Order\Grid" locator="#sales_order_grid" strategy="css selector"/> + <block name="salesOrderGrid" class="Magento\Sales\Test\Block\Adminhtml\Order\Grid" locator=".admin__data-grid-outer-wrap" strategy="css selector"/> <block name="messagesBlock" class="Magento\Backend\Test\Block\Messages" locator="#messages" strategy="css selector"/> </page> </config> diff --git a/dev/tests/integration/testsuite/Magento/Sales/Controller/Adminhtml/OrderTest.php b/dev/tests/integration/testsuite/Magento/Sales/Controller/Adminhtml/OrderTest.php deleted file mode 100644 index 7198676eaf45c6ee1a25e8072a78f106280417c1..0000000000000000000000000000000000000000 --- a/dev/tests/integration/testsuite/Magento/Sales/Controller/Adminhtml/OrderTest.php +++ /dev/null @@ -1,107 +0,0 @@ -<?php -/** - * Copyright © 2015 Magento. All rights reserved. - * See COPYING.txt for license details. - */ -namespace Magento\Sales\Controller\Adminhtml; - -/** - * @magentoAppArea adminhtml - */ -class OrderTest extends \Magento\TestFramework\TestCase\AbstractBackendController -{ - public function testIndexAction() - { - $this->dispatch('backend/sales/order/index'); - $this->assertContains('No records found.', $this->getResponse()->getBody()); - } - - /** - * @magentoDataFixture Magento/Sales/_files/order.php - */ - public function testIndexActionWithOrder() - { - $this->dispatch('backend/sales/order/index'); - $this->assertRegExp( - '/<span.*id="sales_order_grid-total-count".*>\s*1\s*<\/span>\s*records found.\s*/', - $this->getResponse()->getBody() - ); - } - - /** - * @magentoDataFixture Magento/Sales/_files/order.php - */ - public function testOrderViewAction() - { - /** @var $order \Magento\Sales\Model\Order */ - $order = \Magento\TestFramework\Helper\Bootstrap::getObjectManager()->create('Magento\Sales\Model\Order'); - $order->load('100000001', 'increment_id'); - $this->dispatch('backend/sales/order/view/order_id/' . $order->getId()); - $this->assertContains('Los Angeles', $this->getResponse()->getBody()); - } - - public function testAddressActionNonExistingAddress() - { - $this->getRequest()->setParam('address_id', -1); - $this->dispatch('backend/sales/order/address'); - $this->assertRedirect(); - } - - /** - * @magentoDataFixture Magento/Sales/_files/address.php - */ - public function testAddressActionNoVAT() - { - /** @var $address \Magento\Sales\Model\Order\Address */ - $address = \Magento\TestFramework\Helper\Bootstrap::getObjectManager()->create( - 'Magento\Sales\Model\Order\Address' - ); - $address->load('a_unique_firstname', 'firstname'); - $this->getRequest()->setParam('address_id', $address->getId()); - $this->dispatch('backend/sales/order/address'); - $html = $this->getResponse()->getBody(); - $prohibitedStrings = ['validate-vat', 'validateVat', 'Validate VAT']; - foreach ($prohibitedStrings as $string) { - $this->assertNotContains($string, $html, 'VAT button must not be shown while editing address', true); - } - } - - /** - * Test add comment to order - * - * @param $status - * @param $comment - * @param $response - * @magentoDataFixture Magento/Sales/_files/order.php - * @dataProvider getAddCommentData - */ - public function testAddCommentAction($status, $comment, $response) - { - /** @var $order \Magento\Sales\Model\Order */ - $order = \Magento\TestFramework\Helper\Bootstrap::getObjectManager()->create('Magento\Sales\Model\Order'); - $order->load('100000001', 'increment_id'); - - $this->getRequest()->setPostValue(['history' => ['status' => $status, 'comment' => $comment]]); - $this->dispatch('backend/sales/order/addComment/order_id/' . $order->getId()); - $html = $this->getResponse()->getBody(); - - $this->assertContains($response, $html); - } - - /** - * Get Add Comment Data - * - * @return array - */ - public function getAddCommentData() - { - return [ - ['status' => 'pending', 'comment' => 'Test comment', 'response' => 'Test comment'], - [ - 'status' => 'processing', - 'comment' => '', - 'response' => '{"error":true,"message":"Please enter a comment."}' - ] - ]; - } -} diff --git a/lib/internal/Magento/Framework/App/Response/Http/FileFactory.php b/lib/internal/Magento/Framework/App/Response/Http/FileFactory.php index 168a43eedd375211d68587abfc2413cc38605961..b09632551f27bf3ca4012a756e5df46fc694d1b7 100644 --- a/lib/internal/Magento/Framework/App/Response/Http/FileFactory.php +++ b/lib/internal/Magento/Framework/App/Response/Http/FileFactory.php @@ -72,7 +72,6 @@ class FileFactory $contentLength = $dir->stat($file)['size']; } } - $this->_response->setHttpResponseCode(200) ->setHeader('Pragma', 'public', true) ->setHeader('Cache-Control', 'must-revalidate, post-check=0, pre-check=0', true) @@ -82,22 +81,25 @@ class FileFactory ->setHeader('Last-Modified', date('r'), true); if ($content !== null) { + $this->_response->sendHeaders(); if ($isFile) { - $this->_response->sendHeaders(); $stream = $dir->openFile($file, 'r'); while (!$stream->eof()) { echo $stream->read(1024); } - $stream->close(); - flush(); - if (!empty($content['rm'])) { - $dir->delete($file); - } - $this->callExit(); } else { - $this->_response->clearBody(); - $this->_response->setBody($content); + $dir->writeFile($fileName, $content); + $stream = $dir->openFile($fileName, 'r'); + while (!$stream->eof()) { + echo $stream->read(1024); + } + } + $stream->close(); + flush(); + if (!empty($content['rm'])) { + $dir->delete($file); } + $this->callExit(); } return $this->_response; } diff --git a/lib/internal/Magento/Framework/App/Test/Unit/Response/Http/FileFactoryTest.php b/lib/internal/Magento/Framework/App/Test/Unit/Response/Http/FileFactoryTest.php index 15932e66d929e173c51b890e90110a57a6b9e440..e90a7126f516370746388a3d8e8dfe2a0f18918c 100644 --- a/lib/internal/Magento/Framework/App/Test/Unit/Response/Http/FileFactoryTest.php +++ b/lib/internal/Magento/Framework/App/Test/Unit/Response/Http/FileFactoryTest.php @@ -201,31 +201,22 @@ class FileFactoryTest extends \PHPUnit_Framework_TestCase ->with(200) ->will($this->returnSelf()); $this->responseMock->expects($this->once()) - ->method('clearBody') - ->will($this->returnSelf()); - $this->responseMock->expects($this->once()) - ->method('setBody') - ->will($this->returnSelf()); - $this->responseMock->expects($this->never()) ->method('sendHeaders') ->will($this->returnSelf()); - + $this->dirMock->expects($this->once()) + ->method('writeFile') + ->with('fileName', 'content', 'w+'); $streamMock = $this->getMockBuilder('Magento\Framework\Filesystem\File\WriteInterface') ->disableOriginalConstructor()->getMock(); - $this->dirMock->expects($this->never()) + $this->dirMock->expects($this->once()) ->method('openFile') ->will($this->returnValue($streamMock)); - $this->dirMock->expects($this->never()) - ->method('delete') - ->will($this->returnValue($streamMock)); - $streamMock->expects($this->never()) + $streamMock->expects($this->once()) ->method('eof') - ->will($this->returnValue(false)); - $streamMock->expects($this->never()) - ->method('read'); - $streamMock->expects($this->never()) + ->will($this->returnValue(true)); + $streamMock->expects($this->once()) ->method('close'); - $this->assertSame($this->responseMock, $this->getModel()->create('fileName', 'content')); + $this->getModelMock()->create('fileName', 'content'); } /** diff --git a/lib/internal/Magento/Framework/View/Element/UiComponent/DataProvider/DataProvider.php b/lib/internal/Magento/Framework/View/Element/UiComponent/DataProvider/DataProvider.php new file mode 100644 index 0000000000000000000000000000000000000000..12d7a1425850ea19464bb73f08751a2e43bf93f7 --- /dev/null +++ b/lib/internal/Magento/Framework/View/Element/UiComponent/DataProvider/DataProvider.php @@ -0,0 +1,273 @@ +<?php +/** + * Copyright © 2015 Magento. All rights reserved. + * See COPYING.txt for license details. + */ + +namespace Magento\Framework\View\Element\UiComponent\DataProvider; + +use Magento\Framework\Model\Resource\Db\Collection\AbstractCollection as Collection; + +/** + * Class DataProvider + */ +class DataProvider implements DataProviderInterface +{ + /** + * Data Provider name + * + * @var string + */ + protected $name; + + /** + * Data Provider Primary Identifier name + * + * @var string + */ + protected $primaryFieldName; + + /** + * Data Provider Request Parameter Identifier name + * + * @var string + */ + protected $requestFieldName; + + /** + * @var Collection + */ + protected $collection; + + /** + * @var array + */ + protected $meta = []; + + /** + * Provider configuration data + * + * @var array + */ + protected $data = []; + + /** + * @var FilterPool + */ + protected $filterPool; + + /** + * @param string $name + * @param string $primaryFieldName + * @param string $requestFieldName + * @param Collection $collection + * @param FilterPool $filterPool + * @param array $meta + * @param array $data + */ + public function __construct( + $name, + $primaryFieldName, + $requestFieldName, + Collection $collection, + FilterPool $filterPool, + array $meta = [], + array $data = [] + ) { + $this->name = $name; + $this->primaryFieldName = $primaryFieldName; + $this->requestFieldName = $requestFieldName; + $this->filterPool = $filterPool; + $this->collection = $collection; + $this->meta = $meta; + $this->data = $data; + } + + /** + * @return Collection + */ + public function getCollection() + { + return $this->collection; + } + + /** + * Get Data Provider name + * + * @return string + */ + public function getName() + { + return $this->name; + } + + /** + * Get primary field name + * + * @return string + */ + public function getPrimaryFieldName() + { + return $this->primaryFieldName; + } + + /** + * Get field name in request + * + * @return string + */ + public function getRequestFieldName() + { + return $this->requestFieldName; + } + + /** + * @return array + */ + public function getMeta() + { + return $this->meta; + } + + /** + * Get field Set meta info + * + * @param string $fieldSetName + * @return array + */ + public function getFieldSetMetaInfo($fieldSetName) + { + return isset($this->meta[$fieldSetName]) ? $this->meta[$fieldSetName] : []; + } + + /** + * @param string $fieldSetName + * @return array + */ + public function getFieldsMetaInfo($fieldSetName) + { + return isset($this->meta[$fieldSetName]['fields']) ? $this->meta[$fieldSetName]['fields'] : []; + } + + /** + * @param string $fieldSetName + * @param string $fieldName + * @return array + */ + public function getFieldMetaInfo($fieldSetName, $fieldName) + { + return isset($this->meta[$fieldSetName]['fields'][$fieldName]) + ? $this->meta[$fieldSetName]['fields'][$fieldName] + : []; + } + + /** + * @inheritdoc + */ + public function addFilter($condition, $field = null, $type = 'regular') + { + $this->filterPool->registerNewFilter($condition, $field, $type); + } + + /** + * Add field to select + * + * @param string|array $field + * @param string|null $alias + * @return void + */ + public function addField($field, $alias = null) + { + $this->collection->addFieldToSelect($field, $alias); + } + + /** + * self::setOrder() alias + * + * @param string $field + * @param string $direction + * @return void + */ + public function addOrder($field, $direction) + { + $this->collection->addOrder($field, $direction); + } + + /** + * Set Query limit + * + * @param int $offset + * @param int $size + * @return void + */ + public function setLimit($offset, $size) + { + $this->collection->setPageSize($size); + $this->collection->setCurPage($offset); + } + + /** + * Removes field from select + * + * @param string|null $field + * @param bool $isAlias Alias identifier + * @return void + */ + public function removeField($field, $isAlias = false) + { + $this->collection->removeFieldFromSelect($field, $isAlias); + } + + /** + * Removes all fields from select + * + * @return void + */ + public function removeAllFields() + { + $this->collection->removeAllFieldsFromSelect(); + } + + /** + * 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(); + } + + /** + * Get config data + * + * @return mixed + */ + public function getConfigData() + { + return isset($this->data['config']) ? $this->data['config'] : []; + } + + /** + * Set data + * + * @param mixed $config + * @return void + */ + public function setConfigData($config) + { + $this->data['config'] = $config; + } +} diff --git a/lib/internal/Magento/Framework/View/Element/UiComponent/DataProvider/DataProviderInterface.php b/lib/internal/Magento/Framework/View/Element/UiComponent/DataProvider/DataProviderInterface.php index e0390785dfa66de74a3a30c0297eb35452560527..0b4a9761eb907923b0027848d6347abbd122f211 100644 --- a/lib/internal/Magento/Framework/View/Element/UiComponent/DataProvider/DataProviderInterface.php +++ b/lib/internal/Magento/Framework/View/Element/UiComponent/DataProvider/DataProviderInterface.php @@ -91,11 +91,12 @@ interface DataProviderInterface /** * Add field filter to collection * - * @param string|array $field * @param string|int|array|null $condition - * @return void + * @param null|string|array $field + * @param string $type + * @return mixed */ - public function addFilter($field, $condition = null); + public function addFilter($condition, $field = null, $type = 'regular'); /** * Add ORDER BY to the end or to the beginning diff --git a/lib/internal/Magento/Framework/View/Element/UiComponent/DataProvider/FilterApplierInterface.php b/lib/internal/Magento/Framework/View/Element/UiComponent/DataProvider/FilterApplierInterface.php new file mode 100644 index 0000000000000000000000000000000000000000..cb2ecf07a0b0f9152993d364a009c538acc5a7fd --- /dev/null +++ b/lib/internal/Magento/Framework/View/Element/UiComponent/DataProvider/FilterApplierInterface.php @@ -0,0 +1,24 @@ +<?php +/** + * Copyright © 2015 Magento. All rights reserved. + * See COPYING.txt for license details. + */ + +namespace Magento\Framework\View\Element\UiComponent\DataProvider; + +use Magento\Framework\Data\Collection\AbstractDb; + +/** + * Interface FilterApplierInterface + */ +interface FilterApplierInterface +{ + /** + * Apply filter + * + * @param AbstractDb $collection + * @param array $filters + * @return mixed + */ + public function apply(AbstractDb $collection, $filters); +} diff --git a/lib/internal/Magento/Framework/View/Element/UiComponent/DataProvider/FilterPool.php b/lib/internal/Magento/Framework/View/Element/UiComponent/DataProvider/FilterPool.php new file mode 100644 index 0000000000000000000000000000000000000000..7ed363a5f98bd7b4bccc1c9e26db30ff22733c11 --- /dev/null +++ b/lib/internal/Magento/Framework/View/Element/UiComponent/DataProvider/FilterPool.php @@ -0,0 +1,62 @@ +<?php +/** + * Copyright © 2015 Magento. All rights reserved. + * See COPYING.txt for license details. + */ + +namespace Magento\Framework\View\Element\UiComponent\DataProvider; + +use Magento\Framework\Data\Collection\AbstractDb; + +/** + * Class FilterPool + */ +class FilterPool +{ + /** + * @var array + */ + protected $filters = []; + + /** + * @var array + */ + protected $appliers; + + /** + * @param array $appliers + */ + public function __construct(array $appliers = []) + { + $this->appliers = $appliers; + } + + /** + * @param string|int|array|null $condition + * @param string|null|array $field + * @param string $type + * @return void + */ + public function registerNewFilter($condition, $field, $type) + { + $this->filters[$type][sha1($field . serialize($condition))] = [ + 'field' => $field, + 'condition' => $condition + ]; + } + + /** + * @param AbstractDb $collection + * @return void + */ + public function applyFilters(AbstractDb $collection) + { + foreach ($this->filters as $type => $filter) { + if (isset($this->appliers[$type])) { + /** @var $filterApplier FilterApplierInterface*/ + $filterApplier = $this->appliers[$type]; + $filterApplier->apply($collection, $filter); + } + } + } +} diff --git a/lib/internal/Magento/Framework/View/Element/UiComponent/DataProvider/FulltextFilter.php b/lib/internal/Magento/Framework/View/Element/UiComponent/DataProvider/FulltextFilter.php new file mode 100644 index 0000000000000000000000000000000000000000..a313e403aa61f37ef17d4bf608f5a82f79893182 --- /dev/null +++ b/lib/internal/Magento/Framework/View/Element/UiComponent/DataProvider/FulltextFilter.php @@ -0,0 +1,57 @@ +<?php +/** + * Copyright © 2015 Magento. All rights reserved. + * See COPYING.txt for license details. + */ + +namespace Magento\Framework\View\Element\UiComponent\DataProvider; + +use Magento\Framework\Data\Collection\AbstractDb as DbCollection; +use \Magento\Framework\Model\Resource\Db\AbstractDb as DbResource; + +/** + * Class Fulltext + */ +class FulltextFilter implements FilterApplierInterface +{ + /** + * Returns list of columns from fulltext index (doesn't support more then one FTI per table) + * + * @param DbResource $resource + * @param string $indexTable + * @return array + * @throws \Magento\Framework\Exception\LocalizedException + */ + protected function getFulltextIndexColumns(DbResource $resource, $indexTable) + { + $indexes = $resource->getReadConnection()->getIndexList($indexTable); + foreach ($indexes as $index) { + if (strtoupper($index['INDEX_TYPE']) == 'FULLTEXT') { + return $index['COLUMNS_LIST']; + } + } + return []; + } + + /** + * Apply fulltext filters + * + * @param DbCollection $collection + * @param array $filters + * @return void + */ + public function apply(DbCollection $collection, $filters) + { + $columns = $this->getFulltextIndexColumns($collection->getResource(), $collection->getMainTable()); + if (!$columns) { + return; + } + foreach ($filters as $filter) { + $collection->getSelect() + ->where( + 'MATCH(' . implode(',', $columns) . ') AGAINST(? IN BOOLEAN MODE)', + $filter['condition'] + ); + } + } +} diff --git a/lib/internal/Magento/Framework/View/Element/UiComponent/DataProvider/RegularFilter.php b/lib/internal/Magento/Framework/View/Element/UiComponent/DataProvider/RegularFilter.php new file mode 100644 index 0000000000000000000000000000000000000000..6104b805c32efe371ed6f34bacb4365b170fd58b --- /dev/null +++ b/lib/internal/Magento/Framework/View/Element/UiComponent/DataProvider/RegularFilter.php @@ -0,0 +1,29 @@ +<?php +/** + * Copyright © 2015 Magento. All rights reserved. + * See COPYING.txt for license details. + */ + +namespace Magento\Framework\View\Element\UiComponent\DataProvider; + +use Magento\Framework\Data\Collection\AbstractDb; + +/** + * Class RegularFilter + */ +class RegularFilter implements FilterApplierInterface +{ + /** + * Apply regular filters like collection filters + * + * @param AbstractDb $collection + * @param array $filters + * @return void + */ + public function apply(AbstractDb $collection, $filters) + { + foreach ($filters as $filter) { + $collection->addFieldToFilter($filter['field'], $filter['condition']); + } + } +} diff --git a/setup/src/Magento/Setup/Test/Unit/Fixtures/OrdersFixtureTest.php b/setup/src/Magento/Setup/Test/Unit/Fixtures/OrdersFixtureTest.php index 2775d218af70ed7c5bb856733b0dc71d3a444dea..ad373730692acd16efd79d514eaa37993b70d6a2 100644 --- a/setup/src/Magento/Setup/Test/Unit/Fixtures/OrdersFixtureTest.php +++ b/setup/src/Magento/Setup/Test/Unit/Fixtures/OrdersFixtureTest.php @@ -52,7 +52,7 @@ class OrdersFixtureTest extends \PHPUnit_Framework_TestCase $mockObjects = []; foreach ($mockObjectNames as $mockObjectName) { - $mockObject = $this->getMock($mockObjectName, [], [], '', false); + $mockObject = $this->getMock($mockObjectName, ['getTable'], [], '', false); $path = explode('\\', $mockObjectName); $name = array_pop($path); if (strcasecmp($mockObjectName, 'Magento\Sales\Model\Resource\Order') == 0) {