@@ -213,16 +213,41 @@ public static function getAttributeFilterType(\Magento\Eav\Model\Entity\Attribut
213
213
return self ::FILTER_TYPE_DATE ;
214
214
} elseif ('decimal ' == $ attribute ->getBackendType () || 'int ' == $ attribute ->getBackendType ()) {
215
215
return self ::FILTER_TYPE_NUMBER ;
216
- } elseif ($ attribute ->isStatic () ||
217
- 'varchar ' == $ attribute ->getBackendType () ||
218
- 'text ' == $ attribute ->getBackendType ()
219
- ) {
216
+ } elseif ('varchar ' == $ attribute ->getBackendType () || 'text ' == $ attribute ->getBackendType ()) {
220
217
return self ::FILTER_TYPE_INPUT ;
218
+ } elseif ($ attribute ->isStatic ()) {
219
+ return self ::getStaticAttributeFilterType ($ attribute );
221
220
} else {
222
221
throw new \Magento \Framework \Exception \LocalizedException (__ ('Cannot determine attribute filter type ' ));
223
222
}
224
223
}
225
224
225
+ /**
226
+ * Determine filter type for static attribute.
227
+ *
228
+ * @static
229
+ * @param \Magento\Eav\Model\Entity\Attribute $attribute
230
+ * @return string
231
+ */
232
+ public static function getStaticAttributeFilterType (\Magento \Eav \Model \Entity \Attribute $ attribute )
233
+ {
234
+ $ columns = $ attribute ->getFlatColumns ();
235
+ switch ($ columns [$ attribute ->getAttributeCode ()]['type ' ]) {
236
+ case \Magento \Framework \DB \Ddl \Table::TYPE_INTEGER :
237
+ case \Magento \Framework \DB \Ddl \Table::TYPE_BIGINT :
238
+ $ type = self ::FILTER_TYPE_NUMBER ;
239
+ break ;
240
+ case \Magento \Framework \DB \Ddl \Table::TYPE_DATE :
241
+ case \Magento \Framework \DB \Ddl \Table::TYPE_DATETIME :
242
+ case \Magento \Framework \DB \Ddl \Table::TYPE_TIMESTAMP :
243
+ $ type = self ::FILTER_TYPE_DATE ;
244
+ break ;
245
+ default :
246
+ $ type = self ::FILTER_TYPE_INPUT ;
247
+ }
248
+ return $ type ;
249
+ }
250
+
226
251
/**
227
252
* MIME-type for 'Content-Type' header.
228
253
*
0 commit comments