Like [Auto Nodetitle](http://drupal.org/project/auto_nodetitle) does. It would be ever-so-nice. Somebody will have to expand auto_nodetitle to be auto_entitytitle or something. You may want to look in the queue over there to see if work is in progress. I'm sure everybody wants it for every entity.
I would love to see this too. We are creating a site where the client wants the title to be the SKU concatenated with a required taxonomy term. Even if we could just make the title not required it would help.
Actually, it's not hard at all to do a simple rule that builds a title based on other fields. The [attached rule](http://www.drupalcommerce.org/sites/default/files/auto_title_products.ru...) builds a title based on the SKU. It listens to the "before saving a product" event, and just sets the title. Of course, this will override anything you may have in the title field. It also does not deal with the fact that the title field is required. A little form alter could fix that.
I have two types of products in the store and I only want to apply this rule to one of them. I thought I could add a condition, but when I tried the condition 'Entity is of Type', I can select Commerce Product, but there is no option to select a particular type of commerce product. I looked at the Commerce Extra Conditions module, but it doesn't seem to contain such a condition either. Any idea how I can accomplish this? Thanks again for your help.
Unfortunately there's quite a lot of confusion about what "type" means. Entity type is "commerce_product" or "commerce_order". *Bundle* type is what you want. To do that you do a data comparison on commerce-order:type and see if it's of the type you want.
That works great. I was able to create a new rule through the interface and it worked when I tested it. I just put dummy data in the title field so I could submit since it was a required field. Once the product was saved, my dummy data had been overwritten with the SKU. I will deal with the hook_form_alter and the concatenation of the SKU and the other field tomorrow. The other filed is a taxonomy term. This is all so new to me, but I am beginning to recognize how powerful it is. Thank you so much for your help.
Comments
Like auto_nodetitle
Like [Auto Nodetitle](http://drupal.org/project/auto_nodetitle) does. It would be ever-so-nice. Somebody will have to expand auto_nodetitle to be auto_entitytitle or something. You may want to look in the queue over there to see if work is in progress. I'm sure everybody wants it for every entity.
http://drupal.org/project
http://drupal.org/project/auto_entitylabel
http://drupal.org/project/title
What other fields? For
What other fields?
For product, the only base fields are title and SKU.
I meant any other added
I meant any other added field, like node reference, etc... any idea?
Subscribing
I would love to see this too. We are creating a site where the client wants the title to be the SKU concatenated with a required taxonomy term. Even if we could just make the title not required it would help.
Specific pattern easy to implement with rules
Actually, it's not hard at all to do a simple rule that builds a title based on other fields. The [attached rule](http://www.drupalcommerce.org/sites/default/files/auto_title_products.ru...) builds a title based on the SKU. It listens to the "before saving a product" event, and just sets the title. Of course, this will override anything you may have in the title field. It also does not deal with the fact that the title field is required. A little form alter could fix that.
Sounds like an excellent idea
This should do nicely. I will give it a try and let you know how it turns out. Thanks for your help.
Hit a little snag
I have two types of products in the store and I only want to apply this rule to one of them. I thought I could add a condition, but when I tried the condition 'Entity is of Type', I can select Commerce Product, but there is no option to select a particular type of commerce product. I looked at the Commerce Extra Conditions module, but it doesn't seem to contain such a condition either. Any idea how I can accomplish this? Thanks again for your help.
Bundle type: Use data comparison
Unfortunately there's quite a lot of confusion about what "type" means. Entity type is "commerce_product" or "commerce_order". *Bundle* type is what you want. To do that you do a data comparison on commerce-order:type and see if it's of the type you want.
Worked like a charm
That works great. I was able to create a new rule through the interface and it worked when I tested it. I just put dummy data in the title field so I could submit since it was a required field. Once the product was saved, my dummy data had been overwritten with the SKU. I will deal with the hook_form_alter and the concatenation of the SKU and the other field tomorrow. The other filed is a taxonomy term. This is all so new to me, but I am beginning to recognize how powerful it is. Thank you so much for your help.
Can you make that rule
Can you make that rule available again, please?
+1
+1
Or you could use this:
Or you could use this:
http://drupal.org/project/auto_entitylabel
Thamk you but one rule is
Thamk you but one rule is best.
This is rule "SKU to title"
This is rule "SKU to title" with php code:
{ "rules_before_saving_product_change_title" : {
"LABEL" : "Before saving product change title",
"PLUGIN" : "reaction rule",
"REQUIRES" : [ "php", "rules", "entity" ],
"ON" : [ "commerce_product_presave" ],
"DO" : [
{ "php_eval" : { "code" : "if(isset( $commerce_product-\u003Esku)) {\r\n$commerce_product-\u003Etitle = $commerce_product-\u003Esku;\r\n}" } }
]
}
}