How do I open a csv file in the root of my module directory?Importing orders from a CSV into Magento...
When was drinking water recognized as crucial in marathon running?
Is divide-by-zero a security vulnerability?
How to properly claim credit for peer review?
Is there a low-level alternative to Animate Objects?
Replacement ford fiesta radiator has extra hose
It took me a lot of time to make this, pls like. (YouTube Comments #1)
What do the pedals on grand pianos do?
The change directory (cd) command is not working with a USB drive
Easy code troubleshooting in wordpress
What are these green text/line displays shown during the livestream of Crew Dragon's approach to dock with the ISS?
What can I substitute for soda pop in a sweet pork recipe?
Significance and timing of "mux scans"
Contradiction with Banach Fixed Point Theorem
Understanding Kramnik's play in game 1 of Candidates 2018
How can I handle a player who pre-plans arguments about my rulings on RAW?
Did 5.25" floppies undergo a change in magnetic coating?
Closure of presentable objects under finite limits
Why proton concentration is divided by 10⁻⁷?
Casually inserting sexuality
Why does Starman/Roadster have radial acceleration?
Is there a German word for “analytics”?
What type of postprocessing gives the effect of people standing out
How to speed up a process
What is the wife of a henpecked husband called?
How do I open a csv file in the root of my module directory?
Importing orders from a CSV into Magento programmaticallyHow to add csv file in attributesTroubleshooting 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?Custom Module for Custom Column using Plugin Yes/No optionMagento 2 Import CSV File to Custom Module TableMagento 2.3 Can't view module's front end page output?
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
bumped to the homepage by Community♦ 9 mins ago
This question has answers that may be good or bad; the system has marked it active so that they can be reviewed.
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
bumped to the homepage by Community♦ 9 mins ago
This question has answers that may be good or bad; the system has marked it active so that they can be reviewed.
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
8401026
8401026
bumped to the homepage by Community♦ 9 mins ago
This question has answers that may be good or bad; the system has marked it active so that they can be reviewed.
bumped to the homepage by Community♦ 9 mins ago
This question has answers that may be good or bad; the system has marked it active so that they can be reviewed.
add a comment |
add a comment |
2 Answers
2
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 |
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
2 Answers
2
active
oldest
votes
2 Answers
2
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
312
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
8401026
8401026
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