Tags/topics: 
1
Answers
Vote up!
0
Vote down!

Crimes against entity_metadata_wrapper?

I'm having a problem getting to some data with the entity wrapper and found myself using:

$e_wrap->commerce_price->value()['original']['amount']

That doesn't feel much better than going through the whole ['und'] array.
How else could I access this?

Andy @ BlueFusion
on October 30, 2014

Comments

1 Answer

Vote up!
0
Vote down!

Hey Andy, I'm actually not sure where the 'original' field value is coming from there, so I don't have a much better option for you. My guess is you're doing exactly what you should be here.

The code looks a little funky (I actually wasn't aware array notation would work like that : ), so if you wanted you could always extract the field value to its own array and access whatever array properties you want from that variable - but that's just a readability difference, not a difference in approach.

Thanks for contributing to other questions!

Ryan Szrama
Answer by: Ryan Szrama
Posted: Oct 31, 2014

Comments

Many thanks Ryan, I guess I'll just live with ugly code :-) And thanks for all your work on DC too - I'm really loving working with it.

- Andy @ BlueFusion on November 3, 2014