Drupal Commerce - The Need To Clone
Recently we've begun working with Drupal 7 on an e-commerce site and obviously I suppose we decided that Drupal Commerce was the way to go. On previous Drupal 6 sites we've used Ubercart and whilst we really liked using it thought that the fact that Commerce uses entities for its content types made more sense from a developers point of view. With entities we dont get the overhead of fields/funtionality that we don't necessarily need i.e. a product type has no need for comments etc that are an intrinsic part of Drupal 6 nodes. Now nodes are entities and product types are entities, each can be seen as an independent object type.
When we analysed the site we where going to build we realised that we would have to create mutiple Product Types to manage the different categories of product that made up the online store. The different Product Types are very similar and differ only on a few fields so when we had a Product Type created that all other Product Types would basically copy we had to create each of the Product Types with all the same fields and Product Displays manually. This is in itself is not a difficult task but as we needed quite a few Product Types it became a tedious and long winded process not least of all because we had to remember what field settings etc we had used.
This leads to the reason for this article, wouldn't it be great if we could have just cloned our base Product Type? in fact why not take it a step further and why not have the ability to clone any entity type? Personally I believe this should be part of the core functionality of Drupal 7 and if rumours are to be believed wiil at some point in the future become available.
In the meantime I thought I may as well look into how to go about this as Im sure we'll be doing more e-commerce sites or indeed other sites where the ability to clone an entity type may be of use. To keep this simple I've begun on limiting this purely to the Drupal Commerce Product Type. When I complete the code to do this over the next week or two I'll post my solution here for anyone to make use of if they find it useful.