Closed ntejapermana closed 9 years ago
The embedded object must be an instance of Cm_Mongo_Model_Abstract: https://github.com/colinmollenhour/magento-mongo/blob/d77b9d46b49abdec772b9d96b815bb3e7fbedb6f/code/Model/Resource/Abstract.php#L523
Thank you for the response Colin. I have made the embedded object extends Cm_Mongo_Model_Abstract, the problem is this line of code always return NULL :
$model = $object->getDataUsingMethod($field);
Ahh, the intent is that the method exists and returns an object of the right type. So if your field name is foo_bar
then your parent object model should have a method getFooBar
which usually would just look like this:
public function getFooBar()
{
return $this->_getEmbeddedObject('foo_bar');
}
You would typically also have a setFooBar
that uses the _setEmbeddedObject
method.
Edit: referenced wrong method names..
Edited previous comment which referenced the wrong method names...
Thank you for explanation Colin. It works like a charm.
Hi Colin,
I'm using your magento-mongo extension in my project and it's awesome. But I have problem if my document has embedded document in it. It always throws 'Invalid embedded object instance for xxx'. Could you help me with this problem, please.
Thank you