0

I have been racking my brains on how I can import a massive database I have collected into my Drupal website.

I have collected the below data for over 3000 players so manually uploading is not an option.

Can anyone help?

Player Content Type

Player, Position(Term Reference)

Season Content Type

Season, Appearance, Substitute, Appearances, Tries, Yellow Cards, Red Cards, Club (Term Reference)

Each Player would have multiple seasons worth of data assigning to them, relating to previous seasons.

I cannot see a way in Feeds to implement this, I have tried with Entity Reference, but cannot see how I can add multiple Seasons to the same player through Feeds.

Here is some sample data.

Player - John Smith, Position - Flanker

Season - 2013/2014, Apps - 22, Subs - 10, Tries - 2, YC - 3, RC - 0, Club - York RFC

Season - 2012/2013, Apps - 12, Subs - 1, Tries - 0, YC - 0, RC - 0, Club - Leeds RFC

I have some experience with Feeds, but not when using Entity References and the community does'nt really have anything that fits my bill.

If there is a better way to structure the data then I am open to suggestions as this is just the way I logically can work it out. I just ideally do not want to have multiple fields assigned to each player in one content type like 2013_apps, 2013_tries, 2012_apps, 2012_tries etc which would be the easy route...

Thanks

Craig

1

To my knowledge the solution you are looking for is not available directly through published modules.

You can find the beginning of the answering you are looking for at

http://clikfocus.com/blog/drupal-developer-tip-multiple-entity-references-using-feeds-importer

  1. Create a custom target callback for your field importer. The targets array is keyed by the name of the target so it is necessary to differentiate your custom handler from the standard field handler for that entity reference field.

    function my_module_feeds_processor_targets_alter() {

      foreach (field_info_instances($entity_type, $bundle_name) as $name => $instance) {
        $info = field_info_field($name);
    
        if ($info['type'] == 'entityreference') {
          $targets[$name .':custom_handler'] = array (link is external)(
            'name'        => check_plain($instance['label'] .t(' (Import multiple values into multi-instance field')),
            'callback'    => 'my_module_set_target_entity_reference',
            'description' => t(''),
          );
        }
      }
    }
    

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.