Skip to content

Instantly share code, notes, and snippets.

@rafaqz
Last active December 18, 2015 17:39
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save rafaqz/5820419 to your computer and use it in GitHub Desktop.
Save rafaqz/5820419 to your computer and use it in GitHub Desktop.
Drupal Feeds Patch to add location and group handling
diff --git a/plugins/FeedsProcessor.inc b/plugins/FeedsProcessor.inc
index c2b0af5..7bcd238 100755
--- a/plugins/FeedsProcessor.inc
+++ b/plugins/FeedsProcessor.inc
@@ -178,6 +178,25 @@ abstract class FeedsProcessor extends FeedsPlugin {
$state = $source->state(FEEDS_PROCESS);
while ($item = $parser_result->shiftItem()) {
+ //hack to get location target id from feed source
+ if ($source->config["FeedsCSVParser"]) {
+ $feeds_plugin = 'FeedsCSVParser';
+ } elseif ($source->config["FeedsExcelParser"]) {
+ $feeds_plugin = 'FeedsExcelParser';
+ }
+ if ($feeds_plugin) {
+ if ($source->config[$feeds_plugin]["location"]) {
+ $location_target_id = $source->config[$feeds_plugin]["location"];
+ }
+ if ($source->config[$feeds_plugin]["groups"]) {
+ $group_id = $source->config[$feeds_plugin]["groups"];
+ }
+ }
+ //get current user
+ global $user;
+
+ //end hack
+
// Check if this item already exists.
$entity_id = $this->existingEntityId($source, $parser_result);
@@ -221,6 +240,19 @@ abstract class FeedsProcessor extends FeedsPlugin {
// Set property and field values.
$this->map($source, $parser_result, $entity);
+ //hack to set location target id and group ids
+ if ($feeds_plugin) {
+
+ $entity->field_reference_location = array(und => array(0 => array('target_id' => $location_target_id)));
+ $entity->uid = $user->uid;
+ //$i = 0;
+ //$entity->og_group_ref = array(und => array());
+ //foreach ($group_id as $id => $gid) {
+ //$entity->og_group_ref['und'][$i] = array('target_id' => $gid);
+ //$i++;
+ //}
+ }
+ //end hack
$this->entityValidate($entity);
// Allow modules to alter the entity before saving.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment