diff --git a/modules/farm/farm_import/farm_import.feeds_importer_default.inc b/modules/farm/farm_import/farm_import.feeds_importer_default.inc index 823d6563..4b070b31 100644 --- a/modules/farm/farm_import/farm_import.feeds_importer_default.inc +++ b/modules/farm/farm_import/farm_import.feeds_importer_default.inc @@ -214,6 +214,9 @@ function farm_import_add_importer_fields($type, $bundle, $importer) { // Add fields, if they exist on the bundle. foreach ($mappings as $field => $mapping) { + if (!empty($mapping['real_field'])) { + $field = $mapping['real_field']; + } if (!empty(field_info_instance($type, $field, $bundle))) { $importer->config['processor']['config']['mappings'][] = $mapping; } @@ -271,6 +274,13 @@ function farm_import_asset_field_mappings() { 'unique' => FALSE, 'language' => 'und', ), + 'field_farm_parent_name' => array( + 'source' => 'Parent names', + 'target' => 'field_farm_parent:label', + 'unique' => FALSE, + 'language' => 'und', + 'real_field' => 'field_farm_parent', + ), ); } @@ -289,6 +299,13 @@ function farm_import_log_field_mappings() { 'unique' => FALSE, 'language' => 'und', ), + 'field_farm_asset_name' => array( + 'source' => 'Asset names', + 'target' => 'field_farm_asset:label', + 'unique' => FALSE, + 'language' => 'und', + 'real_field' => 'field_farm_asset', + ), 'field_farm_area' => array( 'source' => 'Areas', 'target' => 'field_farm_area', diff --git a/modules/farm/farm_import/farm_import.feeds_tamper_default.inc b/modules/farm/farm_import/farm_import.feeds_tamper_default.inc index b341e63e..e4f95985 100644 --- a/modules/farm/farm_import/farm_import.feeds_tamper_default.inc +++ b/modules/farm/farm_import/farm_import.feeds_tamper_default.inc @@ -24,10 +24,13 @@ function farm_import_feeds_tamper_default() { $feeds_tamper = farm_import_feeds_tamper_plugin('farm_asset', $bundle, 'Archived', 'boolean_default_false'); $export[$feeds_tamper->id] = $feeds_tamper; - // If a "Parent IDs" field exists, explode it into an array of IDs. + // If a parent asset field exists, explode "Parent IDs" and "Parent names" + // into arrays of IDs and names. if (!empty(field_info_instance('farm_asset', 'field_farm_parent', $bundle))) { $feeds_tamper = farm_import_feeds_tamper_plugin('farm_asset', $bundle, 'Parent IDs', 'explode'); $export[$feeds_tamper->id] = $feeds_tamper; + $feeds_tamper = farm_import_feeds_tamper_plugin('farm_asset', $bundle, 'Parent names', 'explode'); + $export[$feeds_tamper->id] = $feeds_tamper; } } @@ -50,10 +53,13 @@ function farm_import_feeds_tamper_default() { $feeds_tamper = farm_import_feeds_tamper_plugin('log', $bundle, 'Done', 'boolean_default_true'); $export[$feeds_tamper->id] = $feeds_tamper; - // If an "Asset IDs" field exists, explode it into an array of IDs. + // If an asset reference field exists, explode the "Asset IDs" and "Asset + // names" targets into arrays of IDs and names. if (!empty(field_info_instance('log', 'field_farm_asset', $bundle))) { $feeds_tamper = farm_import_feeds_tamper_plugin('log', $bundle, 'Asset IDs', 'explode'); $export[$feeds_tamper->id] = $feeds_tamper; + $feeds_tamper = farm_import_feeds_tamper_plugin('log', $bundle, 'Asset names', 'explode'); + $export[$feeds_tamper->id] = $feeds_tamper; } // If an "Areas" field exists, explode it into an array of area names. diff --git a/modules/farm/farm_livestock/farm_livestock.module b/modules/farm/farm_livestock/farm_livestock.module index 87b26bdb..542ce6b3 100644 --- a/modules/farm/farm_livestock/farm_livestock.module +++ b/modules/farm/farm_livestock/farm_livestock.module @@ -200,7 +200,7 @@ function farm_livestock_feeds_importer_default_alter($importers) { $name = 'log_farm_birth'; if (!empty($importers[$name])) { - // Add Mother ID mapping. + // Add Mother ID and name mappings. $mappings = array( array( 'source' => 'Mother ID', @@ -208,6 +208,12 @@ function farm_livestock_feeds_importer_default_alter($importers) { 'unique' => FALSE, 'language' => 'und', ), + array( + 'source' => 'Mother name', + 'target' => 'field_farm_mother:label', + 'unique' => FALSE, + 'language' => 'und', + ), ); $importer_mappings =& $importers[$name]->config['processor']['config']['mappings']; $importer_mappings = array_merge($importer_mappings, $mappings); @@ -218,6 +224,13 @@ function farm_livestock_feeds_importer_default_alter($importers) { $mapping['source'] = 'Children IDs'; } } + + // Change "Asset names" to "Children names". + foreach ($importer_mappings as &$mapping) { + if ($mapping['source'] == 'Asset names') { + $mapping['source'] = 'Children names'; + } + } } } @@ -258,6 +271,12 @@ function farm_livestock_feeds_tamper_default_alter(&$feeds_tampers) { // Explode nicknames to allow multiple values. $feeds_tamper = farm_import_feeds_tamper_plugin('farm_asset', 'animal', 'Nicknames', 'explode'); $feeds_tampers[$feeds_tamper->id] = $feeds_tamper; + + // Explode birth children IDs and names to allow multiple values. + $feeds_tamper = farm_import_feeds_tamper_plugin('log', 'farm_birth', 'Children IDs', 'explode'); + $feeds_tampers[$feeds_tamper->id] = $feeds_tamper; + $feeds_tamper = farm_import_feeds_tamper_plugin('log', 'farm_birth', 'Children names', 'explode'); + $feeds_tampers[$feeds_tamper->id] = $feeds_tamper; } /**