6
6
7
7
namespace Magmodules \Channable \Helper ;
8
8
9
+ use Magento \Catalog \Model \Product \TypeFactory ;
9
10
use Magento \Framework \App \Helper \AbstractHelper ;
10
11
use Magento \Framework \App \Helper \Context ;
11
12
use Magento \Framework \Exception \NoSuchEntityException ;
@@ -94,6 +95,10 @@ class Source extends AbstractHelper
94
95
* @var InventorySource
95
96
*/
96
97
private $ inventorySource ;
98
+ /**
99
+ * @var TypeFactory
100
+ */
101
+ private $ typeFactory ;
97
102
/**
98
103
* @var
99
104
*/
@@ -105,11 +110,13 @@ public function __construct(
105
110
General $ generalHelper ,
106
111
Product $ productHelper ,
107
112
InventorySource $ inventorySource ,
113
+ TypeFactory $ typeFactory ,
108
114
Item $ itemHelper
109
115
) {
110
116
$ this ->generalHelper = $ generalHelper ;
111
117
$ this ->productHelper = $ productHelper ;
112
118
$ this ->itemHelper = $ itemHelper ;
119
+ $ this ->typeFactory = $ typeFactory ;
113
120
$ this ->storeManager = $ storeManager ;
114
121
$ this ->inventorySource = $ inventorySource ;
115
122
parent ::__construct ($ context );
@@ -174,21 +181,28 @@ public function getStoreId($storeId = null)
174
181
return $ this ->storeId ;
175
182
}
176
183
184
+ private function getAllProductTypeIds (): array
185
+ {
186
+ $ typeInstance = $ this ->typeFactory ->create ();
187
+ return array_keys ($ typeInstance ->getOptionArray ());
188
+ }
189
+
177
190
/**
178
191
* @param $type
179
192
*
180
193
* @return array
181
194
*/
182
- public function getProductFilters ($ type )
195
+ public function getProductFilters ($ type ): array
183
196
{
184
- $ filters = [];
185
- $ filters ['type_id ' ] = ['simple ' , 'downloadable ' , 'virtual ' , 'giftcard ' ];
186
- $ filters ['relations ' ] = [];
187
- $ filters ['exclude_parents ' ] = [];
188
- $ filters ['nonvisible ' ] = [];
189
- $ filters ['parent_attributes ' ] = [];
190
- $ filters ['image ' ] = [];
191
- $ filters ['link ' ] = [];
197
+ $ filters = [
198
+ 'type_id ' => array_diff ($ this ->getAllProductTypeIds (), ['configurable ' , 'bundle ' , 'grouped ' ]),
199
+ 'relations ' => [],
200
+ 'exclude_parents ' => [],
201
+ 'nonvisible ' => [],
202
+ 'parent_attributes ' => [],
203
+ 'image ' => [],
204
+ 'link ' => [],
205
+ ];
192
206
193
207
$ configurabale = $ this ->getStoreValue (self ::XPATH_CONFIGURABLE );
194
208
switch ($ configurabale ) {
0 commit comments