5

I'm wondering if this plugin already exists and I'm just not finding it on Github or via Google. Essentially looking for a CraftCMS version of the ExpressionEngine plugin called "Data Grab" - http://brandnewbox.co.uk/products/details/datagrab

This plugin basically lets you define a feed and run automated imports to create entries. Hoping someone has done this in Craft or has some pointers to a preexisting plugin!

Thanks!

3

The Import plugin by Bob Olde Hampsink can import CSVs. JSON support is on the roadmap, but in the meantime, it’s easy enough to convert JSON to a CSV with a little bit of Javascript.

Just paste this into your browser’s JS console on any webpage:

var data = [
    { title: "Entry Title", body: "Body content" },
    { title: "Entry Title 2", body: "More body content" },
    // etc.
];

function csvVal(val) {
    // Borrowed from http://phpjs.org/functions/addslashes/
    return '"' + ((val + '').replace(/[\\"']/g, '\\$&').replace(/\u0000/g, '\\0')) + '"';
}

var csv = '';

data.forEach(function(row) {
    csv += csvVal(row.title) + ',' + csvVal(row.body) + "\n";
});

console.log(csv);

Save the resulting CSV as somefile.csv and then you can upload it to the Import plugin.

| improve this answer | |
  • Thanks Brandon! I need this import to happen regularly (based on a cronjob or something along those lines) and was hoping to avoid programming all of the JSON to field mapping, etc. I ended up writing a small plugin that converts the JSON feed to RSS and then using the craft.feeds functionality to output them on the site. – pstinnett Oct 9 '14 at 17:47
5

Check out the FeedMe plugin. It's pretty similar to DataGrab and Importer.

From the README:

Feed Me

Feed Me is a Craft plugin to make it easy to import entries and entry data from XML, RSS, ATOM or JSON feeds. Feeds can be setup as a task in Craft's Control Panel, or called on-demand for use in your twig templates.

A common use-case for this plugin is to consume external feeds (news, events), but can also be used as a once-off task for importing content when migrating from other sites.

Features

  • Import data from XML, RSS, ATOM or JSON feeds.
  • Feeds are saved to allow easy re-processing on-demand, or to be used in a Cron job.
  • Map feed data to your entry fields. See Supported Fieldtypes.
  • Duplication handling - control what happens when feeds are processed again.
  • Uses Craft's Task service to process feeds in the background.
  • Database backups before each feed processing.
  • Troubleshoot feed processing issues with logs.
  • Grab feed data directly from your twig templates.
  • Craft 2.5 compatible.

Disclosure: I authored this free plugin. Let me know if I can be of assistance!

| improve this answer | |
  • I expanded your post to include more details about your plugin (which looks great, by the way!) – Simon East Dec 22 '16 at 23:25

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.