Here's the plan:

Every time a product_reference_field switches to a product_reference_view widget we instantiate a "corresponding" viewfield instance.

For example:

a. product_reference_field "field_testa" switches to product_reference_view widget we create a field called field_testa_view
http://drupal.org/node/1256820#comment-4906976

Comments

chriscalip’s picture

Update .info file to add entity api and viewfield module

chriscalip’s picture

update .install schema

a.) remove existing table.
b.) add new schema product_reference_view
columns :
1.)commerce_product_reference (field_id)
2.)view_field(field_id)
3.)status (bool active/inactive)

chriscalip’s picture

Priority: Critical » Normal

Module Logic and processes for event "Any Change of Widget on field Commerce Product Reference"

search drupal api or entity api
a.) add product_reference_view widget specific stuff to do on event "Any Change of Widget on field Commerce Product Reference"
1.) add/modify record on schema product_reference_view (prv) -- first see if the field id has an existing record on prv , if not create corresponding viewfield instance and name it as [(commerce_product_reference)field_name]_view; add record on prv
$prv = array('commerce_product_reference'=>$cpr_field_id, 'viewfield'=>$viewfield_id,'active');
drupal_write_record($prv);

Reserved Product Reference Source View.
reserved field: field_rsrvd_prdref_srcview
also implement hook_install to create a field type 'viewfield' fieldname => field_rsrvd_prdref_srcview strictly for this module purposes and modify hook_uninstall to drop said field on uninstall process of this module.

chriscalip’s picture

search entity api
alter display properties ( disable ) of any viewfield found active in schema product_reference_view

chriscalip’s picture

On node create/edit form on field using widget product_reference_view disable display of field edit element.

create widget property of product_reference_view copy node crud form of commerce_product_reference (hidden).

chriscalip’s picture

create hook_entity_presave/hook_node_presave funnel array of product ids results from source viewfield to 'corresponding' commerce_product_reference

** be sure to refer to schema product_reference_view;

chriscalip’s picture

disable and removed any existing settings function for product_reference_view in the field settings form.
We let viewfield handle that part of the puzzle.
settings for this widget is only http://drupal.org/node/1260046#comment-4907274

chriscalip’s picture

Priority: Normal » Critical
chriscalip’s picture

create a no display formatter for the viewfield module; we don't want those corresponding source viewfields to be rendering.
scratch this comment, every field type has a formatter of hidden.

chriscalip’s picture

Priority: Normal » Critical

on event "Any Change of Widget on field Commerce Product Reference" instead of making use of product_reference_view schema make use of existing drupal resources from field_info_instances.
update logic of node crud form too.

chriscalip’s picture

Version: » 7.x-1.x-dev
Status: Active » Fixed

done.

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.