drupal 7

Drupal Migrate V2 and Addressfield

While trying to migrate data from a legacy CakePHP system to Drupal 7 recently I had a problem getting an Addressfield field to play nicely.
What I had origianly was this (which did not work).

  $this->addFieldMapping('field_customer_address:thoroughfare', 'address'); 
$this->addFieldMapping('field_customer_address:locality', 'suburb');
$this->addFieldMapping('field_customer_address:administrative_area', 'state');
$this->addFieldMapping('field_customer_address:postal_code', 'postcode');

Looking all over the web I found many examples saying to use the arguments function. eg.
  $address_arguments= array( 
'thoroughfare' => array('source_field' => 'address'),
'locality' => array('source_field' => 'suburb'),
'administrative_area' => array('source_field'=>'state'),
'postal_code' => array('source_field' => 'postcode'),
);
$this->addFieldMapping('field_customer_address')
->arguments($address_arguments);

But when trying this I got a message from the module saying that this was not correct. I think the above code was/is for version 1 of the migrate module.
It turns out that all I needed to do was to set a default country. ie.
  $this->addFieldMapping('field_customer_address')->defaultValue('AU'); 
$this->addFieldMapping('field_customer_address:thoroughfare', 'address');
$this->addFieldMapping('field_customer_address:locality', 'suburb');
$this->addFieldMapping('field_customer_address:administrative_area', 'state');
$this->addFieldMapping('field_customer_address:postal_code', 'postcode');

Useful Drupal Links

I often seem to forget all the good places on the web to find info and things about drupal, So I thought I would start a list, mainly for my own reference.

  • Drupal API Reference Drupal API reference. Every Drupal dev. should be taking advantage of this site.
  • TopDrops Listing of most popular Drupal powered websites.
  • Drupal Jobs A group on Drupal Groups dedicated to job advertisements in the Drupal space.
  • Drupal paid services Another page dedicated to job advertisements.
  • Drupal Project applications A list of Drupal projects that are waiting review and approval to become full Drupal projects.
  • pareview.sh A site to review your Drupal module code. This should be used on all of your Drupal projects.
  • simpletest.me Easily test a drupal theme or module.
  • Drupal 7 Template (Theme Hook) Suggestions
  • Drupal X-Ray Tool to view the modules a Drupal website uses.
  • Create forms in a safe way to avoid cross-site request forgeries (CSRF)
Modules to remember
  • Fields
    • Conditional fields
  • Taxonomy
    • Hierarchical Select
  • Input formats
    • Pathologic
  • Image carousels / sliders
    • Slick Carousel
    • Owl Carousel
  • Development
    • Object Log
    • Security Review
  • Views
    • Foo table - responsive tables
  • Paths
    • Query parameters to url
  • Performance
    • CSS Embedded Images
    • Views Litepager
    • Views content cache
  • Emails
    • Mail logger
    • Reroute email
Useful modules when inheriting a Drupal...