* @since 100.0.2
+ * @SuppressWarnings(PHPMD.CouplingBetweenObjects)
*/
class Grid extends \Magento\Backend\Block\Widget\Grid\Extended
{
@@ -42,6 +47,11 @@ class Grid extends \Magento\Backend\Block\Widget\Grid\Extended
*/
protected $_productFactory;
+ /**
+ * @var ProductCollectionDataProvider $productCollectionProvider
+ */
+ private $productCollectionProvider;
+
/**
* @param \Magento\Backend\Block\Template\Context $context
* @param \Magento\Backend\Helper\Data $backendHelper
@@ -50,6 +60,7 @@ class Grid extends \Magento\Backend\Block\Widget\Grid\Extended
* @param \Magento\Backend\Model\Session\Quote $sessionQuote
* @param \Magento\Sales\Model\Config $salesConfig
* @param array $data
+ * @param ProductCollectionDataProvider|null $productCollectionProvider
*/
public function __construct(
\Magento\Backend\Block\Template\Context $context,
@@ -58,12 +69,15 @@ public function __construct(
\Magento\Catalog\Model\Config $catalogConfig,
\Magento\Backend\Model\Session\Quote $sessionQuote,
\Magento\Sales\Model\Config $salesConfig,
- array $data = []
+ array $data = [],
+ ProductCollectionDataProvider $productCollectionProvider = null
) {
$this->_productFactory = $productFactory;
$this->_catalogConfig = $catalogConfig;
$this->_sessionQuote = $sessionQuote;
$this->_salesConfig = $salesConfig;
+ $this->productCollectionProvider = $productCollectionProvider
+ ?: ObjectManager::getInstance()->get(ProductCollectionDataProvider::class);
parent::__construct($context, $backendHelper, $data);
}
@@ -140,20 +154,18 @@ protected function _addColumnFilterToCollection($column)
*/
protected function _prepareCollection()
{
+
$attributes = $this->_catalogConfig->getProductAttributes();
+ $store = $this->getStore();
+
/* @var $collection \Magento\Catalog\Model\ResourceModel\Product\Collection */
- $collection = $this->_productFactory->create()->getCollection();
- $collection->setStore(
- $this->getStore()
- )->addAttributeToSelect(
+ $collection = $this->productCollectionProvider->getCollectionForStore($store);
+ $collection->addAttributeToSelect(
$attributes
- )->addAttributeToSelect(
- 'sku'
- )->addStoreFilter()->addAttributeToFilter(
+ );
+ $collection->addAttributeToFilter(
'type_id',
$this->_salesConfig->getAvailableProductTypes()
- )->addAttributeToSelect(
- 'gift_message_available'
);
$this->setCollection($collection);
diff --git a/app/code/Magento/Sales/Block/Adminhtml/Order/Create/Search/Grid/DataProvider/ProductCollection.php b/app/code/Magento/Sales/Block/Adminhtml/Order/Create/Search/Grid/DataProvider/ProductCollection.php
new file mode 100644
index 0000000000000..733791a2f9549
--- /dev/null
+++ b/app/code/Magento/Sales/Block/Adminhtml/Order/Create/Search/Grid/DataProvider/ProductCollection.php
@@ -0,0 +1,55 @@
+collectionFactory = $collectionFactory;
+ }
+
+ /**
+ * Provide products collection filtered with store
+ *
+ * @param Store $store
+ * @return Collection
+ */
+ public function getCollectionForStore(Store $store):Collection
+ {
+ /** @var Collection $collection */
+ $collection = $this->collectionFactory->create();
+
+ $collection->setStore($store);
+ $collection->addAttributeToSelect(
+ 'gift_message_available'
+ );
+ $collection->addAttributeToSelect(
+ 'sku'
+ );
+ $collection->addStoreFilter();
+
+ return $collection;
+ }
+}
diff --git a/app/code/Magento/Sales/view/adminhtml/templates/order/create/form/address.phtml b/app/code/Magento/Sales/view/adminhtml/templates/order/create/form/address.phtml
index b0a88b8fa37dc..d1a90783c68c7 100644
--- a/app/code/Magento/Sales/view/adminhtml/templates/order/create/form/address.phtml
+++ b/app/code/Magento/Sales/view/adminhtml/templates/order/create/form/address.phtml
@@ -89,11 +89,8 @@ endif; ?>
= $block->getForm()->toHtml() ?>
- getDontSaveInAddressBook() && $block->getAddress()->getSaveInAddressBook()): ?> checked="checked"
- class="admin__control-checkbox"/>
+ getDontSaveInAddressBook()): ?> checked="checked" class="admin__control-checkbox"/>
diff --git a/app/code/Magento/Search/Test/Mftf/Section/StorefrontQuickSearchResultsSection.xml b/app/code/Magento/Search/Test/Mftf/Section/StorefrontQuickSearchResultsSection.xml
index 81b025c9554e2..ff9fce57c4524 100644
--- a/app/code/Magento/Search/Test/Mftf/Section/StorefrontQuickSearchResultsSection.xml
+++ b/app/code/Magento/Search/Test/Mftf/Section/StorefrontQuickSearchResultsSection.xml
@@ -12,6 +12,7 @@
+
diff --git a/app/code/Magento/Ui/Test/Mftf/ActionGroup/AdminDataGridPaginationActionGroup.xml b/app/code/Magento/Ui/Test/Mftf/ActionGroup/AdminDataGridPaginationActionGroup.xml
index 9148c22976c19..fbb543a6cab92 100644
--- a/app/code/Magento/Ui/Test/Mftf/ActionGroup/AdminDataGridPaginationActionGroup.xml
+++ b/app/code/Magento/Ui/Test/Mftf/ActionGroup/AdminDataGridPaginationActionGroup.xml
@@ -23,8 +23,23 @@