-
Notifications
You must be signed in to change notification settings - Fork 9.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Purchasing a downloadable product as guest then creating an account on the onepagesuccess step doesn't link product with account #21711
Conversation
…g an account on the onepagesuccess step doesn't link product with account - added order save event for update link purchased data
Hi @Jitheesh. Thank you for your contribution
For more details, please, review the Magento Contributor Assistant documentation |
@magento-engcom-team give me test instance |
Hi @Jitheesh. Thank you for your request. I'm working on Magento instance for you |
Hi @Jitheesh, here is your new Magento instance. |
/** | ||
* @SuppressWarnings(PHPMD.CouplingBetweenObjects) | ||
*/ | ||
class UpdateLinkPurchasedObserver implements ObserverInterface |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hi @Jitheesh. Thank you for your contribution. Could you explain, please, is there any reason why the observer was created instead of fixing the issue directly in the code where it appears?
Thank you
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hi @rogyar
This issue is related to downloadable component and issue is appears at sales component,
magento2/app/code/Magento/Sales/Model/Order/CustomerManagement.php
Lines 99 to 125 in ab66a14
public function create($orderId) | |
{ | |
$order = $this->orderRepository->get($orderId); | |
if ($order->getCustomerId()) { | |
throw new AlreadyExistsException( | |
__('This order already has associated customer account') | |
); | |
} | |
$customer = $this->customerExtractor->extract($orderId); | |
/** @var AddressInterface[] $filteredAddresses */ | |
$filteredAddresses = []; | |
foreach ($customer->getAddresses() as $address) { | |
if ($this->needToSaveAddress($order, $address)) { | |
$filteredAddresses[] = $address; | |
} | |
} | |
$customer->setAddresses($filteredAddresses); | |
$account = $this->accountManagement->createAccount($customer); | |
$order = $this->orderRepository->get($orderId); | |
$order->setCustomerId($account->getId()); | |
$order->setCustomerIsGuest(0); | |
$this->orderRepository->save($order); | |
return $account; | |
} |
so I thought it would be good to add this fix on corresponding component. We already have other Observer based on this rule.
class SetLinkStatusObserver implements ObserverInterface |
app/code/Magento/Downloadable/Observer/UpdateLinkPurchasedObserver.php
Outdated
Show resolved
Hide resolved
app/code/Magento/Downloadable/Observer/UpdateLinkPurchasedObserver.php
Outdated
Show resolved
Hide resolved
app/code/Magento/Downloadable/Observer/UpdateLinkPurchasedObserver.php
Outdated
Show resolved
Hide resolved
app/code/Magento/Downloadable/Observer/UpdateLinkPurchasedObserver.php
Outdated
Show resolved
Hide resolved
@magento-engcom-team give me test instance |
Hi @Jitheesh. Thank you for your request. I'm working on Magento instance for you |
Hi @Jitheesh, here is your new Magento instance. |
Hi @rogyar, thank you for the review. |
✔️ QA passed |
Hi @Jitheesh, thank you for your contribution! |
… an account on the onepagesuccess step doesn't link product with account magento#21711
New downloadable products does not show up in my downloadable products section after using guest checkout and creating an account. This issue is because Link Purchased items are not updating after create account.
After account create Magento is assigning customer ID to recent order and it initiates order save. My fix will observer order save and it will update downloadable_link_purchased table with updated order data.
I'm not sure this is right fix or not.
Description (*)
Fixed Issues (if relevant)
Manual testing scenarios (*)
Contribution checklist (*)