magento / magento/magento2-sample-data
Install fails with the error "Unable to apply data patch Magento\CustomerSampleData\Setup\Patch\Data\InstallCustomerSampleData" on EE/Commerce
Nobody has claimed this yet.
- Dominant language
- PHP
- Stars
- 212
- Forks
- 266
- PR merge metrics
- No merged PRs in 30d
Description
Using a clean Docker stack based on the versions mentioned in the [official requirements](https://experienceleague.adobe.com/docs/commerce-operations/installation-guide/system-requirements.html) page, I always end up with the following error when trying to install the sample data:
```
Unable to apply data patch Magento\CustomerSampleData\Setup\Patch\Data\InstallCustomerSampleData for module Magento_CustomerSampleData. Original exception message: Rolled back transaction has not been completed correctly.
```
When digging up a bit, I can figure out this is caused by the following file: `vendor/magento/module-customer-sample-data/fixtures/customer_profile.csv`, and because it has the ID `2` hardcoded in the `gender` column:
```csv
firstname,lastname,email,password,dob,gender,street,city,region,country_id,postcode,telephone
Veronica,Costello,"roni_cost@example.com","roni_cost3@example.com","1973-12-15",2,"[""6146 Honey Bluff Parkway"",""""]",Calder,Michigan,US,"49628-7978","(555) 229-3326"
HERE ---^
```
Looking at the database, I can see that the IDs seem to have a increment step of **3** and not 1, which means that `2` cannot occur when using a single database node (typical configuration on a developer instance).
| option_id | attribute_id | sort_order |
|-----------|--------------|------------|
| 1 | 58 | 0 |
| 4 | 58 | 1 |
| 7 | 58 | 3 |
(`58` is the ID of th attribute `gender` on customers)
I guess hardcoding IDs is a bad practice anyway, so perhaps the best solution would be to use the label in that file (`Female`) and adapt the injection code to it.
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with vendor/magento/module-customer-sample-data/fixtures/customer_profile.csv and Magento\CustomerSampleData\Setup\Patch\Data\InstallCustomerSampleData. Trace how the gender value is injected during sample-data installation and verify the behavior with the single-node database configuration described in the issue. Done means the sample data installs without the rolled-back transaction error and does not depend on an unavailable hardcoded option ID.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- php
- Domain
- backend, databases
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 38/100