-
Couldn't load subscription status.
- Fork 256
Issue #2861181 : Better handling of customer remote IDs for payments. #676
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
Issue #2861181 : Better handling of customer remote IDs for payments. #676
Conversation
…IDs for payments.
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.
Just some concerns around the post update function.
| */ | ||
| function commerce_payment_post_update_1(&$sandbox) { | ||
| // Get the user ids that have 'commerce_remote_id' field not emtpy. | ||
| $result = \Drupal::entityQuery('user')->exists('commerce_remote_id')->execute(); |
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.
Wouldn't we only want to run this the first time, and I think we could just do a count query
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.
is it necessary?
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.
A count query would probably be more efficient, let's do that.
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.
it should be done now
|
|
||
| // Process entities by groups of 20. | ||
| $limit = 20; | ||
| $result = array_slice($result, $sandbox['current'], $limit); |
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.
Why not put a range on the query instead
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.
is it necessary?
…o 2861181-payments-remote-ids
…o 2861181-payments-remote-ids
| if (\Drupal::entityQuery('user')->exists('commerce_remote_id')->count()->execute() == 0) { | ||
| return t('No user Remote ID field data to update.'); | ||
| } | ||
| $result = \Drupal::entityQuery('user')->exists('commerce_remote_id')->execute(); |
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.
We should run the count query only under if (!isset($sandbox['current'])) {
After that it's cached in $sandbox.
Then run the real query with a range each time.
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.
should be done
| /** @var \Drupal\commerce_payment\PaymentGatewayStorageInterface $payment_gateway_storage */ | ||
| $payment_gateway_storage = \Drupal::entityTypeManager()->getStorage('commerce_payment_gateway'); | ||
| $payment_gateways = $payment_gateway_storage->loadMultiple(); | ||
| uasort($payment_gateways, [$payment_gateway_storage->getEntityType()->getClass(), 'sort']); |
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.
You should be able to use $payment_gateway_storage->getEntityType()->getProvider() to get the module.
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.
no idea, what you mean
| return $this; | ||
| } | ||
|
|
||
| /** |
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.
Is there a point in having these methods? We usually need the remote customer ID before creating a payment method, so we need them on PaymentGatewayBase instead.
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.
i also thought the same initially. but working on it looks like PaymentMethod entity methods
…o 2861181-payments-remote-ids
…o 2861181-payments-remote-ids
…o 2861181-payments-remote-ids
…rce into 2861181-payments-remote-ids
6be1d5c to
b8a7444
Compare
|
Committed in 14786dd. |
No description provided.