The usability issue I have been struggling with (as you know!) is the separation of Product Entities and Product Display Nodes. Whilst there's no question that this is a good thing and give us great flexibility, it adds complexity that can make setting up a simple store complicated for a new user.

I propose that we create a new rule event that creates a simple product node display based on a newly created product. Whilst this won't be needed in every case, it could be something that's set up in the install profile for a "simple" site.

Creating this issue so I can submit a patch.

Comments

ikos’s picture

StatusFileSize
new1.17 KB

Patch to add this action.

ikos’s picture

Assigned: ikos » Unassigned
Status: Active » Needs review
xibun’s picture

great idea - I believe this should be on by default. at first review (of Drupal Commerce) I lost quite some time "finding" my created products. I believe without such a function new users might give up on Drupal Commerce.

thill_’s picture

I have two questions about this.

1. Would it work with something like http://drupal.org/project/commerce_feeds where the products are not created through the UI. I guess it depends if the the module creating the entity does it the same way as the UI does.

2. Is there a way to group products. For instance if I import 15 product entities and I want 5 grouped in each of three node it seems like i could indicate which entities on my csv should be grouped.

ikos’s picture

The idea behind this patch / rule is for the absolute basic use case where a beginner user just wants a display version of their product- it might help get through the early learning curve.

Once the user understands the concept, they would be able to make more "powerful" display nodes manually.

On the feed issue, I think this would work as the rules trigger should be activated by feeds creating a new entity.

rszrama’s picture

Status: Needs review » Needs work

I think we may be able to do this without a custom action... although setting a product reference field value through Rules has been hairy for me thus far. Also, do you think there needs to be some option to redirect to the edit form of the newly created node? Maybe we can get a list of the workflow - I think Bojhan wanted to review this today, too.

pcambra’s picture

rszrama’s picture

Title: Create a new rule event that will automatically create a product display node when a new product is created » Automatically create a product display node when a new product is created
Component: Product » Contributed modules
Status: Needs work » Postponed

Hmm, so I think this is a contributed module concern, not the concern of the core modules. Switching the component but leaving postponed in case anyone wants to start such a project and move this issue to it.

WilliamV’s picture

What is the best approach: creating a node that autocreates a product or creating a product that autocreates a node?

This is an ingenious action and needs to be considered immediately?

Thx & Grtz.

rszrama’s picture

It can go either way... really depends on the site. Additionally, such a rule really won't work unless the module it's a part of defines the node type that should have the product reference field. But either way, Rules will support it.

WilliamV’s picture

So it can be applied with current state of modules?

As i understand, for each product there must be a product display so... this is a superb way in approaching this vision no?

Thx & Grtz.

WilliamV’s picture

Please advise.

torgospizza’s picture

Ryan, we talked about this a little at DrupalCon. Is what you're saying here - about Contrib space - still valid after talking about it? I forget what your conclusion was but either way, I'm gonna subscribe to this thread :)

EDIT: This seems to be related and includes an exported Rule that may be a viable solution: #971484-16: Using Rules to reference the newly created product in a product_reference field

pachus’s picture

did someone tried that rule? couldn't make it work.

anthonyR’s picture

Using the patch from #1 in a custom module. It's working for my simple testcase.

oz_an’s picture

In my case I had to change $node->field_product['und'][0]['product_id'] ... to $node->field_products['und'][0]['product_id'] .... Thank you for the patch.

rfay’s picture

Status: Postponed » Fixed

I hope everybody here knows about the new Commerce Product Display Manager, which is a very nice way to do this.

In fact, I'll call this fixed because of that and the processes mentioned in this issue.

torgospizza’s picture

Brilliant! Thanks for letting us know, Randy!

Status: Fixed » Closed (fixed)

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

vthirteen’s picture

Status: Closed (fixed) » Active

one of the main problems of the rules method and the http://drupal.org/project/commerce_product_display_manager module is that there's no automatic way to set a taxonomy for a product display.

so, what about at least an option (or a rule?) to redirect from the completed commerce product creation form to the edit form of the product display, possibly prepopulating at least the product reference field?

it would still be a 2-step process, but at least users wouldn't get lost in between from the 1st step (commerce product creation) to the 2nd (product display creation).

setting this issue as active again, just in case.

rszrama’s picture

Status: Active » Closed (fixed)

I'd just go ahead and post your issue as a feature request to that module. From a Rules standpoint, there's already the ability to redirect to different URLs (such as node/[nid] of the newly created display node), so there's nothing from a core Commerce perspective more that needs to be done here.

carn1x’s picture

subscribe

jax’s picture

flefle’s picture

ikos: Works like a dream, thank you! I've had to fish out the code and put it within Drupal commerce kickstart file at (as):

"profiles/commerce_kickstart/modules/commerce/modules/line_item/commerce_line_item.rules.inc":

function commerce_line_item_rules_action_info() {

/* custom action to create product display at product start */
  
  $actions['create_product_display'] = array(
      'label' => t('Create a simple product display node'),
      'parameter' => array(
        'commerce_product' => array(
        	'type' => 'commerce_product', 
        	'label' => t('Product', array(), array('context' => 'a Drupal Commerce product'))
        ),
      ),
      'group' => t('Commerce Product'),
      'callbacks' => array(
        'execute' => 'commerce_display_product_create_method',
      ),
   );
  /* custom action to create product display at product end */

// ...
}


/* Product display and product link creator start */

function commerce_display_product_create_method($product){
	$node = new stdClass();
	$node->type = 'product_display';
	node_object_prepare($node);

	$node->title    = $product->title;
	$node->language = LANGUAGE_NONE;
	node_save($node);

	$node->field_product['und'][0]['product_id'] = $product->product_id;
	node_save($node);
}

/* Product display and product link creator end */

Thank you!

flefle’s picture

Here's the patch to it:

total_slavery’s picture

the patch don't work when i try to apply it i get
fatal: corrupt patch at line 53

bogdan1988’s picture

For automatic product display creation and synchronization you can use this module http://html-and-cms.com/blog/drupal-commerce-automatic-product-display-g...

jax’s picture

Just created a sandbox module that does this: http://drupal.org/sandbox/jax/1920656
I need to test it somewhat more before I promote it to a full project.

And of course, it already existed, http://drupal.org/project/commerce_auto_product_display

summit’s picture

Hi, what is the difference betweeen this sandbox and commerce_auto_product_display please?
Thanks a lot in advance for telling this.

greetings, Martijn

sportel’s picture

Hi Jax,

Whats the difference between your sandbox module and Commerce Auto Product Display?

Thanks,

Mike.

jax’s picture

I haven't tested the commerce auto product display yet but at first glance the main difference is that my module completely replaces the node edit form. If you're viewing a product display and click edit you will actually be editing the product instead of the product display.

In that setup you don't even have to explain the concept of product displays to the people that will be managing the products. As site builder you create a product display, link it to the product and in the module's configuration you indicate that it should be managed by the commerce_simple module.

Then the people that need to manage products can only add products and when they click edit on the product display view page they will be editing the product. It completely hides the product display concept.