Migrate Data using Feeds - Gaurav Goyal


Published on

Published in: Technology, Business
  • Be the first to comment

  • Be the first to like this

No Downloads
Total views
On SlideShare
From Embeds
Number of Embeds
Embeds 0
No embeds

No notes for slide

Migrate Data using Feeds - Gaurav Goyal

  1. 1. What is Feeds? •Pluggable system for importing content into drupal •Create and update drupal entities •one-off import and periodic aggregation of data
  2. 2. Common Use Cases 1. Data Migration 1. Import Users 2. Import Nodes 3. Import Taxonomy Terms 2. Data syncing
  3. 3. Feeds Glossary 1.Feed :- A feed can appear in different forms depending on the import stage, before fetching, a feed is the external document to be fetched(i.e. CSV file. ). After fetching, it is the raw data dump handed to the parser. After parsing, it is the normalized PHP array that is passed to the processor. 2.Feed item : - individual item(CSV Row), 3.Feed node : - the node created after the import. 4.Mapping : source and target, which tells the importer to map feed item property to node field. A mapping connects a Mapping Source to a Mapping Target. 5.GUID : Stands for global unique identifier. in feeds there is a unique identifier for each feed item i.e. primary key. 6.CSV : a.Comma separated values b.Feeds allow us to import data into this format 7.For more visit https://drupal.org/node/622710
  4. 4. Feeds Architecture Source (Say CSV File) Mapper Feed Fetcher Parser HTTP Feed Items Drupal Entity Processor CSV Nodes File OPML Users Xpath Taxonomy Importer
  5. 5. Migrate Data (For E.g. Nodes) 1.Build a Content Type 2.Create A CSV of required data 3.Build a feed Importer a.Select Fetcher type (File) b.Select Parser (CSV file) - Under CSV parser set delimiter c.Select Processor (Node Processor) d.Under node processor e.Specify the bundle name (this will get associated with the items which will be imported by this importer) f.Specify Author name for the imported nodes g.Under Mapping : - Map the csv fields to the content type field. h.Save the importer 4.Go to www.yoursite.com/import 5.select the created importer, upload the file and click on import 6.Data will get imported.
  6. 6. Feed Hooks Feed hooks can be used to alter mapping target or mapping sources. I think Feed hooks as a point where the code is paused, and they ask “anyone wants to add something here”, and then resume again. Any module who replies to it get triggered and data is get processed. •hook_feeds_after_import Invoked after a feed source is imported •hook_feeds_after_parse Invoked after the feed source has been parsed and before process •hook_feeds_processor_target_alter Alter mapping targets for feed items, this hook can also be used to create custom targets. •hook_feeds_presave Invoked Before a feed item is saved in database.
  7. 7. Feeds Extensions
  8. 8. Feed Temper •Feeds Tamper provides a small plugin architecture for Feeds to modify data before it gets saved. •For e.g. oMake every letter uppercase, lowercase oProvide the default value for a field. oRewrite the output of a field. o…. •Once Feeds Tamper is enabled, the list of available Feeds importers (admin/structure/feeds) displays a "Tamper" configuration link for each feed. •You can create your own plugin
  9. 9. 1.Feeds Tamper PHP a.https://drupal.org/project/feeds_tamper_php b.Provides a tamper plugin for executing php code 1.Feeds Tamper String2Id a.https://drupal.org/project/feeds_tamper_string2id b.Adds support for freeform Entityreference linking when using Feeds. 1.Feeds User Picture a.https://drupal.org/project/feeds_user_picture b.Provides Target for importing User Pictures while importing users.
  10. 10. Case Study of one of our drupal implementation