29
29
30
30
class Orders extends ComponentBase {
31
31
public static $ defaultOptions = [
32
- 'start ' => 0 ,
33
- 'limit ' => 10 ,
34
- 'language_id ' => NULL ,
35
- 'site_id ' => NULL ,
36
- 'user_id ' => NULL ,
37
- 'email ' => NULL ,
38
- 'phone_number ' => NULL ,
39
- 'search ' => NULL ,
40
- 'id_manufacturer ' => NULL ,
41
- 'order_status ' => NULL ,
42
- 'order_status_id ' => NULL ,
32
+ 'start ' => 0 ,
33
+ 'limit ' => 10 ,
34
+ 'language_id ' => NULL ,
35
+ 'site_id ' => NULL ,
36
+ 'user_id ' => NULL ,
37
+ 'email ' => NULL ,
38
+ 'phone_number ' => NULL ,
39
+ 'search ' => NULL ,
40
+ 'id_manufacturer ' => NULL ,
41
+ 'order_status ' => NULL ,
42
+ 'order_status_id ' => NULL ,
43
+ 'order_by ' => NULL ,
44
+ 'direction ' => ['url ' , 'asc ' , 'desc ' ],
43
45
];
44
46
45
47
public $ options = [];
@@ -49,6 +51,16 @@ function results() {
49
51
50
52
$ results = $ orders ->getAll ($ this ->options );
51
53
54
+ if (isset ($ this ->options ['order_by ' ]) &&
55
+ ! in_array ($ this ->options ['order_by ' ], ['order_id ' , 'customer_order_id ' , 'order_status_id ' , 'created_at ' ])) {
56
+ unset($ this ->options ['order_by ' ]);
57
+ }
58
+
59
+ if (isset ($ this ->options ['direction ' ]) &&
60
+ ! in_array ($ this ->options ['direction ' ], ['asc ' , 'desc ' ])) {
61
+ unset($ this ->options ['direction ' ]);
62
+ }
63
+
52
64
if ($ results ['order ' ]) {
53
65
$ currency = Currency::getInstance ();
54
66
0 commit comments