Discussions

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.

What's missing?

Ryan Szrama
Posted: Feb 7, 2010

Comments

redben on February 8, 2010

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...

redben on February 8, 2010

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 : ...

Ryan Ryan Szrama on February 8, 2010

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.

kswan (not verified) on February 8, 2010

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.

Ryan Ryan Szrama on February 8, 2010

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.

redben on February 9, 2010

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 !)

Ryan Ryan Szrama on February 9, 2010

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).

redben on February 9, 2010

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

wthem on October 1, 2012

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.

wthem on October 1, 2012

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.