public static function NodeImportController::getFailedRowsInRc in Simple Node Importer 8
Function to fetch failed nodes from node_resolution table.
Parameters
int $nid: Failed nodes from import node nid.
string $refKey: Reference key for the failed records.
2 calls to NodeImportController::getFailedRowsInRc()
- NodeImportController::resolutionCenterOperations in src/
Controller/ NodeImportController.php - Provides different operations for failed rows.
- simple_node_importer_form_alter in ./
simple_node_importer.module - Implements hook_form_alter().
File
- src/
Controller/ NodeImportController.php, line 492
Class
- NodeImportController
- Default controller for the simple_node_importer module.
Namespace
Drupal\simple_node_importer\ControllerCode
public static function getFailedRowsInRc($nid = NULL, $refKey = NULL) {
$data = [];
// Query to fetch failed data.
$connection = Database::getConnection();
$connection
->query("SET SQL_MODE=''");
$query_record = $connection
->select('node_resolution', 'nr');
$query_record
->fields('nr', [
'data',
'reference',
'sni_nid',
]);
if (!empty($nid)) {
$query_record
->condition('nr.sni_nid', $nid);
}
if (!empty($refKey)) {
$query_record
->condition('nr.reference', $refKey);
}
$result = $query_record
->execute()
->fetchAll();
foreach ($result as $k => $value) {
// code...
$data[$k] = unserialize($value->data);
$reference[$k] = $value->reference;
$sni_nid[$k] = $value->sni_nid;
unset($data[$k]['sni_id']);
}
foreach ($data as $rowKey => $rows) {
if (!empty($rows['nid']) || !empty($rows['type'])) {
unset($rows['nid']);
// unset($rows['type']);.
}
foreach ($rows as $key => $record) {
$records[$rowKey][$key] = $record;
$records[$rowKey]['reference'] = $reference[$rowKey];
$records[$rowKey]['sni_nid'] = $sni_nid[$rowKey];
}
}
if (!empty($records)) {
return $records;
}
else {
return FALSE;
}
}