File tree Expand file tree Collapse file tree 3 files changed +54
-1
lines changed
app/code/Magento/CatalogImportExport/Model/Export
dev/tests/integration/testsuite/Magento/CatalogImportExport Expand file tree Collapse file tree 3 files changed +54
-1
lines changed Original file line number Diff line number Diff line change 5
5
*/
6
6
namespace Magento \CatalogImportExport \Model \Export ;
7
7
8
- use Magento \Framework \DB \Ddl \Table ;
9
8
use Magento \ImportExport \Model \Import ;
10
9
use \Magento \Store \Model \Store ;
11
10
use \Magento \CatalogImportExport \Model \Import \Product as ImportProduct ;
@@ -850,6 +849,24 @@ public function export()
850
849
return $ writer ->getContents ();
851
850
}
852
851
852
+ /**
853
+ * {@inheritdoc}
854
+ */
855
+ protected function _prepareEntityCollection (\Magento \Eav \Model \Entity \Collection \AbstractCollection $ collection )
856
+ {
857
+ $ exportFilter = !empty ($ this ->_parameters [\Magento \ImportExport \Model \Export::FILTER_ELEMENT_GROUP ]) ?
858
+ $ this ->_parameters [\Magento \ImportExport \Model \Export::FILTER_ELEMENT_GROUP ] : [];
859
+
860
+ if (isset ($ exportFilter ['category_ids ' ])
861
+ && trim ($ exportFilter ['category_ids ' ])
862
+ && $ collection instanceof \Magento \Catalog \Model \ResourceModel \Product \Collection
863
+ ) {
864
+ $ collection ->addCategoriesFilter (['in ' => explode (', ' , $ exportFilter ['category_ids ' ])]);
865
+ }
866
+
867
+ return parent ::_prepareEntityCollection ($ collection );
868
+ }
869
+
853
870
/**
854
871
* Get export data for collection
855
872
*
Original file line number Diff line number Diff line change @@ -230,4 +230,31 @@ public function testExportWithFieldsEnclosure()
230
230
$ this ->assertContains ('""Option 4 """"!@#$%^&*""" ' , $ exportData );
231
231
$ this ->assertContains ('text_attribute=""!@#$%^&*()_+1234567890-=|\:;""" ' , $ exportData );
232
232
}
233
+
234
+ /**
235
+ * Verify that "category ids" filter correctly applies to export result
236
+ *
237
+ * @magentoDataFixture Magento/CatalogImportExport/_files/product_export_with_categories.php
238
+ */
239
+ public function testCategoryIdsFilter ()
240
+ {
241
+ $ this ->model ->setWriter (
242
+ $ this ->objectManager ->create (
243
+ \Magento \ImportExport \Model \Export \Adapter \Csv::class
244
+ )
245
+ );
246
+
247
+ $ this ->model ->setParameters ([
248
+ \Magento \ImportExport \Model \Export::FILTER_ELEMENT_GROUP => [
249
+ 'category_ids ' => '2,13 '
250
+ ]
251
+ ]);
252
+
253
+ $ exportData = $ this ->model ->export ();
254
+
255
+ $ this ->assertContains ('Simple Product ' , $ exportData );
256
+ $ this ->assertContains ('Simple Product Three ' , $ exportData );
257
+ $ this ->assertNotContains ('Simple Product Two ' , $ exportData );
258
+ $ this ->assertNotContains ('Simple Product Not Visible On Storefront ' , $ exportData );
259
+ }
233
260
}
Original file line number Diff line number Diff line change
1
+ <?php
2
+ /**
3
+ * Copyright © 2016 Magento. All rights reserved.
4
+ * See COPYING.txt for license details.
5
+ */
6
+
7
+ \Magento \TestFramework \Helper \Bootstrap::getInstance ()->reinitialize ();
8
+
9
+ require dirname (dirname (__DIR__ )) . '/Catalog/_files/categories.php ' ;
You can’t perform that action at this time.
0 commit comments