i have 3 different entities build with help of EntityApi module. They connected with each other with ID column in tables.

Entity - "Purchase"
Entity - "Catalog" has 'purchase_id' column in table
Entity - "Product" has 'catalog_id' column in its table.

What is the way to clone in one click some already active "Purchase" with all catalogs and product which it ccontains?


I believe node_clone can clone entities and their fields for you. There is an API to call it programmatically, or if you have Admin pages created for your entity I believe you can make a "save and clone" or "clone" button show up there.

  • Both not good for me. Lets say i have in purchase 3 catalogs with 100 products in each. Clone one by one manually not the way to do it. I would like to have script which will do it automaticcaly. – drupal2000 Jan 16 '13 at 20:44
  • what? node_clone clones the 1 entity and any sub-data as well. If you want to script it write a small php script (I did not small Module) and run that script via Drush. Or, make a module and use like views_bulk_operations module and node_clone. If you're cloning anything node_clone is the way to go. Good luck finding another approach ... – tenken Jan 17 '13 at 2:00
  • Thank you i will check node_clone more thoughrely may be i missed something. – drupal2000 Jan 17 '13 at 3:03


Check that out. You can use it by doing something like:

// Load the entity you want.
$entity = \Drupal::entityTypeManager()

// Copy it.
$duplicate = $entity->createDuplicate();

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.