Create Virtual Model with Join

Hi All,

I’m working on a project that needs to grab data(read only) from a Magento database.

Magento’s database is in an EAV structure so getting the correct data means joining 3 other tables.

I’m trying to get the billing address based on order id.

I have the raw sql query




SELECT soev.*

FROM sales_order AS so

LEFT JOIN sales_order_int AS soi ON soi.entity_id = so.entity_id AND soi.attribute_id = 122/*122 for billing 123 for shipping*/

LEFT JOIN sales_order_entity_varchar AS soev ON soev.entity_id = soi.value

WHERE so.increment_id = 100000001



I’ve read the tutorial about Relational Active Record.

And in particular "Performing Relational query without getting related models"

I just don’t know how i would work out the code in my model for the virtual attribute.

Any tips/advice is appreciated

Thanks

Oliver