I wonder how I can access all of the line item properties in Rules?
For example in a Rules event "Before saving a line item" I can show a debug message of the line item. It has different properties such as commerce_display_path and data->context->entity which however aren't available in Rules ie. I cannot set them as variable for later processing.
How could I make these properties available to Rules? I've tried to add different conditions to make sure the "whole entity" is loaded to Rules but still I cannot access these properties.
EDIT 1
I've now tried to develop a solution to provide this data to Rules. Following enables only entity(field collection item) id and entity revision and nothing else. I thought that it would provide the whole entity and it's properties (or at least so I understood from documentation that all that entity__property_info returns).
EDIT 2
Now I can set a message on site that presents host entity properties. However, I cannot use those properties in any other rules functionality eg. I cannot create variable from field regarding field collection item i.e. I still cannot make use of them. Why the properties are available for message but not for anything else?
function mymodule_entity_property_info_alter(&$info)
{
if (isset($info['commerce_line_item'])) {
$info['commerce_line_item']['properties']['host_entity'] = array(
'label' => 'Host entity',
'type' => 'field_collection_item',
'description' => t('Host entity of a line item.'),
'getter callback' => 'mymodule_get_host_entity_callback',
'setter callback' => 'entity_property_verbatim_set',
'computed' => true,
);
$bundles['field_collection_item'] = array('label'=>'Field collection item', 'properties'=>entity_get_all_property_info('field_collection_item'));
dpm($info['commerce_line_item'], 'line item in entity info alter');
}
}
function mymodule_get_host_entity_callback($entity, array $options, $name, $entity_type)
{
dpm($entity, 'line item entity in Rules callback');
$wrapper = entity_metadata_wrapper($entity_type, $entity);
$host_entity_id = $wrapper->data->context->entity->entity_id->value();
$host_entity_type = $wrapper->data->context->entity->entity_type->value();
$host_wrapper = entity_metadata_wrapper($host_entity_type, $host_entity_id);
$host = $host_wrapper->value();
return $host;
}
function mymodule_set_host_entity_callback($entity, array $options, $name, $entity_type)
{
$wrapper = entity_metadata_wrapper($entity_type, $entity);
return $wrapper->host_entity->value();
}