diff --git a/vendor/magento/module-customer-graph-ql/Model/GetGuestOrdersByEmail.php b/vendor/magento/module-customer-graph-ql/Model/GetGuestOrdersByEmail.php
new file mode 100644
index 0000000000000..b06ff42b7d2de
--- /dev/null
+++ b/vendor/magento/module-customer-graph-ql/Model/GetGuestOrdersByEmail.php
@@ -0,0 +1,54 @@
+searchCriteriaBuilder->addFilter(
+ 'customer_email',
+ $email,
+ 'eq'
+ )->addFilter(
+ 'customer_is_guest',
+ 1,
+ 'eq'
+ );
+ return $this->orderRepository->getList($this->searchCriteriaBuilder->create());
+ }
+}
diff --git a/vendor/magento/module-customer-graph-ql/Plugin/Model/MergeGuestOrder.php b/vendor/magento/module-customer-graph-ql/Plugin/Model/MergeGuestOrder.php
new file mode 100644
index 0000000000000..b86c133a5da54
--- /dev/null
+++ b/vendor/magento/module-customer-graph-ql/Plugin/Model/MergeGuestOrder.php
@@ -0,0 +1,51 @@
+getGuestOrdersByEmail->execute($customer->getEmail());
+ foreach ($searchResult->getItems() as $order) {
+ $this->customerAssignment->execute($order, $customer);
+ }
+ return $customer;
+ }
+}
diff --git a/vendor/magento/module-customer-graph-ql/etc/graphql/di.xml b/vendor/magento/module-customer-graph-ql/etc/graphql/di.xml
index 305e9cd12d676..22bfedf0d00cc 100644
--- a/vendor/magento/module-customer-graph-ql/etc/graphql/di.xml
+++ b/vendor/magento/module-customer-graph-ql/etc/graphql/di.xml
@@ -209,4 +209,8 @@
+
+
+
diff --git a/vendor/magento/module-quote-graph-ql/Plugin/Model/MergeGuestOrder.php b/vendor/magento/module-quote-graph-ql/Plugin/Model/MergeGuestOrder.php
new file mode 100644
index 0000000000000..6216bce3cc31c
--- /dev/null
+++ b/vendor/magento/module-quote-graph-ql/Plugin/Model/MergeGuestOrder.php
@@ -0,0 +1,71 @@
+orderRepository->get($orderId);
+ if ($order->getCustomerIsGuest() && $order->getCustomerEmail()) {
+ try {
+ $websiteID = $this->storeManager->getStore()->getWebsiteId();
+ $customer = $this->customerRepository->get($order->getCustomerEmail(), $websiteID);
+ if ($customer->getId()) {
+ $this->customerAssignment->execute($order, $customer);
+ }
+ // phpcs:ignore Magento2.CodeAnalysis.EmptyBlock
+ } catch (NoSuchEntityException $e) {
+ // Do not remove this handle as it used to check that customer
+ // with this email not registered in the system
+ }
+ }
+ }
+ return $orderId;
+ }
+}
diff --git a/vendor/magento/module-quote-graph-ql/etc/graphql/di.xml b/vendor/magento/module-quote-graph-ql/etc/graphql/di.xml
index 83942f1daebb2..6ded0467ecd0e 100644
--- a/vendor/magento/module-quote-graph-ql/etc/graphql/di.xml
+++ b/vendor/magento/module-quote-graph-ql/etc/graphql/di.xml
@@ -73,4 +73,8 @@
+
+
+