0

My module defines a custom entity type and bundle and adds fields to the bundle programatically. Now, I need to create a bunch of dummy data to test the interface. I'm working with various combinations of entity_get_controller()->create(), entity_metadata_wrapper()->save(), field_attach_submit(), etc. and I have been able to fill the entity base table with new rows. The problem is that the generated entities aren't loaded with:

  $query = new EntityFieldQuery();
  $query->entityCondition('entity_type', 'my_entity_type');

I'm not surprised that the query doesn't return my new entities because I haven't found a place to specify bundle for the dummy entities and I haven't figured out how to generate default or random field data. How do I specify the bundle for my new entities and how can I generate valid random field data for date, taxonomy_term_reference and integer fields?

1 Answer 1

0

My created entities were not listed by the EntityFieldQuery above because of this issue: Make EntityFieldQuery::fieldOrderBy include NULL field values

My new entities did not include a date field that was used to sort the table. So, the table didn't include the null-field entries.

I didn't figure out how to specify the bundle for my new entities but there is only one bundle defined, so it is the default. I'm still interested in a function that would be able to create random field data valid for each type of field. Heading over to look at Devel module for that function.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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