Hello,
I have a node content type with a line_item reference field.
On a line item deletion event, i need to delete all the nodes referencing the line_item being deleted.
So I have the following rule :
{ "rules_synchronize_stock_entries_line_item_deleted" : {
"LABEL" : "Synchronize stock entries (Line item deleted)",
"PLUGIN" : "reaction rule",
"TAGS" : [ "stock" ],
"REQUIRES" : [ "rules", "entity" ],
"ON" : [ "commerce_line_item_delete" ],
"IF" : [
{ "NOT data_is_empty" : { "data" : [ "commerce-line-item:order" ] } },
{ "OR" : [
{ "data_is" : { "data" : [ "commerce-line-item:order:state" ], "value" : "completed" } },
{ "data_is" : { "data" : [ "commerce-line-item:order:state" ], "value" : "pending" } }
]
}
],
"DO" : [
{ "entity_query" : {
"USING" : {
"type" : "node",
"property" : "field_stock_entry_line_item",
"value" : [ "commerce-line-item" ]
},
"PROVIDE" : { "entity_fetched" : { "entity_fetched" : "Fetched entity" } }
}
},
{ "LOOP" : {
"USING" : { "list" : [ "entity-fetched" ] },
"ITEM" : { "list_item" : "Current list item" },
"DO" : [ { "entity_delete" : { "data" : [ "list-item" ] } } ]
}
}
]
}
}
It seems like the "Fetch entity by property" doesn't manage to properly query on the line item reference field.
In entity.property.inc in rules, the function entity_property_query() action function calls
return $info['query callback']($entity_type, $property, $value, $limit);
but $info['query callback'] is set to FALSE by this line earlier in the code, because $properties[$property]['schema field'] doesn't exist
$info = $properties[$property] + array('type' => 'text', 'query callback' => isset($properties[$property]['schema field']) ? 'entity_metadata_table_query' : FALSE);
and $properties is filled up with entity_get_all_property_info() which gathers information for the entity and its bundles
$properties = entity_get_all_property_info($entity_type);
Could this issue be related to #1356006: Fix entity property info of product / customer profile / line item reference fields or #1306106: Can't load nodes via a product reference in a rule ?
Any help is appreciated !
Thanks
| Comment | File | Size | Author |
|---|---|---|---|
| #2 | 1358760_line_item_reference_property-2.patch | 658 bytes | pcambra |
| #1 | Capture d’écran 2011-12-02 à 12.37.40 AM.png | 68.01 KB | liupascal |
Comments
Comment #1
liupascal commentedIf it can help here is the rule log
Comment #2
pcambraCan you try if it works with this patch?
Comment #3
liupascal commentedit LOOKS like it's not changing anything, I have to do more testing.
I'm starting to think that my rule is not correctly configured ...
Can I fetch all the entity which field value is equal to a variable, then loop over that list of entities and delete them ?
In code it would look like this :
Does this rule export seems to do the same thing as this code ?
Comment #4
liupascal commentedNever mind #3 first line - it is working.
The patch does fix the issue.
I still need to work on the rules though...Comment #5
pcambraMarking this as duplicate of #1356006: Fix entity property info of product / customer profile / line item reference fields as for #1356006-9: Fix entity property info of product / customer profile / line item reference fields