Skip to content

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

@chrisolof

Description

@chrisolof

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).

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions