Entity Export

Component ID

2076545

Component name

Entity Export

Component type

module

Maintenance status

Development status

Component security advisory coverage

not-covered

Component created

Component changed

Component body

** In short, this module exports any entity object (the contents, not the structures) into JSON string, which can be used for import if the same entity type exists on the target site**

I just want to start by saying that I'm extremely new to drupal development. Maybe I have implemented a module with duplicated functionalities, but I wrote it after researching many alternatives (such as the Migrate or the data_export modules) which all failed to meet my need, and I do believe it's a somewhat common need that an actual module would benefit the community.

So the idea came from a site I'm recently developing (the first serious site I developed with drupal ;) Due to time constraints, the site needs to be up and running as soon as possible. It is rather easy to meet the current requirement with all the modules drupal community provides, but I want to retain flexibility as in when I need to, I can just reinstall the site with new features in it.

Thus I plan to use a duo stage installation. A production site runs whatever features it currently needs, and another development site will be used to test new feature developments. Once the new features are rich and stable enough, the production site will be replaced by a copy of the development site.

The problem then, is how to easily transfer all the content in the production site to the development site. I'm not only talking about nodes, but registrations (with the entity registration module), entityform submissions (with the entityform module), user profiles (with the profile 2 module), etc... Luckily they are all utilizing the Entity API, but I have yet to find a tool that can handle any kind of entity export / import easily.

Thus I created this module, which will create two pages: /admin/entityexport and /admin/entityimport. The first one will present a form asks for three values: The entity_type, entity name, and the field which contains the id value of the entity objects you intend to export. For example, I have a profile type 'basic' on my site that contains, say 'First name' and such. If I specify, relatively, 'profile2', 'basic', and 'pid' in the form, the module will serialize the basic profile of all the users who have created one, into JSON string.

With this JSON string, on a new site, you can then copy it into the form presented by /admin/entityimport, along with specifying that it was generated from entity_type 'profile2', and automatically, all the user's profile data will be inserted back into the database of the new site.

This module right now is extremely simple, have many shortcomings, and not extremely easy to use (you sometimes need to peek into your database to find out the name of field that holds the ID value), but it serves its purpose for me. If I have some entityform, some registration, and a few content types, I can migrate all the content with just a few copys, pastes and clicks, as long as the the structure of the entities stays the same.

One caveat tho, certain data needs to be migrated first to make drupal and entity api happy. I would just manually copy the following tables from the old database to the new one:

  1. users
  2. users_role
  3. file_managed
  4. file_usage
  5. amazons3_file (if you are using AmazonS3 module)

So I hope that you would find this module useful. Now my development model involves creating new features on new git branches, but every new feature development starts with a new site install. The features can be easily tested with real data by migrating entities from the live site, and if I'm happy with it, I simply merge the changes into the main branch, update the live site code, do a reinstall on the live site, and migrate everything back.