Magento – Product export download is not working in magento 2.1.15

exportmagento2product

I am using AWS server. I tried to export the product from the back-end. But while downloading it showing Failed- Server Unreachable in chrome browser. Is that related to owner permission issue? Because in inside the var folder that exported CSV is present but while downloading it's not working. If I hit direct URL with that CSV file means it's working fine. Please tell me any idea to fix this issue…

Best Answer

please override Download.php file from the vendor.

1. Magento\ImportExport\Controller\Adminhtml\Export\File\Download.php

add changes to in.

 public function execute()
    {
        if (empty($fileName = $this->getRequest()->getParam('filename'))) {
            throw new LocalizedException(__('Please provide export file
name'));
        }
        try {
            $path = 'export/' . $fileName;
            $directory =
$this->filesystem->getDirectoryRead(DirectoryList::VAR_DIR);
            if ($directory->isFile($path)) {
                return $this->fileFactory->create(
                    *$fileName,*
                    $directory->readFile($path),
                    DirectoryList::VAR_DIR,
                    'application/octet-stream'
                );
            }
        } catch (LocalizedException | \Exception $exception) {
            throw new LocalizedException(__('There are no export file with
such name %1', $fileName));
        }
    }

Hopefully, it works for you.

Related Topic