I want to create duplicates of some Commerce Products with the goal of giving these products a new Product type. With great help (How to change the product type of selected Drupal Commerce products (without direct DB updates)?), I have managed to use the Views Rules module to create a Views loop that should iterate through a selection of Commerce Products and duplicating them (creating new entities) with the new product type.

All fields except one accept the data type "Text", and the variables created looks like [sku:value], [title:value] and so forth.

The problem is that I keep getting PHP errors like this:

Unable to create entity commerce_product": Invalid data value given. Be sure it matches the required data type and format. Value at commerce_product()->commerce_price: .

... telling me that the data format for the Commerce price field is wrong though. I have tried using "text" as data type (and also "Price", "Commerce product" etc.).

Whatever I do in the action part of the Views loop, I keep getting a numeric field for the price (I can't just paste [price:value] in the field). I can switch to "Data Selection input mode", and add something like commerce-price:base-price (if I use Price as data type for the price field in the variable settings for the Rules View in question) but that also ends with a PHP error like I described above.

What to do with the variable for the commerce price here?

EDIT: this is the price field I get in the Action part of the Views loop, no matter what data type I assign to the price field in the Rules View, including Integer (in the variables configuration). I have also tried to add an action that converts the price into an integer jag before the action that creates the new entity. If I switch to Data Selection there are no price fields to be found.

enter image description here

And if I toggle to Data Selection mode this is what I get. No price field can be selected.

enter image description here

It really seems impossible to use the price field in a views loop.

  • I tried your solution with no luck for the price field. I have learned a lot by experimenting with Views loops and Rules, but I am running out of time and for now I will just go for the simple solution to change the SKU (because it needs to be unique) for each of the products that I want to convert in an Excel sheet and import them with the new product type.
    – TBJ
    Commented Feb 15, 2017 at 15:31

1 Answer 1


Have a look at the Drupal Commerce issue about "Revise the way we handle price amount values". Especially comment nr 37 in it, which states:

The price field is and will continue to store price amounts as integers ...

So give it a try to use "integer" for your Commerce price field. If needed, also use a Rules Action like "convert the data type" (of that price field) to convert your actual input to an integer.

  • I think I have come to a dead end here. It really seems impossible to use the commerce price field in a views loop. See my Edit above. I have tried your suggestion to use Integer as data type and also to add an action that converts the price to an integer.
    – TBJ
    Commented Feb 16, 2017 at 7:58
  • I still don't give up ... Have you also tried to add a Rules Action like "fetch entity by ID" (if needed add the id of your old product as an extra field in your view)? After that action, atoken with the field of the old product must be available to select it in a subsequent rules action. PS: Allan Bean (apollo astronaut) would say "there has to be a way to do it" (do it = walk on the moon ...) Commented Feb 16, 2017 at 8:05
  • That actually gave me the token as promised :-). But still no luck, a bunch of error messages appeared, like Unable to get variable entity_fetched, it is not defined., so I tried to add a contextual filter in views... still trying
    – TBJ
    Commented Feb 16, 2017 at 8:41

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.