Custom Export Report issue in Magento 2CSV import not working - Need AssistanceExport report not showing fieldsIssue with custom reportCustom csv export - customersMagento 2 add custom columns in exportCannot export list of customer from the grid magento 2Magento Customer Grid Custom attribute can't export csv and export xmlHow to change “input file” storage location in customer account edit formMagento 2.3 email attachment not working while sending custom emailMagento 2 Custom sales report export issue
Secure my password from unsafe servers
Is TA-ing worth the opportunity cost?
Why are the inside diameters of some pipe larger than the stated size?
Why use regularization instead of decreasing the model
Is it true that control+alt+delete only became a thing because IBM would not build Bill Gates a computer with a task manager button?
What are these mathematical groups in U.S. universities?
Does the Voyager team use a wrapper (Fortran(77?) to Python) to transmit current commands?
WordCloud: do not eliminate duplicates
Where is the rule for moving slowly when searching for traps that’s referenced by Dungeon Delver?
Why can I log in to my Facebook account with a misspelled email/password?
Casting Goblin Matron with Plague Engineer on the battlefield
Unexpected route on a flight from USA to Europe
Traveling from Germany to other countries by train?
Ampacity of Conductive Tape
Validation and verification of mathematical models
In the movie Harry Potter and the Order or the Phoenix, why didn't Mr. Filch succeed to open the Room of Requirement if it's what he needed?
Why should public servants be apolitical?
How do I change the output voltage of the LM7805?
French equivalent of "Make leaps and bounds"
Why is there a need to prevent a racist, sexist, or otherwise bigoted vendor from discriminating who they sell to?
Is there a loss of quality when converting RGB to HEX?
Is Odin inconsistent about the powers of Mjolnir?
Is this cheap "air conditioner" able to cool a room?
Does this smartphone photo show Mars just below the Sun?
Custom Export Report issue in Magento 2
CSV import not working - Need AssistanceExport report not showing fieldsIssue with custom reportCustom csv export - customersMagento 2 add custom columns in exportCannot export list of customer from the grid magento 2Magento Customer Grid Custom attribute can't export csv and export xmlHow to change “input file” storage location in customer account edit formMagento 2.3 email attachment not working while sending custom emailMagento 2 Custom sales report export issue
.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty margin-bottom:0;
I need to export the custom grid to the csv file. I have used the below code in my listing.xml file.
<exportButton class="MagentoUiComponentExportButton">
<argument name="data" xsi:type="array">
<item name="config" xsi:type="array">
<item name="options" xsi:type="array">
<item name="cvs" xsi:type="array">
<item name="value" xsi:type="string">csv</item>
<item name="label" xsi:type="string" translate="true">CSV</item>
<item name="url" xsi:type="string">catalogreport/export/gridToCsv</item>
</item>
<item name="xml" xsi:type="array">
<item name="value" xsi:type="string">xml</item>
<item name="label" xsi:type="string" translate="true">Excel XML</item>
<item name="url" xsi:type="string">catalogreport/export/gridToXml</item>
</item>
</item>
</item>
</argument>
</exportButton>
Then in my
Module/Controller/Adminhtml/Export/gridToCsv.php
class GridToCsv extends Action
public function execute()
$fileName = "CustomSales_". date('Ymd_His').".csv";
$dataSource = //The data fetches here;
$handle = fopen($fileName, 'w');
// Adding my logic to write the content to the file
$this->downloadCsv($fileName);
public function downloadCsv($fileName)
if (file_exists($fileName))
//set appropriate headers
header('Content-Description: File Transfer');
header('Content-Type: application/csv');
header('Content-Disposition: attachment; filename='.basename($fileName));
header('Expires: 0');
header('Cache-Control: must-revalidate');
header('Pragma: public');
header('Content-Length: ' . filesize($fileName));
ob_clean();flush();
readfile($fileName);
This is working fine, The file is downloading successfully, But here my question is the CSV file is storing into the root directory, I need to change to pub/media/import
directory.
How this can be done here? I want to store the csv file inside pub/media/import
directory.
Can anyone suggest me please. Thanks!!
magento2 grid csv export
add a comment |
I need to export the custom grid to the csv file. I have used the below code in my listing.xml file.
<exportButton class="MagentoUiComponentExportButton">
<argument name="data" xsi:type="array">
<item name="config" xsi:type="array">
<item name="options" xsi:type="array">
<item name="cvs" xsi:type="array">
<item name="value" xsi:type="string">csv</item>
<item name="label" xsi:type="string" translate="true">CSV</item>
<item name="url" xsi:type="string">catalogreport/export/gridToCsv</item>
</item>
<item name="xml" xsi:type="array">
<item name="value" xsi:type="string">xml</item>
<item name="label" xsi:type="string" translate="true">Excel XML</item>
<item name="url" xsi:type="string">catalogreport/export/gridToXml</item>
</item>
</item>
</item>
</argument>
</exportButton>
Then in my
Module/Controller/Adminhtml/Export/gridToCsv.php
class GridToCsv extends Action
public function execute()
$fileName = "CustomSales_". date('Ymd_His').".csv";
$dataSource = //The data fetches here;
$handle = fopen($fileName, 'w');
// Adding my logic to write the content to the file
$this->downloadCsv($fileName);
public function downloadCsv($fileName)
if (file_exists($fileName))
//set appropriate headers
header('Content-Description: File Transfer');
header('Content-Type: application/csv');
header('Content-Disposition: attachment; filename='.basename($fileName));
header('Expires: 0');
header('Cache-Control: must-revalidate');
header('Pragma: public');
header('Content-Length: ' . filesize($fileName));
ob_clean();flush();
readfile($fileName);
This is working fine, The file is downloading successfully, But here my question is the CSV file is storing into the root directory, I need to change to pub/media/import
directory.
How this can be done here? I want to store the csv file inside pub/media/import
directory.
Can anyone suggest me please. Thanks!!
magento2 grid csv export
add a comment |
I need to export the custom grid to the csv file. I have used the below code in my listing.xml file.
<exportButton class="MagentoUiComponentExportButton">
<argument name="data" xsi:type="array">
<item name="config" xsi:type="array">
<item name="options" xsi:type="array">
<item name="cvs" xsi:type="array">
<item name="value" xsi:type="string">csv</item>
<item name="label" xsi:type="string" translate="true">CSV</item>
<item name="url" xsi:type="string">catalogreport/export/gridToCsv</item>
</item>
<item name="xml" xsi:type="array">
<item name="value" xsi:type="string">xml</item>
<item name="label" xsi:type="string" translate="true">Excel XML</item>
<item name="url" xsi:type="string">catalogreport/export/gridToXml</item>
</item>
</item>
</item>
</argument>
</exportButton>
Then in my
Module/Controller/Adminhtml/Export/gridToCsv.php
class GridToCsv extends Action
public function execute()
$fileName = "CustomSales_". date('Ymd_His').".csv";
$dataSource = //The data fetches here;
$handle = fopen($fileName, 'w');
// Adding my logic to write the content to the file
$this->downloadCsv($fileName);
public function downloadCsv($fileName)
if (file_exists($fileName))
//set appropriate headers
header('Content-Description: File Transfer');
header('Content-Type: application/csv');
header('Content-Disposition: attachment; filename='.basename($fileName));
header('Expires: 0');
header('Cache-Control: must-revalidate');
header('Pragma: public');
header('Content-Length: ' . filesize($fileName));
ob_clean();flush();
readfile($fileName);
This is working fine, The file is downloading successfully, But here my question is the CSV file is storing into the root directory, I need to change to pub/media/import
directory.
How this can be done here? I want to store the csv file inside pub/media/import
directory.
Can anyone suggest me please. Thanks!!
magento2 grid csv export
I need to export the custom grid to the csv file. I have used the below code in my listing.xml file.
<exportButton class="MagentoUiComponentExportButton">
<argument name="data" xsi:type="array">
<item name="config" xsi:type="array">
<item name="options" xsi:type="array">
<item name="cvs" xsi:type="array">
<item name="value" xsi:type="string">csv</item>
<item name="label" xsi:type="string" translate="true">CSV</item>
<item name="url" xsi:type="string">catalogreport/export/gridToCsv</item>
</item>
<item name="xml" xsi:type="array">
<item name="value" xsi:type="string">xml</item>
<item name="label" xsi:type="string" translate="true">Excel XML</item>
<item name="url" xsi:type="string">catalogreport/export/gridToXml</item>
</item>
</item>
</item>
</argument>
</exportButton>
Then in my
Module/Controller/Adminhtml/Export/gridToCsv.php
class GridToCsv extends Action
public function execute()
$fileName = "CustomSales_". date('Ymd_His').".csv";
$dataSource = //The data fetches here;
$handle = fopen($fileName, 'w');
// Adding my logic to write the content to the file
$this->downloadCsv($fileName);
public function downloadCsv($fileName)
if (file_exists($fileName))
//set appropriate headers
header('Content-Description: File Transfer');
header('Content-Type: application/csv');
header('Content-Disposition: attachment; filename='.basename($fileName));
header('Expires: 0');
header('Cache-Control: must-revalidate');
header('Pragma: public');
header('Content-Length: ' . filesize($fileName));
ob_clean();flush();
readfile($fileName);
This is working fine, The file is downloading successfully, But here my question is the CSV file is storing into the root directory, I need to change to pub/media/import
directory.
How this can be done here? I want to store the csv file inside pub/media/import
directory.
Can anyone suggest me please. Thanks!!
magento2 grid csv export
magento2 grid csv export
edited Jul 29 at 11:05
Manjunath
asked Jul 29 at 10:20
ManjunathManjunath
797 bronze badges
797 bronze badges
add a comment |
add a comment |
1 Answer
1
active
oldest
votes
Try changing Content-Disposition
in function downloadCsv($fileName)
to
header('Content-Disposition: attachment; filename='.$directory.'/'.$fileName);
Where $directory will be the media folder path which you can get dynamically by adding dependency in constructor using below code
use MagentoFrameworkAppFilesystemDirectoryList;
protected $_filesystem;
public function __construct(
MagentoFrameworkFilesystem $filesystem
)
$this->_filesystem = $filesystem;
$mediapath = $this->_filesystem->getDirectoryRead(DirectoryList::MEDIA)->getAbsolutePath();
$directory = mediapath.'import'
add a comment |
Your Answer
StackExchange.ready(function()
var channelOptions =
tags: "".split(" "),
id: "479"
;
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function()
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled)
StackExchange.using("snippets", function()
createEditor();
);
else
createEditor();
);
function createEditor()
StackExchange.prepareEditor(
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: false,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: null,
bindNavPrevention: true,
postfix: "",
imageUploader:
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
,
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
);
);
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fmagento.stackexchange.com%2fquestions%2f283649%2fcustom-export-report-issue-in-magento-2%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
Try changing Content-Disposition
in function downloadCsv($fileName)
to
header('Content-Disposition: attachment; filename='.$directory.'/'.$fileName);
Where $directory will be the media folder path which you can get dynamically by adding dependency in constructor using below code
use MagentoFrameworkAppFilesystemDirectoryList;
protected $_filesystem;
public function __construct(
MagentoFrameworkFilesystem $filesystem
)
$this->_filesystem = $filesystem;
$mediapath = $this->_filesystem->getDirectoryRead(DirectoryList::MEDIA)->getAbsolutePath();
$directory = mediapath.'import'
add a comment |
Try changing Content-Disposition
in function downloadCsv($fileName)
to
header('Content-Disposition: attachment; filename='.$directory.'/'.$fileName);
Where $directory will be the media folder path which you can get dynamically by adding dependency in constructor using below code
use MagentoFrameworkAppFilesystemDirectoryList;
protected $_filesystem;
public function __construct(
MagentoFrameworkFilesystem $filesystem
)
$this->_filesystem = $filesystem;
$mediapath = $this->_filesystem->getDirectoryRead(DirectoryList::MEDIA)->getAbsolutePath();
$directory = mediapath.'import'
add a comment |
Try changing Content-Disposition
in function downloadCsv($fileName)
to
header('Content-Disposition: attachment; filename='.$directory.'/'.$fileName);
Where $directory will be the media folder path which you can get dynamically by adding dependency in constructor using below code
use MagentoFrameworkAppFilesystemDirectoryList;
protected $_filesystem;
public function __construct(
MagentoFrameworkFilesystem $filesystem
)
$this->_filesystem = $filesystem;
$mediapath = $this->_filesystem->getDirectoryRead(DirectoryList::MEDIA)->getAbsolutePath();
$directory = mediapath.'import'
Try changing Content-Disposition
in function downloadCsv($fileName)
to
header('Content-Disposition: attachment; filename='.$directory.'/'.$fileName);
Where $directory will be the media folder path which you can get dynamically by adding dependency in constructor using below code
use MagentoFrameworkAppFilesystemDirectoryList;
protected $_filesystem;
public function __construct(
MagentoFrameworkFilesystem $filesystem
)
$this->_filesystem = $filesystem;
$mediapath = $this->_filesystem->getDirectoryRead(DirectoryList::MEDIA)->getAbsolutePath();
$directory = mediapath.'import'
answered Jul 29 at 12:32
Prachi SaxenaPrachi Saxena
3281 silver badge8 bronze badges
3281 silver badge8 bronze badges
add a comment |
add a comment |
Thanks for contributing an answer to Magento Stack Exchange!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fmagento.stackexchange.com%2fquestions%2f283649%2fcustom-export-report-issue-in-magento-2%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown