From e637e7d2cad6bbf81d58db869cef733dd2d891c1 Mon Sep 17 00:00:00 2001 From: Julian van Drielen Date: Sat, 24 Mar 2018 16:11:11 +0100 Subject: [PATCH 1/5] Added posibility to set store_id for ProductDataProvider in a data argument. This is also now set to zero (default store view) for the catalog/product/index product grid --- .../Catalog/Ui/DataProvider/Product/ProductDataProvider.php | 4 ++++ .../Catalog/view/adminhtml/ui_component/product_listing.xml | 6 ++++++ 2 files changed, 10 insertions(+) diff --git a/app/code/Magento/Catalog/Ui/DataProvider/Product/ProductDataProvider.php b/app/code/Magento/Catalog/Ui/DataProvider/Product/ProductDataProvider.php index e31eca89f63c2..488c18cf1b707 100644 --- a/app/code/Magento/Catalog/Ui/DataProvider/Product/ProductDataProvider.php +++ b/app/code/Magento/Catalog/Ui/DataProvider/Product/ProductDataProvider.php @@ -58,6 +58,10 @@ public function __construct( $this->collection = $collectionFactory->create(); $this->addFieldStrategies = $addFieldStrategies; $this->addFilterStrategies = $addFilterStrategies; + + if (isset($data['store_id'])) { + $this->collection->setStoreId($data['store_id']); + } } /** diff --git a/app/code/Magento/Catalog/view/adminhtml/ui_component/product_listing.xml b/app/code/Magento/Catalog/view/adminhtml/ui_component/product_listing.xml index 09332d66633f1..34e7547825e7c 100644 --- a/app/code/Magento/Catalog/view/adminhtml/ui_component/product_listing.xml +++ b/app/code/Magento/Catalog/view/adminhtml/ui_component/product_listing.xml @@ -25,12 +25,18 @@ Magento_Catalog::products + 0 id entity_id + + + 0 + + From e7d9201ebb6d41ece454e0e193baf8a84dc597ff Mon Sep 17 00:00:00 2001 From: Julian van Drielen Date: Sat, 24 Mar 2018 16:19:45 +0100 Subject: [PATCH 2/5] Removed unnecessary storeId xml property. This was invalid code. --- .../Catalog/view/adminhtml/ui_component/product_listing.xml | 1 - 1 file changed, 1 deletion(-) diff --git a/app/code/Magento/Catalog/view/adminhtml/ui_component/product_listing.xml b/app/code/Magento/Catalog/view/adminhtml/ui_component/product_listing.xml index 34e7547825e7c..93242e0ca8adb 100644 --- a/app/code/Magento/Catalog/view/adminhtml/ui_component/product_listing.xml +++ b/app/code/Magento/Catalog/view/adminhtml/ui_component/product_listing.xml @@ -25,7 +25,6 @@ Magento_Catalog::products - 0 id From 08cf1372dc5bfb46babf578cbb79802cf0c3eb24 Mon Sep 17 00:00:00 2001 From: Julian van Drielen Date: Sat, 2 Jun 2018 11:30:27 +0200 Subject: [PATCH 3/5] Possible resolution to unit test errors. --- .../Ui/DataProvider/Product/ProductDataProvider.php | 7 +++++-- .../view/adminhtml/ui_component/product_listing.xml | 7 ++----- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/app/code/Magento/Catalog/Ui/DataProvider/Product/ProductDataProvider.php b/app/code/Magento/Catalog/Ui/DataProvider/Product/ProductDataProvider.php index 488c18cf1b707..f176326a56c20 100644 --- a/app/code/Magento/Catalog/Ui/DataProvider/Product/ProductDataProvider.php +++ b/app/code/Magento/Catalog/Ui/DataProvider/Product/ProductDataProvider.php @@ -59,8 +59,11 @@ public function __construct( $this->addFieldStrategies = $addFieldStrategies; $this->addFilterStrategies = $addFilterStrategies; - if (isset($data['store_id'])) { - $this->collection->setStoreId($data['store_id']); + if (isset($data['config']['storageConfig']['default_store']) + && (bool) $data['config']['storageConfig']['default_store'] + ) { + print_r("Oh damn");exit; + $this->collection->setStoreId($this->collection->getDefaultStoreId()); } } diff --git a/app/code/Magento/Catalog/view/adminhtml/ui_component/product_listing.xml b/app/code/Magento/Catalog/view/adminhtml/ui_component/product_listing.xml index 93242e0ca8adb..b92a03cefe419 100644 --- a/app/code/Magento/Catalog/view/adminhtml/ui_component/product_listing.xml +++ b/app/code/Magento/Catalog/view/adminhtml/ui_component/product_listing.xml @@ -21,21 +21,18 @@ filters.store_id + 1 Magento_Catalog::products + 1000 id entity_id - - - 0 - - From 13454e94baea7c422c271dbeb59970016a5e9092 Mon Sep 17 00:00:00 2001 From: Julian van Drielen Date: Sat, 2 Jun 2018 12:13:44 +0200 Subject: [PATCH 4/5] Removed debug line, that was accidentally included in the previous commit --- .../Catalog/Ui/DataProvider/Product/ProductDataProvider.php | 1 - 1 file changed, 1 deletion(-) diff --git a/app/code/Magento/Catalog/Ui/DataProvider/Product/ProductDataProvider.php b/app/code/Magento/Catalog/Ui/DataProvider/Product/ProductDataProvider.php index f176326a56c20..ab44cf98d11ef 100644 --- a/app/code/Magento/Catalog/Ui/DataProvider/Product/ProductDataProvider.php +++ b/app/code/Magento/Catalog/Ui/DataProvider/Product/ProductDataProvider.php @@ -62,7 +62,6 @@ public function __construct( if (isset($data['config']['storageConfig']['default_store']) && (bool) $data['config']['storageConfig']['default_store'] ) { - print_r("Oh damn");exit; $this->collection->setStoreId($this->collection->getDefaultStoreId()); } } From 8ac689847a0036782771ac08a5ce433b10825d16 Mon Sep 17 00:00:00 2001 From: Julian van Drielen Date: Sat, 2 Jun 2018 12:14:54 +0200 Subject: [PATCH 5/5] Removed code used in previous solution --- .../Catalog/view/adminhtml/ui_component/product_listing.xml | 1 - 1 file changed, 1 deletion(-) diff --git a/app/code/Magento/Catalog/view/adminhtml/ui_component/product_listing.xml b/app/code/Magento/Catalog/view/adminhtml/ui_component/product_listing.xml index b92a03cefe419..2181622415cfc 100644 --- a/app/code/Magento/Catalog/view/adminhtml/ui_component/product_listing.xml +++ b/app/code/Magento/Catalog/view/adminhtml/ui_component/product_listing.xml @@ -27,7 +27,6 @@ Magento_Catalog::products - 1000 id entity_id