3

I'm setting up a Feeds Importer to pull in content form a previous CMS. To keep things manageable I'm setting up MySQL exports saved to CSV files per Content Type. In a content type of News we're using the Body for full content display and the Body Teaser for the views listing.

In the source CSV file I have two separate columns: one for Body Content and another destined for Body Summary.

enter image description here

But in the Mapping for Node Processor Feed Importer, I don't have an option to place the teaser column in Body Summary.

enter image description here

Follow up:

I did the dummy field option. Once I had that, three lines of SQL saved the day.

UPDATE field_data_body f, field_data_field_news_teaser_summary_holdin ff 
SET f.`body_summary` = ff.`field_news_teaser_summary_holdin_value`
WHERE  ff.`entity_id`= f.`entity_id` AND f.`revision_id`= ff.`revision_id`
7

Couple of ways of doing this using a dummy field. Create a dummy text field on the content type you are importing to. Then you could:

a. Use rules to move the dummy field into the body summary.

or

b. (preferred) Use the feeds presave hook in your own module to set the summary AND set the dummy field blank.

/**
 * Invoked before a feed item is saved.
 *
 * @param $source
 *  FeedsSource object that describes the source that is being imported.
 * @param $entity
 *   The entity object.
 * @param $item
 *   The parser result for this entity.
 */
function [YOUR_MODULE_NAME]_feeds_presave(FeedsSource $source, $entity, $item) {
  if ($entity->feeds_item->entity_type == 'node' && isset($entity->field_temp_summary['und'][0]['value'])) {
    $entity->body['und'][0]['summary'] = $entity->field_temp_summary['und'][0]['value'];
    unset($entity->field_temp_summary);
  }
}
  • 1
    Thank you. I left a 'follow up' section above with my results. – Rick Feb 12 '13 at 20:30
  • 1
    Updated the example to include some working code for @7wonders suggestion. Assumes you're inserting the summary data into "field_temp_summary" on a node entity. – areynolds Jun 25 '13 at 22:12
1

This is already added to feeds dev you can use the dev feeds module or get the patch from issue [962912]

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.