Skip to content
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

Jitheesh
Copy link
Contributor

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)

  1. Purchasing a downloadable product as guest then creating an account on the onepagesuccess step doesn't link product with account #21702: Purchasing a downloadable product as guest then creating an account on the onepagesuccess step doesn't link product with account

Manual testing scenarios (*)

  1. Enable guest purchasing of downloadable products (Catalog -> Catalog -> Dowloadable Product Options -> Disable Guest Checkout if Cart Contains Downloadable Items -> (Change it to NO))
  2. Purchase a downloadable product via guest checkout
  3. On the onepagesuccess step, create an account.
  4. Login to that newly created account and view the list of purchased downloadable products

Contribution checklist (*)

  • Pull request has a meaningful description of its purpose
  • All commits are accompanied by meaningful commit messages
  • All new or changed code is covered with unit/integration tests (if applicable)
  • All automated tests passed successfully (all builds on Travis CI are green)

…g an account on the onepagesuccess step doesn't link product with account

- added order save event for update link purchased data
@magento-engcom-team
Copy link
Contributor

Hi @Jitheesh. Thank you for your contribution
Here is some useful tips how you can test your changes using Magento test environment.
Add the comment under your pull request to deploy test or vanilla Magento instance:

  • @magento-engcom-team give me test instance - deploy test instance based on PR changes
  • @magento-engcom-team give me 2.3-develop instance - deploy vanilla Magento instance

For more details, please, review the Magento Contributor Assistant documentation

@Jitheesh
Copy link
Contributor Author

@magento-engcom-team give me test instance

@magento-engcom-team
Copy link
Contributor

Hi @Jitheesh. Thank you for your request. I'm working on Magento instance for you

@magento-engcom-team
Copy link
Contributor

Hi @Jitheesh, here is your new Magento instance.
Admin access: https://pr-21711.instances.magento-community.engineering/admin
Login: admin Password: 123123q

@ghost ghost assigned rogyar Mar 13, 2019
/**
* @SuppressWarnings(PHPMD.CouplingBetweenObjects)
*/
class UpdateLinkPurchasedObserver implements ObserverInterface
Copy link
Contributor

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

Copy link
Contributor Author

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,

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

@Jitheesh Jitheesh requested a review from rogyar March 19, 2019 12:00
@Jitheesh Jitheesh requested a review from rogyar March 21, 2019 04:24
@Jitheesh
Copy link
Contributor Author

@magento-engcom-team give me test instance

@magento-engcom-team
Copy link
Contributor

Hi @Jitheesh. Thank you for your request. I'm working on Magento instance for you

@magento-engcom-team
Copy link
Contributor

Hi @Jitheesh, here is your new Magento instance.
Admin access: https://pr-21711.instances.magento-community.engineering/admin
Login: admin Password: 123123q

@magento-engcom-team
Copy link
Contributor

Hi @rogyar, thank you for the review.
ENGCOM-4691 has been created to process this Pull Request

@VasylShvorak
Copy link
Contributor

✔️ QA passed

@m2-assistant
Copy link

m2-assistant bot commented Apr 23, 2019

Hi @Jitheesh, thank you for your contribution!
Please, complete Contribution Survey, it will take less than a minute.
Your feedback will help us to improve contribution process.

taskula pushed a commit to Hypernova-Oy/magento2 that referenced this pull request Apr 23, 2019
… an account on the onepagesuccess step doesn't link product with account magento#21711
@magento-engcom-team magento-engcom-team added this to the Release: 2.3.2 milestone Apr 23, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants