2

I'm trying to add property information to an entity which uses the entity API. Working from the commerce_product module I am trying to manage additional information outside of fields and in my own database that ends up attributed with the resulting product object when the entity is loaded. I've been looking into the hook_entity_property_info_alter and hook_entity_load functions to get the additional custom or "pseudo-fields" loaded. I'm having issues when saving/creating the new entity (product) and information submitted from the form is not accessible. Am I supposed to alter the form and tack on an additional form submit handler? During a call to hook_commerce_product_insert I was expecting the $product object to have form field values included that I could work with. What would be the recommended way to approach this? I want to end up with data from my own database schema added to the entity and be editable through the entity's creation/edit forms.

I found this relevant solution but that approach deals with editing the original schema which is definitely something I want to avoid.

2 Answers 2

0

You may have to override the form submit handler, or at a minimum add you're own submit handler in addition to the default. As long as the submit handler starts with an entity passed through the $form_state, you could add your own handler to fire before the final handler that saves the entity and set your properties there.

While I don't have a ton of experience working with entities and hook_entity_load etc, you may get more milage from extending and overriding the default entity controller for product and overriding the load, save, and delete methods.

0

There is some kind of field other than usual CCK fields: extra fields.

hook_field_extra_field

I'm going to use it to add additional information to entity (Parent NID, Parent UID) some stuff that entity-reference can't and shouldn't handle. You have said it must not be field, I don't know if you don't want to use this kind of field also, But you might overlook some issues.

I'm not 100 percent sure if it's the solution but for people looking for an answer it's good to look at it.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.