Hi, firstly, thanks for your work on this excellent and promising module set!

I have question around panels integration.

For product display, it's great that you can select relevant fields from the related product on the product display node under 'display options'

However, those product fields aren't available when added "Node" fields to a panel - only the immediate product display fields are available.

Any idea / thoughts what could be done to make those fields from display options available as panel fields also?

Given some pointers, I may be able to provide a patch for this.

thanks again,

DT

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

EclipseGc’s picture

Assigned: Unassigned » EclipseGc
Status: Active » Fixed

David,

Not entirely sure what you're asking here, but the typical workflow would be, if you're referencing products from a node, you would add a product reference from the node you're viewing. Then the product's fields would be available for display on the node type.

This all works due to a lot of leg work in page_manager, however it does not yet account for anything other than a 1 to 1 ratio of products to nodes. I do intend on fixing that soonish, but have not yet had a chance.

If this doesn't answer your question then please mark this issue as active again and be a bit more specific.

Eclipse

davidwhthomas’s picture

Hi Eclipse, thanks for your reply.

The problem is perhaps best illustrated with a screenshot.

Basically, I'm wanting to display product fields in a node view override panel for the product display node.

Panels only shows the fields directly on the product display node type, not the referenced fields on the product.

Do the attached screenshots help?

I'd like the 'display option' fields from the second screenshot to be available to add to the panel pane in the first screenshot.

thanks again,

David

EclipseGc’s picture

Status: Active » Fixed

Right, visit the "contexts" area for the variant, add a relationship to the product entity via your product reference field, and then you'll have a "Commerce Product" entity section in the content_type selector (i.e. all the product fields will be available).

Hope that helps.

Eclipse

davidwhthomas’s picture

Awesome, that's the one, works perfectly!

Thanks so much for the help.

cheers,

David

Status: Fixed » Closed (fixed)

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

amcc’s picture

i'm doing the same thing here and have got the "Commerce Product" entity section now so thanks for that.

BUT... if you have multiple products referenced the nice AJAX that updates the product price and other product fields does not work.

I assume this is because its not all being added as one thing, the form and product fields have to be added separately in panels.

any ideas

EclipseGc’s picture

I'm actually hoping to fix that next week. We're doing a sprint in Colorado for the week leading up to drupalcamp colorado, and that particular issue is the one I want to fix.

courtney.mob’s picture

amcc, I'm having the same issue. I'm glad to see someone is working on it. EclipseGc, thanks for the support. This is what I really love about the Drupal Community.

EclipseGc’s picture

For those of you following this, the actual progress that's being made here can be tracked at #1182712: Page Manager Integration (postponed pending a ctools patch).

amcc’s picture

Well done for all the great work on this. Meanwhile I've gone back to hand coding node.tpl files. That still works great and sometimes is even easier. But I do love panels all the same.

courtney.mob’s picture

Any update on this?

James A’s picture

Hi, I am trying to use panels with Drupal Commerce and have run into the issue outlined above where with multiple products my call to "Commerce Product from Node (on Node: Product)" doesn't update when I change the selected product.

I have tried following the Page Manager Integration link with the patches but they don't appear to work for me, the last one does patch to commerce_product_reference.module and creates product_field_from_entity.inc but didn't fix the issue. I then went back up the post assuming I also had to apply the patch for entity_field.inc but this no longer appears to work, failing during the patch routine.

If you can give any further advice or help on this it would be much appreciated.

maxplus’s picture

Issue summary: View changes

Hi,

did anyone find the solution for panels in combination with different product variations inside one product display node?

I have the problem that many others have that when changing an attribute in the add to cart form, several components (like the product image inside the product variation) disappear or other product specific fields there appearance changes...

Even when I add a panel pane of rendered entity of a product display node, it does not react well when changing attributes in the add to cart form.

mlundager’s picture

I have exactly the same problem as #13

Fred E’s picture

This may not fit your exact setup, but I hope it helps. I have a Panels page with the add to cart form in one pane and a Views content pane in another. The Views pane is a slideshow for images of the currently selected product variation. When the add to cart form option is changed, the view needs to be refreshed. This can be done by running hook_commerce_cart_attributes_refresh_alter and adding an AJAX command. I just discovered "RefreshView, " which does the trick. Here is an example:

function my_module_commerce_cart_attributes_refresh_alter(&$commands, $form, $form_state) {
  $commands[] = ajax_command_invoke('#my_view_id', 'trigger', array('RefreshView'));
}

Depending on your view, this might be enough. It wasn't for me because I needed to update the argument for the contextual filter in my view. Based on comments in #1781988: How to ajax refresh a view?, I opted for a custom ajax command and changed the above to this:

function my_module_commerce_cart_attributes_refresh_alter(&$commands, $form, $form_state) {
  $commands[] = array(
    'command' => 'myRefreshView',
    'data' => array(
      'my_view_name',
      $form_state['default_product']->sku,  // or your contextual filter value
    ),
  );
}

In a separate js file I then wrote my custom command to first reset the views argument and then call RefreshView:

 (function ($) {
    // Provide new command for Drupal's Ajax framework.
    Drupal.ajax.prototype.commands.myRefreshView = function(ajax, response, status) {

	// caller passes view name and sku
	var viewName = response.data[0];
	var sku = response.data[1];

	// for convenience
	var views = Drupal.settings.views.ajaxViews;
	var keys = Object.keys(views);

	// for the view object with view_name set to viewName, update the view_args to the sku
	// and make the call to RefreshView
	for (var i in keys) {
	    if (views[keys[i]]['view_name'] == viewName) {
		// reset the view_args value
		views[keys[i]].view_args = sku;
		// call RefreshView to reload the new images
		$('.view-dom-id-' + views[keys[i]]['view_dom_id']).trigger('RefreshView');
	    }
	}
    };
}(jQuery));

Remember to use drupal_add_js to include your js file. I attached mine to the add to cart form with hook_form_FORM_ID_alter.

heddn’s picture