File tree Expand file tree Collapse file tree 1 file changed +18
-2
lines changed
app/code/Magento/Rule/Model/Condition/Sql Expand file tree Collapse file tree 1 file changed +18
-2
lines changed Original file line number Diff line number Diff line change @@ -250,8 +250,24 @@ public function attachConditionToCollection(
250
250
$ this ->_joinTablesToCollection ($ collection , $ combine );
251
251
$ whereExpression = (string )$ this ->_getMappedSqlCombination ($ combine );
252
252
if (!empty ($ whereExpression )) {
253
- // Select ::where method adds braces even on empty expression
254
- $ collection ->getSelect ()->where ($ whereExpression );
253
+ if (!empty ($ combine ->getConditions ())) {
254
+ foreach ($ combine ->getConditions () as $ condition ) {
255
+ $ conditions = $ condition ->getData ()['value ' ];
256
+ $ attribute = $ condition ->getData ()['attribute ' ];
257
+ }
258
+ if (!empty ($ conditions )) {
259
+ $ conditions = explode (', ' , $ conditions );
260
+ foreach ($ conditions as &$ condition ) {
261
+ $ condition = "' " . trim ($ condition ) . "' " ;
262
+ }
263
+ $ conditions = implode (', ' , $ conditions );
264
+ }
265
+
266
+ $ collection ->getSelect ()->where ($ whereExpression )->order ("FIELD( $ attribute, $ conditions) " );
267
+ } else {
268
+ // Select ::where method adds braces even on empty expression
269
+ $ collection ->getSelect ()->where ($ whereExpression );
270
+ }
255
271
}
256
272
}
257
273
}
You can’t perform that action at this time.
0 commit comments