mshop_order_base.customerid is "sometimes" empty
Forum rules
Always add your TYPO3, Aimeos and PHP version as well as your environment (Linux/Mac/Win)
Spam and unrelated posts will be removed immediately!
Always add your TYPO3, Aimeos and PHP version as well as your environment (Linux/Mac/Win)
Spam and unrelated posts will be removed immediately!
-
- Posts: 3
- Joined: 05 Jul 2018, 15:33
mshop_order_base.customerid is "sometimes" empty
Hello!
Software used:
TYPO3 8.7.18
aimeos 17.10.1
aimeio_pay 17.8.2
Situation:
The shop functionality was extended. Every user is forced to create an user account. The normal checkbox was replaced by a hidden input field.
This worked like a charm. Expect for less than 0.1% of all orders.
For some reason customerid is sometimes empty. I wasted hours of investigating this behavior but did not found any clue. There are no recurring patterns, errors nor anything that leads to this error.
What I tried out:
- I tried every possible way to order a product but could not reproduce this behavior: F5, cancel order and go back, order as registered user, order as new user, order again and again, etc
- the field customerid was sometimes empty on registered users orders and new users orders aswell
- the field customerid was sometimes empty on any statuspayment
Questions:
- Is there an other way to force auto create fe_user behavior?
- Is our attempt wrong?
- Why is customerid empty, when the order is correctly written to mshop_order_base and mshop_order_*.
Many many thanks in advance!
Software used:
TYPO3 8.7.18
aimeos 17.10.1
aimeio_pay 17.8.2
Situation:
The shop functionality was extended. Every user is forced to create an user account. The normal checkbox was replaced by a hidden input field.
Code: Select all
<?php if( !isset( $this->customerId ) ) : ?>
<input
id="option-account"
type="hidden"
value="1"
name="<?= $enc->attr( $this->formparam( array( 'cs_option_account' ) ) ); ?>"
/>
<?php endif; ?>
For some reason customerid is sometimes empty. I wasted hours of investigating this behavior but did not found any clue. There are no recurring patterns, errors nor anything that leads to this error.
What I tried out:
- I tried every possible way to order a product but could not reproduce this behavior: F5, cancel order and go back, order as registered user, order as new user, order again and again, etc
- the field customerid was sometimes empty on registered users orders and new users orders aswell
- the field customerid was sometimes empty on any statuspayment
Questions:
- Is there an other way to force auto create fe_user behavior?
- Is our attempt wrong?
- Why is customerid empty, when the order is correctly written to mshop_order_base and mshop_order_*.
Many many thanks in advance!
Re: mshop_order_base.customerid is "sometimes" empty
What you've done is absolutely OK and such errors are hard to find. You should add some logging and wait until the problem occurs again. A few things you should add logging to and what you should log.
Here's the code that adds the TYPO3 user ID for existing users to the Aimeos context:
https://github.com/aimeos/aimeos-typo3/ ... t.php#L275
Here's the code that adds the user ID for new users to the Aimeos context:
https://github.com/aimeos/ai-client-htm ... d.php#L188
Here's the code that adds the user ID to the basket before it is stored as order:
https://github.com/aimeos/ai-controller ... d.php#L168
The frontend basket controller, you should add some code like this:
In case the account couldn't be created because and exception is thrown (and therefore the user ID in the context is empty), an error must be available in the madmin_log table:
https://github.com/aimeos/ai-client-htm ... d.php#L193
Another possible case is that the mshop_order_base record is overwritten by a version without user ID. You should check if mtime and ctime of that record differ in the cases where the mshop_order_base.customerid value is missing. If this is the case, you can add the "ChangeLog" decorator to the order base manager, which will log all saved items:
https://github.com/aimeos/aimeos-core/b ... ngelog.php
You can add it to the order base manager by using this config setting:
https://aimeos.org/docs/Configuration/C ... ors/global
e.g. for TYPO3:
Maybe you should add it to the TSConfig field of your scheduler tasks as well.
The last possibility is that it's lost when you save the order in the administration interface. Did you check that as well?
Here's the code that adds the TYPO3 user ID for existing users to the Aimeos context:
https://github.com/aimeos/aimeos-typo3/ ... t.php#L275
Here's the code that adds the user ID for new users to the Aimeos context:
https://github.com/aimeos/ai-client-htm ... d.php#L188
Here's the code that adds the user ID to the basket before it is stored as order:
https://github.com/aimeos/ai-controller ... d.php#L168
The frontend basket controller, you should add some code like this:
Code: Select all
if( !$context->getUserId() ) {
$this->getContext()->getLogger()->log( 'NOUSERID: ' . var_export( $context->getUserId(), true ) );
$this->getContext()->getLogger()->log( 'NOUSERID: ' . var_export( $GLOBALS['TSFE']->loginUser, true ) );
$this->getContext()->getLogger()->log( 'NOUSERID: ' . print_r( $GLOBALS['TSFE']->fe_user->user, true ) );
}
https://github.com/aimeos/ai-client-htm ... d.php#L193
Another possible case is that the mshop_order_base record is overwritten by a version without user ID. You should check if mtime and ctime of that record differ in the cases where the mshop_order_base.customerid value is missing. If this is the case, you can add the "ChangeLog" decorator to the order base manager, which will log all saved items:
https://github.com/aimeos/aimeos-core/b ... ngelog.php
You can add it to the order base manager by using this config setting:
https://aimeos.org/docs/Configuration/C ... ors/global
e.g. for TYPO3:
Code: Select all
plugin.tx_aimeos.settings.mshop.order.manager.base.decorators.global {
0 = ChangeLog
}
The last possibility is that it's lost when you save the order in the administration interface. Did you check that as well?
Professional support and custom implementation are available at Aimeos.com
If you like Aimeos, give us a star
If you like Aimeos, give us a star
-
- Posts: 3
- Joined: 05 Jul 2018, 15:33
Re: mshop_order_base.customerid is "sometimes" empty
Many thanks! That was a quick and good answer.
- no exceptions were thrown inside madmin_log including "Unable to create an account"
- mtime and ctime do not differ any order where "customerid" is empty
- saving an order as BE-user does not lead to empty customerid
- we will enable logging in our aimeos shop
Is it possible that $this->customerId exists for some reason? Returning to the site when a payment provider was not readable or any other reason.
- no exceptions were thrown inside madmin_log including "Unable to create an account"
- mtime and ctime do not differ any order where "customerid" is empty
- saving an order as BE-user does not lead to empty customerid
- we will enable logging in our aimeos shop
Is it possible that $this->customerId exists for some reason? Returning to the site when a payment provider was not readable or any other reason.
Re: mshop_order_base.customerid is "sometimes" empty
Usually not but you should check for that too.
Professional support and custom implementation are available at Aimeos.com
If you like Aimeos, give us a star
If you like Aimeos, give us a star