After updating from 7.x-2.3 to 7.x-2.6 I ran into the following problem:

I started with a fresh Commerce Kickstart 1 installation. I created a Rules Component with the action: Fetch Entity by Property:
Entity Type: Node
Property: Product (= product reference field)
Value: line-item:commerce-product:product-id

This worked fine untill I updated rules. Than I got the error: The data type of the configured argument does not match the parameter's value requirement.

For a complete explanation of my use case see: http://www.drupalcommerce.org/questions/10798/how-subscribe-customer-org...

Mike.

Comments

sportel’s picture

Could someone confirm that something between 2.3 and 2.6 has changed that causes this error?

sportel’s picture

Priority: Normal » Major
sportel’s picture

I've installed a fresh Commerce Kickstart 1, which comes with Rules 7.x-2.3. My rules work fine. Then updated to Rules 7.x-2.4, and then I get the error already. So, the bug was introduced in 7.x-2.4. I'll try to investigate further, but haven't got the skills to find errors in the code I'm afraid.

I hope someone can help?

benjifisher’s picture

I am getting the same error message, and I think I have found a way to fix it. This is obviously a kluge, but it works for me and I tried many different variants, none of which worked. If you have an entity reference parent -> child, then to find the parent from the child, add the following actions to your rule:

  1. Fetch entity by property: Fetch node with node:nid = child:nid
  2. Add a variable: Type = list of nodes, value = [node]
  3. Fetch entity by property: Entity type = node, Property: <your Entity reference field>, Provides variable: parent

I hope it works for you.

sportel’s picture

Hi benjifisher,

Thanks for your response. Do you have the same use case as I have? I'm not quite sure how to fit in your adjustments to my existing rules components. Could you provide an export of your rule?

Thanks,

Mike.

Ravenight’s picture

I found the patch that broke this.

I went back and installed 7.x-2.3 and patched the files to make rules 7.x-2.4 manually one by one testing to see where the issue started.

This is the patch: https://drupal.org/node/2058037
Before this is applied on 7.x-2.3 you can get the Node by property using the Product Reference field, after you apply the patch you get the error: "The data type of the configured argument does not match the parameter's value requirement." just by saving the already saved rule.

The workaround is to create a variable of type: "List of commerce Product items" and use this as the "The property value of the entity to be fetched." when fetching the node.

sportel’s picture

Nice work Ravenight! I have reported this back at the issue of the suspected patch.

Thanks,

Mike.

sportel’s picture

Status: Active » Needs review
checker’s picture

Status: Needs review » Active

Status should be active. Needs review is only possible if there is an patch to review.

travist’s picture

Status: Active » Closed (works as designed)

After debugging, I discovered that this isn't really an issue. Within the tutorials, it tells you to use the Product-Id, but the issue is that the product ID is type "integer" while the Product reference is of type "commerce_product". The patch that you are referring actually FIXES the problem where instead of showing a type of "commerce_product", it would show a type of "unknown" and as it turns out the Rules type check skips parameters that are of type "unknown".

The FIX here is to actually fix the Rule to instead of refer to the line-item:commerce-product:product-id to instead only refer to the line-item:commerce-product since that is the same type as the Product reference of "commerce_product".

I propose to close this issue since it now works as designed.

checker’s picture

In my case this is not possible. I have an entity reference field for product for bundles. This field lives in the commerce_product entity type.

I have a rule that fires on "After updating an existing commerce product".

