It would be useful to have subtypes of products--e.g., apparel product type inherits tangible's methods, rather than having to repeat the code in the new module.
Attached is a draft implementation. Product type modules can register parent types through a new productapi $op, 'parent_ptypes'. When registered, parent types are called when a child content type's methods are called.
Implementation details:
* All productapi calls for a particular product type now go through product_invoke_productapi.
* product_invoke_productapi cycles through parent products, using different approaches depending on the expected data types (concatenating strings, merging arrays, etc.).
* a new function product_wizard_select_options helps conctruct nested select lists, similar to how taxonomy selects work.
Still to consider: how to display themed results when there is more than one type's info being displayed?
| Comment | File | Size | Author |
|---|---|---|---|
| #1 | apparel.module | 669 bytes | nedjo |
| product-subtypes.patch | 16.75 KB | nedjo |
Comments
Comment #1
nedjoHere's an example of what a 'child' product type module would look like, that can be used for testing. When you enable this module and have applied the above patch, apparel gets all the functionality of tangible ('shippable product'). Of course, the point would be to add something extra in apparel.module, which I haven't done in this example.
Comment #2
Eglish commentedduplicate
http://drupal.org/node/35071
Comment #3
nedjoThis is not a duplicate. This patch creates subtypes, not subproducts.
Comment #4
Eglish commentedSorry nedjo, my mistake. How is the development of this patch coming along?
Comment #5
nedjoNo prob, the two ideas do look similar.
Well, I don't think anyone has had the time to review it. I'll need to rework this once the 4.7 updates are done.
But any comments meantime welcome!
Comment #6
nedjoI'm starting work on a 4.7 version of this patch.
Comment #7
nedjoComment #8
alynner commentedHello
I've just installed this patch (http://drupal.org/files/issues/product-subtypes.patch) and am trying out the apparel.module provided, but I don't really understand it. I made the ability to add Apparel items but I don't see any parent objects or wizard select. How/where does the apparel_productapi() function get called to determine the $op?
I noticed that when I create a new product, I have the option to choose 'apparel product' under 'choose type of product to create' but I'm not sure the significance of this. Is that all it's supposed to do? I was hoping to make a select list myself with whatever items I wanted.
Perhaps I don't understand the purpose of the patch?
Sorry if I'm slightly ignorant here, it looks like a really good module/patch, I just need some assistance with it.
Cheers,
Alynner
Comment #9
fgmReclassified: uses the 4.6 API.
Comment #10
simeI'd defer to gordon's plans to do something similar with the product type.