Hello,

I wrote drush commands to import Salesforce content, so this can be done on command line and via scripts.

Features :

  • Shows available fieldmaps ;
  • Shows row information about fieldmaps (number of existing linked nodes, number of available rows on Salesforce for an import) ;
  • Option to only import new rows, or only import existing rows ;
  • Can define an import start and count to only import subsets of the rows ;
  • Can compare Salesforce LastModifiedDate and Drupal changed date to only import rows with a more recent modified date.

Drush .inc file is attached. Let me know if you think this is useful and could be added to salesforce ; otherwise I could package it as it's own module.

Comments

Alice Heaton’s picture

StatusFileSize
new8.58 KB

Updated version :

- Fixed typos ;
- Better error management ;
- More information when showing a fieldmap.

kostajh’s picture

Hello, I tested this out. sf-fieldmap and sf-fieldmaps commands were useful. I'd suggest renaming one of them for clarity though.

The code for sf-import assumes that we are importing nodes. The code should check to see what object type is defined in the fieldmap and use that.

Nice work!

kostajh’s picture

Status: Needs review » Needs work
Alice Heaton’s picture

Status: Needs work » Needs review
StatusFileSize
new8.57 KB

Hi, thanks for your feedback !

sf-fieldmap and sf-fieldmaps commands were useful. I'd suggest renaming one of them for clarity though.

I've removed the second. sf-fieldmap now displays the list of available fieldmaps if not given an argument, and the information about a specific fieldmap if that fieldmap key is given as argument. Let me know what you think about this change.

The code for sf-import assumes that we are importing nodes. The code should check to see what object type is defined in the fieldmap and use that.

  • I've removed references to nodes in instructions/output.
  • There was one place where I had harcoded 'node' when calling the salesforce module API - I've now fixed that and pass the type obtained from the fieldmap instead
  • The '--check-date' option still only works for nodes. Using this requires knowledge of the object we're syncing to - so it can only be done for known types

Let me know if this now works well for non-node types.

kostajh’s picture

I'll try to take a look at this next week, thank you for your work on this!

Has anyone else had a chance to review?

kostajh’s picture

Status: Needs review » Needs work

I reviewed this code and it looks good although I haven't had a chance to test it. Thank you for working on this to handle users and other entities in addition to nodes.

For readability and clarity I would still suggest changing references from $nid to $oid, i.e. in this section

$nid = FALSE;
    try {  
      $nid = $function($record->Id, $map->name, $existing[$record->Id]);
    } catch (Exception $e) {
      drush_log("Error importing record $record->Id : " . $e->getMessage(), 'error');
    }

change that to something like:

$oid = FALSE;
    try {  
      $oid = $function($record->Id, $map->name, $existing[$record->Id]);
    } catch (Exception $e) {
      drush_log("Error importing record $record->Id : " . $e->getMessage(), 'error');
    }

And make corresponding changes throughout the code.

Finally, if you can format this as a patch, that would be helpful too, see the instructions here: https://drupal.org/node/141315/git-instructions/6.x-2.x

Has anyone had a chance to test this?

kostajh’s picture

Status: Needs work » Fixed

I made the changes from comment #6 and dropped the "linked" option since linking happens in sf_node_import and sf_user_import. Thank you for your work on this, it's a great feature to have!

Committed to 6.x-2.x-dev: http://drupalcode.org/project/salesforce.git/commit/f6b3cd5

kostajh’s picture

Component: sf_node » sf_import

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.