You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Currently, when importing products with failing validation, it will fail silently, which is confusing. This can be caught using something like this (I guess?)
$importer->processImport($products);
if (!$importer->getValidationResult()) {
print_r($products));
echo$importer->getLogTrace();
}
But that gives a trace for all products. Would it make more sense to throw the validation errors as an exception, preferably with the invalid rows?
The text was updated successfully, but these errors were encountered:
The PR contains our long outstanding fix (we are using this logic for 4 projects now);
This allows for something in the lines of:
$success = $importerModel->processImport($data);
// Output the importer trace
$importerLog = preg_split('/\n|\r/', $importerModel->getLogTrace(), null, PREG_SPLIT_NO_EMPTY);
foreach($importerLog as $log) {
$this->logger->addInfo(preg_replace('/(\d:)/', '--', $log));
}
// If the processImport failed we want to throw an exception
if ($success === false) {
throw new \Exception('Validation failed');
}
Currently, when importing products with failing validation, it will fail silently, which is confusing. This can be caught using something like this (I guess?)
But that gives a trace for all products. Would it make more sense to throw the validation errors as an exception, preferably with the invalid rows?
The text was updated successfully, but these errors were encountered: