prepare() function doesn't work well in migrate module This is my code to move a few records from a table to a Drupal content type (called CT1)

&lt;?php 
class CT1Migration extends Migration {
    public function __construct() {
        parent::__construct(MigrateGroup::getInstance());
        $this-&gt;description = 'Imports CT1';
        $fields = array(
                'id',
                'subject',
                'content',
        );

        $query = db_select('tbl', 'qf')
        -&gt;fields('qf', $fields);

        $this-&gt;source = new MigrateSourceSQL($query);

        $this-&gt;destination = new MigrateDestinationNode('porseman');

        $pkmap = array('id' =&gt; array('type'  =&gt; 'int',
                'unsigned'  =&gt; TRUE,
                'not null'  =&gt; TRUE,
                'alias'     =&gt; 'qf'));

        $this-&gt;map = new MigrateSQLMap($this-&gt;machineName, $pkmap, MigrateDestinationNode::getKeySchema());
        $this-&gt;addFieldMapping('title','subject');
        $this-&gt;addFieldMapping('field_CT_body', 'content')-&gt;arguments(array('format' =&gt; 'full_html'));
    }

    public function prepare($row) {
        $row-&gt;title = "This is title 1";
        $row-&gt;field_CT_body = t("This is body"); 
    }
}
?&gt;


CT1 has two fields, title and body. I need to perform some settings before the migration so I use prepare() function. From function prepare($row) function I expect the values of title and field_CT_body of all of the imported records to be This is title 1 and This is body while after the migration the title correctly gets this string (This is title 1) as its value but field_CT_body has no value at all.

if I remove the prepare function it migrates the records successfully.
Unfortunately you can't set the value directly like that, you need to reference the language and delta in the classic, hated method:

public function prepare($entity, stdClass $row) {
  $row-&gt;title = "This is title 1";
  $row-&gt;field_CT_body[LANGUAGE_NONE][0]['value'] = t("This is body");
}


Note: This function takes 2 params, the entity object being built and the source row. So, since we're altering the entity object, we gotta manipulate it as such.  (I'm not sure, but you might be able to wrap that object in a metadata wrapper in order to use the cleaner API)

Also, please note that the "value" key will depend on the field type in use.

Note: untested code but it should be fine! :)