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

Entity creation does not expand base fields & assumes "id" for entity ID key (D8/9/10 driver) #270

Open
chrisolof opened this issue Mar 6, 2024 · 0 comments · May be fixed by #271
Open

Comments

@chrisolof
Copy link

While creating a set of interrelated commerce entities at the outset of my scenario, I ran into an inability to set the commerce_product_variation's base price field, and the commerce_product's variations field. I tracked it down to a combination of missing entity-level functionality in this and the related drupalextension project.

In this DrupalDriver project, I found that special "expanding" is done to field values prior to actual entity creation. This is absolutely necessary for setting an entity reference field like commerce_product.variations. Unfortunately, expansion is currently only done on non-base fields, preventing me from successfully setting a base field like commerce_product.variations from my scenario.

I also found this driver currently assumes an entity ID key of id, which is not universal to all entity types. Going instead with whatever the entity type's ID key actually is would make entity clean up more straightforward and would open up entityCreate() to be utilized across node, user, and taxonomy term creation methods (reducing repeated entity creation code and centralizing where an entity, of whatever type, is created).

chrisolof added a commit to chrisolof/DrupalDriver that referenced this issue Mar 7, 2024
…nsion

Per FieldHandlerInterface::expand(), field handlers expect an array of
field values.  The source entity object passed into expandEntityFields()
often has an inconsistent structure across its various field properties,
sometimes holding a single value, sometimes holding an array of values (as
expected), and sometimes holding an array of composite field parts for a
single field value.  Consistently providing field handlers the field values
in the structure they expect allows them to expand each field value
correctly.

jhedstromgh-270
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant