How do I open a csv file in the root of my module directory?Importing orders from a CSV into Magento programmaticallyTroubleshooting steps for module not appearing in System->configuration->advancedProblem importing images from a CSV file - Magento ver. 1.9.2.2Error while importing a csv file in the adminCannot open CSV file in phtml templateCSV file wont upload?Magento 2 Import CSV File to Custom Module TableMagento 2.3 Can't view module's front end page output?How to import CSV file programatically from another directory?Magento 2 Uncaught TypeError: Argument 1 […] DataSetup::__construct() […] must be an instance […]
Best way to explain to my boss that I cannot attend a team summit because it is on Rosh Hashana or any other Jewish Holiday
Do any languages mention the top limit of a range first?
Why should public servants be apolitical?
How to approach protecting my code as a research assistant? Should I be worried in the first place?
Repeated! Factorials!
Probably terminated or laid off soon; confront or not?
Is there such thing as a "3-dimensional surface?"
What is the bio-mechanical plausibility of a fox with venomous fangs?
How do I get the =LEFT function in excel, to also take the number zero as the first number?
"How do you solve a problem like Maria?"
How do these cubesats' whip antennas work?
Cobb-Douglas production function with expenditures rather than units
What is the purpose of this mount on the upper suspension arm?
Why can I log in to my Facebook account with a misspelled email/password?
Where in ש״ס who one find the adage, “He who suggests the idea should carry it out”?
How to continue a line in Latex in math mode?
Is DC heating faster than AC heating?
Differentiability of operator norm
Who is the god Ao?
Where to pee in London?
Is this cheap "air conditioner" able to cool a room?
Traveling from Germany to other countries by train?
Does the length of a password for Wi-Fi affect speed?
Should I self-publish my novella on Amazon or try my luck getting publishers?
How do I open a csv file in the root of my module directory?
Importing orders from a CSV into Magento programmaticallyTroubleshooting steps for module not appearing in System->configuration->advancedProblem importing images from a CSV file - Magento ver. 1.9.2.2Error while importing a csv file in the adminCannot open CSV file in phtml templateCSV file wont upload?Magento 2 Import CSV File to Custom Module TableMagento 2.3 Can't view module's front end page output?How to import CSV file programatically from another directory?Magento 2 Uncaught TypeError: Argument 1 […] DataSetup::__construct() […] must be an instance […]
.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty margin-bottom:0;
I've been writing a rather complicated module as of late. One of the steps I need to do is pre-populate one of the models with all of the data it needs to work right. This data is slowly replaced using a syncing system / rest calls from our database software, but it needs to be there initially so the end user doesn't think its 'all missing' before this sync happens.
I've been trying to use a csv file in my module directory. For the life of me, I can't figure out the combination of factories and methods to get that folder. I can't assume its going to be in ANY particular place though, since this module will end up on a CDN hosted platform.
I've tried injecting
MagentoFrameworkModuleDirReaderFactory
MagentoFrameworkAppFilesystemDirectoryListFactory
as well as direct php
__DIR__
dir()
dirname()
$_SERVER (ugh)
None of this can figure out
/var/www/app/code/mycompname/modulename/data.csv
while developing.. and
/var/www/vendor/mycompname/modulename/data.csv
when testing the composer distribution.
Any suggestions are welcome. I need to load the full path to use something like this....
$csv = file($pathThatWasFound);
EDIT: I read http://alanstorm.com/magento_base_directories <--- based on 1.x magento. I need 2.0 suggestions
EDIT: I may be bumping into constraints of FILE magic and xdebug (https://stackoverflow.com/questions/4924676/how-can-i-get-the-php-magic-constant-file-work-with-eclipse-and-pdt)
module csv folder paths
add a comment |
I've been writing a rather complicated module as of late. One of the steps I need to do is pre-populate one of the models with all of the data it needs to work right. This data is slowly replaced using a syncing system / rest calls from our database software, but it needs to be there initially so the end user doesn't think its 'all missing' before this sync happens.
I've been trying to use a csv file in my module directory. For the life of me, I can't figure out the combination of factories and methods to get that folder. I can't assume its going to be in ANY particular place though, since this module will end up on a CDN hosted platform.
I've tried injecting
MagentoFrameworkModuleDirReaderFactory
MagentoFrameworkAppFilesystemDirectoryListFactory
as well as direct php
__DIR__
dir()
dirname()
$_SERVER (ugh)
None of this can figure out
/var/www/app/code/mycompname/modulename/data.csv
while developing.. and
/var/www/vendor/mycompname/modulename/data.csv
when testing the composer distribution.
Any suggestions are welcome. I need to load the full path to use something like this....
$csv = file($pathThatWasFound);
EDIT: I read http://alanstorm.com/magento_base_directories <--- based on 1.x magento. I need 2.0 suggestions
EDIT: I may be bumping into constraints of FILE magic and xdebug (https://stackoverflow.com/questions/4924676/how-can-i-get-the-php-magic-constant-file-work-with-eclipse-and-pdt)
module csv folder paths
add a comment |
I've been writing a rather complicated module as of late. One of the steps I need to do is pre-populate one of the models with all of the data it needs to work right. This data is slowly replaced using a syncing system / rest calls from our database software, but it needs to be there initially so the end user doesn't think its 'all missing' before this sync happens.
I've been trying to use a csv file in my module directory. For the life of me, I can't figure out the combination of factories and methods to get that folder. I can't assume its going to be in ANY particular place though, since this module will end up on a CDN hosted platform.
I've tried injecting
MagentoFrameworkModuleDirReaderFactory
MagentoFrameworkAppFilesystemDirectoryListFactory
as well as direct php
__DIR__
dir()
dirname()
$_SERVER (ugh)
None of this can figure out
/var/www/app/code/mycompname/modulename/data.csv
while developing.. and
/var/www/vendor/mycompname/modulename/data.csv
when testing the composer distribution.
Any suggestions are welcome. I need to load the full path to use something like this....
$csv = file($pathThatWasFound);
EDIT: I read http://alanstorm.com/magento_base_directories <--- based on 1.x magento. I need 2.0 suggestions
EDIT: I may be bumping into constraints of FILE magic and xdebug (https://stackoverflow.com/questions/4924676/how-can-i-get-the-php-magic-constant-file-work-with-eclipse-and-pdt)
module csv folder paths
I've been writing a rather complicated module as of late. One of the steps I need to do is pre-populate one of the models with all of the data it needs to work right. This data is slowly replaced using a syncing system / rest calls from our database software, but it needs to be there initially so the end user doesn't think its 'all missing' before this sync happens.
I've been trying to use a csv file in my module directory. For the life of me, I can't figure out the combination of factories and methods to get that folder. I can't assume its going to be in ANY particular place though, since this module will end up on a CDN hosted platform.
I've tried injecting
MagentoFrameworkModuleDirReaderFactory
MagentoFrameworkAppFilesystemDirectoryListFactory
as well as direct php
__DIR__
dir()
dirname()
$_SERVER (ugh)
None of this can figure out
/var/www/app/code/mycompname/modulename/data.csv
while developing.. and
/var/www/vendor/mycompname/modulename/data.csv
when testing the composer distribution.
Any suggestions are welcome. I need to load the full path to use something like this....
$csv = file($pathThatWasFound);
EDIT: I read http://alanstorm.com/magento_base_directories <--- based on 1.x magento. I need 2.0 suggestions
EDIT: I may be bumping into constraints of FILE magic and xdebug (https://stackoverflow.com/questions/4924676/how-can-i-get-the-php-magic-constant-file-work-with-eclipse-and-pdt)
module csv folder paths
module csv folder paths
edited May 23 '17 at 12:37
Community♦
1
1
asked Apr 28 '16 at 19:26
CarCompCarComp
84911 silver badges27 bronze badges
84911 silver badges27 bronze badges
add a comment |
add a comment |
3 Answers
3
active
oldest
votes
The magento2 sample data codebase has good examples of how this is done.
They define the install
function in the model to populate the database.
This function is called inside the <vendor_name><module_name>Installer
class which is called inside the <vendor_name><module_name>InstallData
class.
I know how the installer works. Thanks though. I guess I should have mentioned i'm running this function from InstallData.php
– CarComp
Apr 28 '16 at 19:52
add a comment |
I figured out what I was doing wrong...
https://stackoverflow.com/questions/5497441/generic-path-to-a-module-in-magento
I need to use the module namespace as well as the module name on getModuleDir()
$readerFactory->getModuleDir('','YourNameSpace_YourExtension')
This gives me the root path to my module.
My final exact copy of this thing is as follows:
$csv = array_map('str_getcsv',file($readerFactory->getModuleDir('','Stti_Healthday') . '/assignments.csv'))
add a comment |
Depending on what you are doing there are other options
https://github.com/DominicWatts/CsvUpload/blob/446ba3c80fc7f9136e7bdf6bda859c0e5d327ed0/view/adminhtml/templates/index/submit.phtml#L2
<a href="<?= $block->escapeUrl($block->getViewFileUrl('Xigen_CsvUpload::template.csv'));?>" target="_blank"><?= $block->escapeHtml(__("CSV Template")); ?></a>
So file path is
vendor/module/view/adminhtml|frontend/web/template.csv
Example
https://github.com/DominicWatts/CsvUpload/blob/master/view/adminhtml/web/template.csv
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%2f113191%2fhow-do-i-open-a-csv-file-in-the-root-of-my-module-directory%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
3 Answers
3
active
oldest
votes
3 Answers
3
active
oldest
votes
active
oldest
votes
active
oldest
votes
The magento2 sample data codebase has good examples of how this is done.
They define the install
function in the model to populate the database.
This function is called inside the <vendor_name><module_name>Installer
class which is called inside the <vendor_name><module_name>InstallData
class.
I know how the installer works. Thanks though. I guess I should have mentioned i'm running this function from InstallData.php
– CarComp
Apr 28 '16 at 19:52
add a comment |
The magento2 sample data codebase has good examples of how this is done.
They define the install
function in the model to populate the database.
This function is called inside the <vendor_name><module_name>Installer
class which is called inside the <vendor_name><module_name>InstallData
class.
I know how the installer works. Thanks though. I guess I should have mentioned i'm running this function from InstallData.php
– CarComp
Apr 28 '16 at 19:52
add a comment |
The magento2 sample data codebase has good examples of how this is done.
They define the install
function in the model to populate the database.
This function is called inside the <vendor_name><module_name>Installer
class which is called inside the <vendor_name><module_name>InstallData
class.
The magento2 sample data codebase has good examples of how this is done.
They define the install
function in the model to populate the database.
This function is called inside the <vendor_name><module_name>Installer
class which is called inside the <vendor_name><module_name>InstallData
class.
answered Apr 28 '16 at 19:50
James CalcabenJames Calcaben
312 bronze badges
312 bronze badges
I know how the installer works. Thanks though. I guess I should have mentioned i'm running this function from InstallData.php
– CarComp
Apr 28 '16 at 19:52
add a comment |
I know how the installer works. Thanks though. I guess I should have mentioned i'm running this function from InstallData.php
– CarComp
Apr 28 '16 at 19:52
I know how the installer works. Thanks though. I guess I should have mentioned i'm running this function from InstallData.php
– CarComp
Apr 28 '16 at 19:52
I know how the installer works. Thanks though. I guess I should have mentioned i'm running this function from InstallData.php
– CarComp
Apr 28 '16 at 19:52
add a comment |
I figured out what I was doing wrong...
https://stackoverflow.com/questions/5497441/generic-path-to-a-module-in-magento
I need to use the module namespace as well as the module name on getModuleDir()
$readerFactory->getModuleDir('','YourNameSpace_YourExtension')
This gives me the root path to my module.
My final exact copy of this thing is as follows:
$csv = array_map('str_getcsv',file($readerFactory->getModuleDir('','Stti_Healthday') . '/assignments.csv'))
add a comment |
I figured out what I was doing wrong...
https://stackoverflow.com/questions/5497441/generic-path-to-a-module-in-magento
I need to use the module namespace as well as the module name on getModuleDir()
$readerFactory->getModuleDir('','YourNameSpace_YourExtension')
This gives me the root path to my module.
My final exact copy of this thing is as follows:
$csv = array_map('str_getcsv',file($readerFactory->getModuleDir('','Stti_Healthday') . '/assignments.csv'))
add a comment |
I figured out what I was doing wrong...
https://stackoverflow.com/questions/5497441/generic-path-to-a-module-in-magento
I need to use the module namespace as well as the module name on getModuleDir()
$readerFactory->getModuleDir('','YourNameSpace_YourExtension')
This gives me the root path to my module.
My final exact copy of this thing is as follows:
$csv = array_map('str_getcsv',file($readerFactory->getModuleDir('','Stti_Healthday') . '/assignments.csv'))
I figured out what I was doing wrong...
https://stackoverflow.com/questions/5497441/generic-path-to-a-module-in-magento
I need to use the module namespace as well as the module name on getModuleDir()
$readerFactory->getModuleDir('','YourNameSpace_YourExtension')
This gives me the root path to my module.
My final exact copy of this thing is as follows:
$csv = array_map('str_getcsv',file($readerFactory->getModuleDir('','Stti_Healthday') . '/assignments.csv'))
edited May 23 '17 at 12:37
Community♦
1
1
answered Apr 28 '16 at 19:46
CarCompCarComp
84911 silver badges27 bronze badges
84911 silver badges27 bronze badges
add a comment |
add a comment |
Depending on what you are doing there are other options
https://github.com/DominicWatts/CsvUpload/blob/446ba3c80fc7f9136e7bdf6bda859c0e5d327ed0/view/adminhtml/templates/index/submit.phtml#L2
<a href="<?= $block->escapeUrl($block->getViewFileUrl('Xigen_CsvUpload::template.csv'));?>" target="_blank"><?= $block->escapeHtml(__("CSV Template")); ?></a>
So file path is
vendor/module/view/adminhtml|frontend/web/template.csv
Example
https://github.com/DominicWatts/CsvUpload/blob/master/view/adminhtml/web/template.csv
add a comment |
Depending on what you are doing there are other options
https://github.com/DominicWatts/CsvUpload/blob/446ba3c80fc7f9136e7bdf6bda859c0e5d327ed0/view/adminhtml/templates/index/submit.phtml#L2
<a href="<?= $block->escapeUrl($block->getViewFileUrl('Xigen_CsvUpload::template.csv'));?>" target="_blank"><?= $block->escapeHtml(__("CSV Template")); ?></a>
So file path is
vendor/module/view/adminhtml|frontend/web/template.csv
Example
https://github.com/DominicWatts/CsvUpload/blob/master/view/adminhtml/web/template.csv
add a comment |
Depending on what you are doing there are other options
https://github.com/DominicWatts/CsvUpload/blob/446ba3c80fc7f9136e7bdf6bda859c0e5d327ed0/view/adminhtml/templates/index/submit.phtml#L2
<a href="<?= $block->escapeUrl($block->getViewFileUrl('Xigen_CsvUpload::template.csv'));?>" target="_blank"><?= $block->escapeHtml(__("CSV Template")); ?></a>
So file path is
vendor/module/view/adminhtml|frontend/web/template.csv
Example
https://github.com/DominicWatts/CsvUpload/blob/master/view/adminhtml/web/template.csv
Depending on what you are doing there are other options
https://github.com/DominicWatts/CsvUpload/blob/446ba3c80fc7f9136e7bdf6bda859c0e5d327ed0/view/adminhtml/templates/index/submit.phtml#L2
<a href="<?= $block->escapeUrl($block->getViewFileUrl('Xigen_CsvUpload::template.csv'));?>" target="_blank"><?= $block->escapeHtml(__("CSV Template")); ?></a>
So file path is
vendor/module/view/adminhtml|frontend/web/template.csv
Example
https://github.com/DominicWatts/CsvUpload/blob/master/view/adminhtml/web/template.csv
answered Jul 28 at 19:02
Dominic XigenDominic Xigen
3,1761 gold badge5 silver badges18 bronze badges
3,1761 gold badge5 silver badges18 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%2f113191%2fhow-do-i-open-a-csv-file-in-the-root-of-my-module-directory%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