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