0

We recently upgraded our website to Magento 2.4, but we have run into an issue with trying to import products using the import tool. When we upload a csv that has errors in it, we want to download the error report to see what those issues are. However, when we try to click on the download button the following error appears in the exception log.

[2020-10-01 14:44:43] main.CRITICAL: Path "/var/www/production/var/importexport//0ioMiFS6xCv06A0XOyQQSxGMKhKTAMcr.csv" cannot be used with directory "/var/www/production/pub/media/" {"exception":"[object] (Magento\\Framework\\Exception\\ValidatorException(code: 0): Path \"/var/www/production/var/importexport//0ioMiFS6xCv06A0XOyQQSxGMKhKTAMcr.csv\" cannot be used with directory \"/var/www/production/pub/media/\" at /var/www/production/vendor/magento/framework/Filesystem/Directory/PathValidator.php:63)"} []
1
  • Hey, I don't know what can cause the issue, but you might find the report at /pub/media/ a folder called importexport or just export, something like that, might be there in the meantime you can't solve this issue
    – Rui Silva
    Commented Oct 1, 2020 at 17:05

1 Answer 1

0

I found that the error reports were not being generated while investigating the download process. I resolved the by copying the working code from the repository and updating the file "vendor\magento\module-import-export\Model\Report\Csv.php"

Inside the csv.php file is the method createReport. I replaced the contents of this method with the following code obtained from the current magento repository

$outputCsv = $this->outputCsvFactory->create();

$sourceCsv = $this->createSourceCsvModel($originalFileName);
$columnsName = $sourceCsv->getColNames();
$columnsName[] = self::REPORT_ERROR_COLUMN_NAME;
$outputCsv->setHeaderCols($columnsName);

foreach ($sourceCsv as $rowNum => $rowData) {
    $errorMessages = $this->retrieveErrorMessagesByRowNumber($rowNum, $errorAggregator);
    if (!$writeOnlyErrorItems || ($writeOnlyErrorItems && $errorMessages)) {
        $rowData[self::REPORT_ERROR_COLUMN_NAME] = $errorMessages;
        $outputCsv->writeRow($rowData);
    }
}

$directory = $this->filesystem->getDirectoryWrite(DirectoryList::VAR_DIR);
$outputFileName = $this->generateOutputFileName($originalFileName);
$directory->writeFile(Import::IMPORT_HISTORY_DIR . $outputFileName, $outputCsv->getContents());

return $outputFileName;

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.