7
7
8
8
namespace Magento \SalesGraphQl \Model \Formatter ;
9
9
10
+ use Magento \Framework \App \ObjectManager ;
11
+ use Magento \Framework \Stdlib \DateTime \TimezoneInterface ;
10
12
use Magento \Sales \Api \Data \OrderInterface ;
11
13
use Magento \SalesGraphQl \Model \Order \OrderAddress ;
12
14
use Magento \SalesGraphQl \Model \Order \OrderPayments ;
@@ -26,16 +28,21 @@ class Order
26
28
*/
27
29
private $ orderPayments ;
28
30
31
+ private TimezoneInterface $ timezone ;
32
+
29
33
/**
30
34
* @param OrderAddress $orderAddress
31
35
* @param OrderPayments $orderPayments
36
+ * @param TimezoneInterface|null $timezone
32
37
*/
33
38
public function __construct (
34
39
OrderAddress $ orderAddress ,
35
- OrderPayments $ orderPayments
40
+ OrderPayments $ orderPayments ,
41
+ TimezoneInterface $ timezone = null
36
42
) {
37
43
$ this ->orderAddress = $ orderAddress ;
38
44
$ this ->orderPayments = $ orderPayments ;
45
+ $ this ->timezone = $ timezone ?: ObjectManager::getInstance ()->get (TimezoneInterface::class);
39
46
}
40
47
41
48
/**
@@ -52,7 +59,7 @@ public function format(OrderInterface $orderModel): array
52
59
'id ' => base64_encode ($ orderModel ->getEntityId ()),
53
60
'increment_id ' => $ orderModel ->getIncrementId (),
54
61
'number ' => $ orderModel ->getIncrementId (),
55
- 'order_date ' => $ orderModel ->getCreatedAt (),
62
+ 'order_date ' => $ this -> timezone -> date ( $ orderModel ->getCreatedAt () ),
56
63
'order_number ' => $ orderModel ->getIncrementId (),
57
64
'status ' => $ orderModel ->getStatusLabel (),
58
65
'shipping_method ' => $ orderModel ->getShippingDescription (),
0 commit comments