This rule should show all products that reference to the current updated product. Therefore i'm using "fetch entity by property". So i can fetch easily all products that have current product id stored in their entity reference field. But here i'm not allowed to use commerce-product:product-id or commerce-product of the current updated product (since #2058037: Support all entity properties in the entity query action.)

Current product 1 id
<- referenced by product A (field value is product 1 id)
<- referenced by product B (field value is product 1 id)

Result is a list of product A and product B.

philipz’s picture

Thanks @Ravenight - #6 did the trick!

deggertsen’s picture

Status: Closed (works as designed) » Active

I'm in the same boat as @checker. Did you ever find a solution? I'm tempted to revert the patch in #2058037: Support all entity properties in the entity query action..

Here's my rule, could somebody look at it and figure out if there is a way to fix it? The solution in #10 does not work as line-item:commerce-product (or eventproduct in my case) is not available either.

The summary of my rule:

On {Completing the checkout process}
Do {
Mark registration entities associated with this order as complete
Fetch Registration Entity that references this order
Loop through all found registrations {
Fetch the product that hosts the registration entity by id
Fetch the content entity that references the product id by the product reference field property (This is the broken part)
Run a Rules Set that requires the Completed order , Registration entity, and Content entity
}
}

deggertsen’s picture

StatusFileSize
new123 bytes

Forgot to attach my full rule. Until I hear back on this, I'm going to revert the patch in #2058037: Support all entity properties in the entity query action..

sportel’s picture

@travist,

The error message says something about the data type. The product ID is of type Integer, but "commerce_product" isn't a data type. Do you mean that the Entity Reference field references a String data type? In that case: to what String on the Product entity is the Entity Reference field referencing?

joran lafleuriel’s picture

Hi all

I am not using commerce kiskstart but I a have the same kind of issue :
"Fetch entity by property" doesn't support a dynamic value that would come from a variable set before.

In my case, I want to retreive entities that all refer to another one [ crm core contacts that belongs to a group ]

So... If the "Fetch entity by property" value is filled by a static value ...as a test... it works fine...

But I need this value to change dynamicaly [ from in the context of the node that launch the rule link...]
Setting a rule variable before and put it in the value UI doesn't work. The UI says 'Unknown data type'.

Why "Fetch entity by property" can't accept a simple integer variable that is entity-id ?

Rules 7.x-2.7+6-dev
Drupal version 7.31

deggertsen’s picture

StatusFileSize
new1.88 KB

CRAP! I just realized the file I posted above was bogus. Hate it when you accidentally save the wrong file. Here is the correct one!

fehin’s picture

I have the same use case as @Sportel. I'm trying to add user to a group after an order. Has anyone gotten this to work?

deggertsen’s picture

This is still a problem. Still having to revert patch applied in #2058037: Support all entity properties in the entity query action. in order to fix the problem.

deggertsen’s picture

@travist. I have tried to use "line-item:commerce-product" and it still throws the error "The data type of the configured argument does not match the parameter's value requirement." There is obviously something else going on here.

FranCarstens’s picture

I'm not sure if my issue is related but it certainly looks like it. When attempting to create a calculation rule my custom variables are not available for "Input Value 2" and any values from the list (randomly added for testing) fail with "The data type of the configured argument does not match the parameter's input_2 requirement".

milena b’s picture

Hi,

I had line items that had Price field. I need to calculate the total price of selected items.(Pizza toppings tutorial on Youtube)
When I displayed line items as radio buttons, I had the same error message when creating a rule.

Loop
Parameter: List: [commerce-line-item:field...
Error: The data type of the configured argument does not match the parameter's list requirement

Then I switched the display to check-boxes I was able to create the rule.

Hope this helps to find the bug.

netw3rker’s picture

This may or not be related, but I just ran into a situation where a module I'm using creates multiple data types of a main generic type, and defines an action that could use any one of those specific data types as a parameter.

It turns out our module wasn't defining the "parent" key in hook_rules_data_info(), and as such the action couldn't use the mapping. Here's some pseudo code to describe the problem:

function example_rules_data_info(){

  $data_info = array(
    'ExampleData' => array(
      'label' => t('Example', array(), array('context' => 'data_types')),
      'group' => t('Example', array(), array('context' => 'data_types')),
    ),
  );

  $data_info['ExampleData<type1>'] = array(
    'label' => t('Example data of the first kind'),
    'ui class' => 'ExampleDataUIclass',
    'group' => t('Example', array(), array('context' => 'data_types')),
  );
  $data_info['ExampleData<type2>'] = array(
    'label' => t('Example data of the second kind'),
    'ui class' => 'ExampleDataUIclass',
    'group' => t('Example', array(), array('context' => 'data_types')),
  );
  return $data_info;
}

function example_rules_action_info() {
  $action_info = array(
    'example_do_something' => array(
      'label' => t('Does a thing'),
      'group' => t('Example'),
      'parameter' => array(
        'testparam' => array(
          'type' => 'ExampleData',
          'label' => t('Data to use'),
          'description' => t('this data will be used for this action'),
        ),
      ),
    ),
  );
  return $action_info;
}

with that, creating a rule that uses the 'example_do_something' action and passing in a parameter of the data type 'ExampleData', the system will throw the referenced error when you attempt to save the action. This is because there's an undocumented "parent" key that is required in this kind of setup. Without it, rules doesn't know that 'ExampleData' is a more specific version of 'ExampleData'.

Simply adding the 'parent' key fixes the problem:

function example_rules_data_info(){

  $data_info = array(
    'ExampleData' => array(
      'label' => t('Example', array(), array('context' => 'data_types')),
      'group' => t('Example', array(), array('context' => 'data_types')),
    ),
  );

  $data_info['ExampleData<type1>'] = array(
    'label' => t('Example data of the first kind'),
    'ui class' => 'ExampleDataUIclass',
    'group' => t('Example', array(), array('context' => 'data_types')),
    'parent' => 'ExampleData',
  );
  $data_info['ExampleData<type2>'] = array(
    'label' => t('Example data of the second kind'),
    'ui class' => 'ExampleDataUIclass',
    'group' => t('Example', array(), array('context' => 'data_types')),
    'parent' => 'ExampleData',
  );
  return $data_info;
}

In regards to your problem @deggertsen, My guess is that to fix your problem, you should first check to see if the parent key is being defined for your "line-item:commerce-product" data type. If it's not, you can try adding it in through hook_rules_data_info_alter(). If that fixes it for you, then relay that back to the DrupalCommerce people to fix in their modules.