0

For a migrate_d2d project, D7 -> D7, I wish to exclude the importing of nodes whose date field is less than the current date. My only class overrides are for mapping custom fields. The migrate function is working as I expect. However, we don't need to import nodes whose dates have passed today's date.

The custom node field is not part of the core field data set, so the following:

public function prepareRow($row)
{
    $postDate = $node->field_job_start[und][0][value2];
    if ($postDate < time()) {
        return FALSE;
}

Will not work, as 'field_job_start' isn't accessible until prepare() by which time, apparently, a return FALSE doesn't cancel the row import.

What is the best way to exclude these rows?

1

You have to do this in prepareRow. Whatever value is mapped to field_job_start, check its value there and return FALSE.

| improve this answer | |
  • Thanks, but please re-read what I wrote. – Screenack Nov 12 '15 at 17:27
  • 1
    Whatever value is eventually inserted into field_job_start, you'll need to get that value in prepareRow and check its value there. It won't work after prepareRow. – heddn Feb 17 '16 at 13:59

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.