Product Reference Field Specification
So, as I've been implementing the product reference field based on the prior specification, I'm realizing it wasn't specified enough. At the very least, having a guiding document that tracks the way this differs from a node reference is necessary. To that end, I've boiled down the basics of the field itself (not necessarily all its display formatters):
The Product Reference Field functions similar to the core Term Reference field and contributed User and Node Reference fields. It stores any number of product_ids associated with the object the field is attached to. The available products for reference should be limitable either by product type or by the results of a View. The field should have selection widget options including a select list, checkboxes, and an autocomplete field. The autocomplete field would allow the user to start typing either a product SKU or title and see an autocomplete listing in the format of "SKU: Title" that when selected reduces to the SKU (which it uses to validate the entry, reducing it to the product_id for storage). The field will have several different display formatters, including plaintext and link lists of SKUs and Titles, an Add to Cart form, and an Add to Cart link that may itself be either a text link or an image.
That's all what is needed
This seems complete enough, any other feature/display formatters would have to be on contrib !
PS: Have a nice trip to Paris
reference products through view
One thing that is missing from node reference field when you choose to limit options by using a view is the ability to expose the selected view's filters in the node creation form.
It would be nice if the product reference field allowed you to specify a view and have its exposed filters presented on the node add form. I think node relationship module implements something similar but using a popup. This could be contrib though...
So you talked about - inner
So you talked about
- inner workings (like user/node reference)
- configuration : limiting by product type or views
- widget : select list, checkbox and autocomplete
- Display : display formatters ; plain text, links, add to cart, add to cart link
I suggest you add some info about third party modules integration :
- tokens : availabe tokens
- views : ...
Good call. DamZ just
Good call. DamZ just mentioned core Token integration in IRC today. Definitely need to take that into account and might go ahead and get the hooks started this evening.
As I am sure you know, the
As I am sure you know, the nodereference module is hard-coded to lookup only the title. I created the super_nodereference module (http://github.com/kswan/super_nodereference) to remove some of the limitation in nodereference.
Unfortunately, I haven't had much chance to get into D7 yet, so I don't know what it would take to get super_nodereference ready for D7.
I don't think super_nodereference completely meets your specification, but it is much closer than nodereference.
Thanks, kswan! I'll check it
Thanks, kswan! I'll check it out if I get stumped, but I also just discovered there's a core Taxonomy Reference field that's proven to be a great example, too.
I think it also makes oodles
I think it also makes oodles of sense for the autocomplete callback and validation routines to be in commerce_product.module, just like Token support. This autocomplete will certainly be used by more than just the Product Reference field.
I am thinking about starting
I am thinking about starting a little module "entity reference" widget that would be used generically. It is just one more level in the knowledge chain ( entity -> entity instance type -> entity instance)
The extra settings it would have is the entity choice.
Unfortunately i don't expect myself to release it any time soon (time, time, time !)
hehe It's not a bad idea,
hehe It's not a bad idea, for sure. In fact, I'd love you even more if you did an Entity Import / Export module. ; )
Technically, I'm not sure what an instance of an entity is called... an object? Whatever you end up calling it, I'd base it on the core Taxonomy Reference code... very handy! I honestly don't think it would be too difficult for you to achieve, it just could risk being too generic to be useful (i.e. it'll be hard to have entity specific displays).
It's the display where it is going to be problematic...maybe display formatter based on entity view modes since that is the only place we're quite sure entities will have
It seems that product
It seems that product reference field is limited to 2048 characters. I have "bulk generated" at about 192 products which are total 3154 characters. When I save the product display I get an error telling me that (autocomplete) product reference field can only have 2048 characters.
OK. Solved. This limitation
OK. Solved. This limitation takes affect only when the product reference field widget is set to "autocomplete". Use checkboxes widget when you have to reference a lot of products.