Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ImportExport - Sample Files in own Modules #6553

Closed
EliasKotlyar opened this issue Sep 9, 2016 · 5 comments
Closed

ImportExport - Sample Files in own Modules #6553

EliasKotlyar opened this issue Sep 9, 2016 · 5 comments
Assignees
Labels
bug report Component: ImportExport Issue: Clear Description Gate 2 Passed. Manual verification of the issue description passed Issue: Confirmed Gate 3 Passed. Manual verification of the issue completed. Issue is confirmed Issue: Format is valid Gate 1 Passed. Automatic verification of issue format passed Issue: Ready for Work Gate 4. Acknowledged. Issue is added to backlog and ready for development

Comments

@EliasKotlyar
Copy link
Contributor

Preconditions

Happens in all Magento2 Versions.

Steps to reproduce

Try to provide your own Sample file in
/Files/Sample/<yourentity.csv>

Expected result

You can add your own sample-file to your module and it will be taken from the ImportExport Wizard in the Backend

Actual result

The sample file needs to be placed in the Module "ImportExport".

Why it happens?

This happens because of this code:
vendor/magento/module-import-export/Controller/Adminhtml/Import/Download.php

` /**
* Download sample file action
*
* @return \Magento\Framework\Controller\Result\Raw
*/
public function execute()
{
$fileName = $this->getRequest()->getParam('filename') . '.csv';
$moduleDir = $this->componentRegistrar->getPath(ComponentRegistrar::MODULE, self::SAMPLE_FILES_MODULE);
$fileAbsolutePath = $moduleDir . '/Files/Sample/' . $fileName;
$directoryRead = $this->readFactory->create($moduleDir);
$filePath = $directoryRead->getRelativePath($fileAbsolutePath);

    if (!$directoryRead->isFile($filePath)) {
        /** @var \Magento\Backend\Model\View\Result\Redirect $resultRedirect */
        $this->messageManager->addError(__('There is no sample file for this entity.'));
        $resultRedirect = $this->resultRedirectFactory->create();
        $resultRedirect->setPath('*/import');
        return $resultRedirect;
    }

    $fileSize = isset($directoryRead->stat($filePath)['size'])
        ? $directoryRead->stat($filePath)['size'] : null;

    $this->fileFactory->create(
        $fileName,
        null,
        DirectoryList::VAR_DIR,
        'application/octet-stream',
        $fileSize
    );

    /** @var \Magento\Framework\Controller\Result\Raw $resultRaw */
    $resultRaw = $this->resultRawFactory->create();
    $resultRaw->setContents($directoryRead->readFile($filePath));
    return $resultRaw;
}`

This Code is taking sample Files only from the ImportExport-Module. There is no way to provide your own sample File.

Greetings
Elias

@BaDos
Copy link
Contributor

BaDos commented Sep 15, 2016

Hi @EliasKotlyar

Thank you for reporting.
We've created internal ticket MAGETWO-58483 to resolve this issue.

@BaDos BaDos added the Issue: Ready for Work Gate 4. Acknowledged. Issue is added to backlog and ready for development label Sep 15, 2016
@BaDos BaDos removed their assignment Sep 15, 2016
@MathieuJJ
Copy link

Hi BaDos,
Any news from this issue? I am working on Magento 2 EE 2.14 and my custom sample csv file cannot be downloaded.
Thank you!
Mathieu

@drdrak3
Copy link

drdrak3 commented Aug 30, 2017

I'm also after this functionality, any news?

@magento-engcom-team magento-engcom-team added 2.0.x Issue: Ready for Work Gate 4. Acknowledged. Issue is added to backlog and ready for development bug report Issue: Format is valid Gate 1 Passed. Automatic verification of issue format passed Component: ImportExport labels Sep 11, 2017
@okorshenko okorshenko added Issue: Clear Description Gate 2 Passed. Manual verification of the issue description passed Issue: Confirmed Gate 3 Passed. Manual verification of the issue completed. Issue is confirmed labels Sep 29, 2017
@piotrekkaminski
Copy link
Contributor

This issue was moved to magento-engcom/import-export-improvements#53

@kirtinariya1
Copy link
Contributor

kirtinariya1 commented Jun 19, 2019

@EliasKotlyar Have you import categories via csv. I have created same but getting some issue.
Let me know if you have done for same.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug report Component: ImportExport Issue: Clear Description Gate 2 Passed. Manual verification of the issue description passed Issue: Confirmed Gate 3 Passed. Manual verification of the issue completed. Issue is confirmed Issue: Format is valid Gate 1 Passed. Automatic verification of issue format passed Issue: Ready for Work Gate 4. Acknowledged. Issue is added to backlog and ready for development
Projects
None yet
Development

No branches or pull requests

9 participants