improved term field restoration batch script

This commit is contained in:
Bachir Soussi Chiadmi 2016-12-12 11:33:34 +01:00
parent c4ab89f177
commit dee5085c89

View File

@ -254,38 +254,19 @@ function _materio_admin_batch_fixterm_ref($node_type, $target_field, $src_tid, $
array(
$nid,
$src_tid, $target_field,
$node_type,
)
);
}
// $nodes = taxonomy_select_nodes($src_tid);
// $k = 0;
// foreach ($nodes as $nid) {
// $batch['operations'][] = array(
// '_materio_admin_batch_fixterm_ref_op',
// array(
// $nid,
// $src_tid, $target_field,
// $node_type,
// )
// );
// $k++;
// if ($k > 0) {
// break;
// }
// }
batch_set($batch);
}
function _materio_admin_batch_fixterm_ref_op($nid, $src_tid, $target_field){
function _materio_admin_batch_fixterm_ref_op($nid, $src_tid, $target_field, $node_type){
$context['results']['field_migrated']++;
$node = node_load($nid);
// if($node->type == $node_type){
if($node->type == $node_type){
$items = field_get_items('node', $node, $target_field);
foreach ($items as $key => $item) {
$flat_items[] = $item['tid'];
@ -294,19 +275,8 @@ function _materio_admin_batch_fixterm_ref_op($nid, $src_tid, $target_field){
// $items[] = array('tid'=>$src_tid);
$node->{$target_field}[LANGUAGE_NONE][] = array('tid'=>$src_tid);
}
// $items = array(LANGUAGE_NONE => array());
// foreach ($terms as $tid => $name) {
// $items[LANGUAGE_NONE][] = array(
// 'showroom_tid' => $tid,
// 'location' => $default_tid == $tid ? $src_value : '',
// );
// }
//
node_save($node);
// }
}
//Simply show the import row count.
$context['message'] = t('Migrating node !c : %title (%nid)', array(