Fix customer missing attributes #382
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Context
#375
It is possible for a store to get into a state where the TaxJar custom customer attributes were not created (e.g. if setup was interrupted). This will cause errors when trying to save customers, and customers will not sync to TaxJar.
Specifically: the TaxJar module's
Observer/Customer/Save.php
observer throws an error when customer attributes are missing:This happens when
tj_exemption_type
,tj_regions
, ortj_last_sync
customer attributes don't exist in the system. Note - the issue isn't so much that any individual customer doesn't have one of these attributes, but that the attributes themselves don't exist in the database (so, can't be applied to an individual customer!).Description
This PR adds:
Feature Additions:
AttributeCheck.php
) to detect any missing TaxJar customer attributes.Install.php
controller to manually install missing customer attributes.Code Adjustments:
Performance
Minimal impact. Adds an extra check on the customers page in the Admin UI. This was intentionally not cached to provide real-time information. This does not impact the customer-facing storefront at all.
Testing
Step 1: Install the Updated TaxJar Module
Step 2: Reproduce the Issue
Delete one or more TaxJar customer attributes from the database:
Clear Magento cache:
Navigate to the customer grid in the admin panel (Customers >> All Customers)
Try to save a customer through the admin interface
Step 3: Test with All Attributes Present
Run setup:upgrade to re-install all attributes:
Note: If you encounter any errors during the
setup:upgrade
process, the command may not complete successfully. In this case, you can use our "Install Missing Attributes Now" button instead, which is designed to work even whensetup:upgrade
fails.Save a customer with TaxJar attributes set
Step 4: Test with Partial Attributes
Delete only one attribute (e.g., tj_regions).
Navigate to the customer grid or edit page.
Click the "Install Missing Attributes Now" button
Edit and save a customer with tax exemption settings
Versions