Skip to content

Commit 4746e94

Browse files
committed
#36947 Fixed timezone of order_date field returned from graphql customerOrders query
1 parent 6b34507 commit 4746e94

File tree

1 file changed

+9
-2
lines changed
  • app/code/Magento/SalesGraphQl/Model/Formatter

1 file changed

+9
-2
lines changed

app/code/Magento/SalesGraphQl/Model/Formatter/Order.php

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,8 @@
77

88
namespace Magento\SalesGraphQl\Model\Formatter;
99

10+
use Magento\Framework\App\ObjectManager;
11+
use Magento\Framework\Stdlib\DateTime\TimezoneInterface;
1012
use Magento\Sales\Api\Data\OrderInterface;
1113
use Magento\SalesGraphQl\Model\Order\OrderAddress;
1214
use Magento\SalesGraphQl\Model\Order\OrderPayments;
@@ -26,16 +28,21 @@ class Order
2628
*/
2729
private $orderPayments;
2830

31+
private TimezoneInterface $timezone;
32+
2933
/**
3034
* @param OrderAddress $orderAddress
3135
* @param OrderPayments $orderPayments
36+
* @param TimezoneInterface|null $timezone
3237
*/
3338
public function __construct(
3439
OrderAddress $orderAddress,
35-
OrderPayments $orderPayments
40+
OrderPayments $orderPayments,
41+
TimezoneInterface $timezone = null
3642
) {
3743
$this->orderAddress = $orderAddress;
3844
$this->orderPayments = $orderPayments;
45+
$this->timezone = $timezone ?: ObjectManager::getInstance()->get(TimezoneInterface::class);
3946
}
4047

4148
/**
@@ -52,7 +59,7 @@ public function format(OrderInterface $orderModel): array
5259
'id' => base64_encode($orderModel->getEntityId()),
5360
'increment_id' => $orderModel->getIncrementId(),
5461
'number' => $orderModel->getIncrementId(),
55-
'order_date' => $orderModel->getCreatedAt(),
62+
'order_date' => $this->timezone->date($orderModel->getCreatedAt()),
5663
'order_number' => $orderModel->getIncrementId(),
5764
'status' => $orderModel->getStatusLabel(),
5865
'shipping_method' => $orderModel->getShippingDescription(),

0 commit comments

Comments
 (0)