When retrieving a record in a service and returning a model the static methods: populateModel and populateModels on BaseModel are useful.
When eager loading a related model in the record query, for example:
$variantRecord = Market_VariantRecord::model()->with('product')->findById($id);
This will load the related Record's product into the
$variantRecord accessible with
when casting this variant record into a Model, using
VariantModel::populateModel, will the product also being retrieved be cast into the
model->product (AttributeType::Mixed) of the variant?
Or should we manually be manually assigning the ->product attribute as casting it to a model with populate model like this?
$variant = Market_VariantRecord::model()->with('product')->findById($id); $variantModel = Market_VariantModel::populateModel($variant); $variantModel->product = Market_ProductModel::populateModel($variant->product); return $variantModel;
This seems clunky and am looking for suggestions on improving the population of models from records with eager loading of relations.
This is one area