i'm not sure if this is an entity or rules issue but it's the same address anyway:
attempting to solve #1313468: I can't access my custom product options from rules (see notes there) i made a property that returns a list of "commerce_option"s (see patch).
all fine.

when in rules i access something like lineitem:options:0 i get an unwrapped(!) commerce_option :-( so no going further in rules.

what is wrong? also a comment in the original issue about the data model will be appreciated.

Comments

geek-merlin’s picture

fago’s picture

Status: Active » Postponed (maintainer needs more info)

A commerce-options is an entity type, right? Then your could should work just fine. Best, try using the property via the metadata wrappers without rules and see whether it works.

geek-merlin’s picture

Status: Postponed (maintainer needs more info) » Active
StatusFileSize
new1.75 KB

that's what i thought too. wrapper seems to work just fine, rules data not:
(please note that i renamed my property to keep good namespacing rules, see new patch)

test the wrappers in my devel/php:

#a line item with an option
$l=commerce_line_item_load(341);
$w=entity_metadata_wrapper('commerce_line_item', $l);
$s=$w->commerce_option_sets;
$o=$s->get(0);
dsm(get_class($w));
dsm($w->type());
dsm(get_class($s));
dsm($s->count());
dsm(get_class($o));
dsm($o->type());

gives as expected:

EntityDrupalWrapper
commerce_line_item
EntityListWrapper
1
EntityDrupalWrapper
commerce_option

BUT...

this rule:

{ "rules_test_line_item_options" : {
    "LABEL" : "Test line item options",
    "PLUGIN" : "action set",
    "TAGS" : [ "test" ],
    "REQUIRES" : [ "rules", "devel" ],
    "ACTION SET" : [
      { "entity_fetch" : {
          "USING" : { "type" : "commerce_line_item", "id" : "341" },
          "PROVIDE" : { "entity_fetched" : { "entity_fetched" : "Abgerufenen Entit\u00e4t" } }
        }
      },
      { "devel_debug" : { "value" : [ "entity-fetched:commerce-option-sets:0" ] } },
      { "LOOP" : {
          "USING" : { "list" : [ "entity-fetched:commerce-option-sets" ] },
          "ITEM" : { "list_item" : "Aktuelle Listenelement" },
          "DO" : [ { "devel_debug" : { "value" : [ "list-item" ] } } ]
        }
      }
    ]
  }
}

spits out 2* an unwrapped...

... (Object) CommerceOption
option_id (String, 1 characters ) 1
set_id (String, 2 characters ) o1
line_item_id (String, 3 characters ) 341
created (String, 1 characters ) 0
changed (String, 1 characters ) 0
product_id (String, 2 characters ) 10
field_name (String, 16 characters ) field_option_set
field_delta (String, 1 characters ) 0
data (NULL)
field_lp_prepaid (Array, 1 element)
rdf_mapping (Array, 0 elements)

so it seems that rules data loses the wrapper when accessing lists.

fago’s picture

Project: Entity API » Rules
Component: Entity property wrapper » Rules Engine
Status: Active » Postponed (maintainer needs more info)

ok, looks like the problem must be in Rules then. Could you check whether your entity type correctly appears in the rules data info? E.g. call dpm(rules_get_cache()); and check whether

list

appears and is marked as wrap => TRUE in 'data info'.

fago’s picture

ok, looks like the problem must be in Rules then. Could you check whether your entity type correctly appears in the rules data info? E.g. call dpm(rules_get_cache()); and check whether

list

appears and is marked as wrap => TRUE in 'data info'.

geek-merlin’s picture

yep,

$rules_cache[data_info][list][wrap] == TRUE
same for list<commerce_option>

geek-merlin’s picture

Status: Postponed (maintainer needs more info) » Needs work

oops, found something...

geek-merlin’s picture

Status: Needs work » Active

hmm, thought i misdeclared something, but no, list<commerce_option> is just the right thing.
(must think ybout the naming of my property :-)

geek-merlin’s picture

bump, ignore my noise and see #6

mitchell’s picture

Issue tags: +lists and loops

tagging

tr’s picture

Component: Rules Engine » Rules Core
Issue summary: View changes
Status: Active » Postponed (maintainer needs more info)

Is this still a problem in the current 7.x-2.x version of Rules, and can the problem be reproduced without a full commerce setup?

tr’s picture

Status: Postponed (maintainer needs more info) » Closed (cannot reproduce)

No further information provided, and 7.x-1.x-dev is not supported any more for a long time now.

If this can be reproduced in the current version of Rules please open a new issue with details of how to reproduce the problem. And preferably using only core Drupal/core Rules and not a full commerce setup.