diff --git a/app/code/Magento/SalesGraphQl/Model/Formatter/Order.php b/app/code/Magento/SalesGraphQl/Model/Formatter/Order.php index c5d0df668afac..bf2d65ad64dc0 100644 --- a/app/code/Magento/SalesGraphQl/Model/Formatter/Order.php +++ b/app/code/Magento/SalesGraphQl/Model/Formatter/Order.php @@ -54,7 +54,6 @@ public function format(OrderInterface $orderModel): array 'number' => $orderModel->getIncrementId(), 'order_date' => $orderModel->getCreatedAt(), 'order_number' => $orderModel->getIncrementId(), - 'status' => $orderModel->getStatusLabel(), 'shipping_method' => $orderModel->getShippingDescription(), 'shipping_address' => $this->orderAddress->getOrderShippingAddress($orderModel), 'billing_address' => $this->orderAddress->getOrderBillingAddress($orderModel), diff --git a/app/code/Magento/SalesGraphQl/Model/Resolver/OrderStatus.php b/app/code/Magento/SalesGraphQl/Model/Resolver/OrderStatus.php new file mode 100644 index 0000000000000..408f027cdbf03 --- /dev/null +++ b/app/code/Magento/SalesGraphQl/Model/Resolver/OrderStatus.php @@ -0,0 +1,59 @@ +orderStatusFactory = $orderStatusFactory; + } + + /** + * @inheritDoc + */ + public function resolve( + Field $field, + $context, + ResolveInfo $info, + array $value = null, + array $args = null + ) { + if (!(($value['model'] ?? null) instanceof OrderInterface)) { + throw new LocalizedException(__('"model" value should be specified')); + } + + /** @var OrderInterface $order */ + $order = $value['model']; + $store = $context->getExtensionAttributes()->getStore(); + + $status = $this->orderStatusFactory->create()->load($order->getStatus()); + return $status->getStoreLabel($store); + } +} diff --git a/app/code/Magento/SalesGraphQl/etc/schema.graphqls b/app/code/Magento/SalesGraphQl/etc/schema.graphqls index 8a76f51d78e79..3262ee184cfb2 100644 --- a/app/code/Magento/SalesGraphQl/etc/schema.graphqls +++ b/app/code/Magento/SalesGraphQl/etc/schema.graphqls @@ -41,7 +41,7 @@ type CustomerOrders @doc(description: "The collection of orders that match the c type CustomerOrder @doc(description: "Contains details about each of the customer's orders") { id: ID! @doc(description: "The unique ID for a `CustomerOrder` object") order_date: String! @doc(description: "The date the order was placed") - status: String! @doc(description: "The current status of the order") + status: String! @doc(description: "The current status of the order") @resolver(class: "Magento\\SalesGraphQl\\Model\\Resolver\\OrderStatus") number: String! @doc(description: "The order number") items: [OrderItemInterface] @doc(description: "An array containing the items purchased in this order") @resolver(class: "Magento\\SalesGraphQl\\Model\\Resolver\\OrderItems") total: OrderTotal @doc(description: "Contains details about the calculated totals for this order") @resolver(class: "Magento\\SalesGraphQl\\Model\\Resolver\\OrderTotal")