How to run external script outside of magento 2 root directory? Planned maintenance scheduled April 23, 2019 at 00:00UTC (8:00pm US/Eastern) Announcing the arrival of Valued Associate #679: Cesar Manara Unicorn Meta Zoo #1: Why another podcast?Magento 2: Calling Custom File on Root Gives RuntimeExceptionMagento 2 Log Bundle Product Data in List Page?Magento Module creation gives errorMagento 2 : after upgrading magento 2 with command site not working“There has been an error processing your request” in Admin area after installationMagento 2: Can't install or uninstall plugins in magento 2Magento 2 and VES theme. Site front and back shows corrupt? PHP version issue?Getting Errors after MySQL database importError Database Magento 2.3 migration from localhost to serverMagento 2 - create custom script on root directory
Maximum summed subsequences with non-adjacent items
Are all finite dimensional hilbert spaces isomorphic to spaces with Euclidean norms?
What's the meaning of "fortified infraction restraint"?
How to install press fit bottom bracket into new frame
Is grep documentation about ignoring case wrong, since it doesn't ignore case in filenames?
Find 108 by using 3,4,6
What do you call the main part of a joke?
How does light 'choose' between wave and particle behaviour?
Time to Settle Down!
How would a mousetrap for use in space work?
What is the appropriate index architecture when forced to implement IsDeleted (soft deletes)?
Using et al. for a last / senior author rather than for a first author
Can an alien society believe that their star system is the universe?
Chinese Seal on silk painting - what does it mean?
Significance of Cersei's obsession with elephants?
What is the difference between globalisation and imperialism?
Is there hard evidence that the grant peer review system performs significantly better than random?
What is the font for "b" letter?
How to write the following sign?
Performance gap between vector<bool> and array
Should I follow up with an employee I believe overracted to a mistake I made?
An adverb for when you're not exaggerating
Project Euler #1 in C++
Does the Weapon Master feat grant you a fighting style?
How to run external script outside of magento 2 root directory?
Planned maintenance scheduled April 23, 2019 at 00:00UTC (8:00pm US/Eastern)
Announcing the arrival of Valued Associate #679: Cesar Manara
Unicorn Meta Zoo #1: Why another podcast?Magento 2: Calling Custom File on Root Gives RuntimeExceptionMagento 2 Log Bundle Product Data in List Page?Magento Module creation gives errorMagento 2 : after upgrading magento 2 with command site not working“There has been an error processing your request” in Admin area after installationMagento 2: Can't install or uninstall plugins in magento 2Magento 2 and VES theme. Site front and back shows corrupt? PHP version issue?Getting Errors after MySQL database importError Database Magento 2.3 migration from localhost to serverMagento 2 - create custom script on root directory
.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty margin-bottom:0;
I have made a few external php scripts to update quantity and tracking numbers,etc Right now, i'm putting them in magento root and set the permission to 640. However, it's still accessible by the browser. I would like to make it accessible by cron and the owner/group only.
I tried to move the script to
magentoroot/script/
, and change the following in the script:
$file = fopen('../../qty.csv', 'r', '"');
require DIR . '../app/bootstrap.php';
$writer = new ZendLogWriterStream(BP .
'../var/log/import-update.log');
then the script stop working. what should i change in the file?
<?php $file = fopen('../qty.csv', 'r', '"'); // set path to the CSV file
if ($file !== false) {
require __DIR__ . '/app/bootstrap.php';
$bootstrap = MagentoFrameworkAppBootstrap::create(BP, $_SERVER);
$objectManager = $bootstrap->getObjectManager();
$state = $objectManager->get('MagentoFrameworkAppState');
$state->setAreaCode('adminhtml');
// used for updating product info
$productRepository = $objectManager->get('MagentoCatalogModelProductRepository');
// used for updating product stock
$stockRegistry = $objectManager->get('MagentoCatalogInventoryApiStockRegistryInterface');
// add logging capability
$writer = new ZendLogWriterStream(BP . '/var/log/import-update.log');
$logger = new ZendLogLogger();
$logger->addWriter($writer);
.....
.....
.....
magento2 cron permissions script file-permissions
add a comment |
I have made a few external php scripts to update quantity and tracking numbers,etc Right now, i'm putting them in magento root and set the permission to 640. However, it's still accessible by the browser. I would like to make it accessible by cron and the owner/group only.
I tried to move the script to
magentoroot/script/
, and change the following in the script:
$file = fopen('../../qty.csv', 'r', '"');
require DIR . '../app/bootstrap.php';
$writer = new ZendLogWriterStream(BP .
'../var/log/import-update.log');
then the script stop working. what should i change in the file?
<?php $file = fopen('../qty.csv', 'r', '"'); // set path to the CSV file
if ($file !== false) {
require __DIR__ . '/app/bootstrap.php';
$bootstrap = MagentoFrameworkAppBootstrap::create(BP, $_SERVER);
$objectManager = $bootstrap->getObjectManager();
$state = $objectManager->get('MagentoFrameworkAppState');
$state->setAreaCode('adminhtml');
// used for updating product info
$productRepository = $objectManager->get('MagentoCatalogModelProductRepository');
// used for updating product stock
$stockRegistry = $objectManager->get('MagentoCatalogInventoryApiStockRegistryInterface');
// add logging capability
$writer = new ZendLogWriterStream(BP . '/var/log/import-update.log');
$logger = new ZendLogLogger();
$logger->addWriter($writer);
.....
.....
.....
magento2 cron permissions script file-permissions
add a comment |
I have made a few external php scripts to update quantity and tracking numbers,etc Right now, i'm putting them in magento root and set the permission to 640. However, it's still accessible by the browser. I would like to make it accessible by cron and the owner/group only.
I tried to move the script to
magentoroot/script/
, and change the following in the script:
$file = fopen('../../qty.csv', 'r', '"');
require DIR . '../app/bootstrap.php';
$writer = new ZendLogWriterStream(BP .
'../var/log/import-update.log');
then the script stop working. what should i change in the file?
<?php $file = fopen('../qty.csv', 'r', '"'); // set path to the CSV file
if ($file !== false) {
require __DIR__ . '/app/bootstrap.php';
$bootstrap = MagentoFrameworkAppBootstrap::create(BP, $_SERVER);
$objectManager = $bootstrap->getObjectManager();
$state = $objectManager->get('MagentoFrameworkAppState');
$state->setAreaCode('adminhtml');
// used for updating product info
$productRepository = $objectManager->get('MagentoCatalogModelProductRepository');
// used for updating product stock
$stockRegistry = $objectManager->get('MagentoCatalogInventoryApiStockRegistryInterface');
// add logging capability
$writer = new ZendLogWriterStream(BP . '/var/log/import-update.log');
$logger = new ZendLogLogger();
$logger->addWriter($writer);
.....
.....
.....
magento2 cron permissions script file-permissions
I have made a few external php scripts to update quantity and tracking numbers,etc Right now, i'm putting them in magento root and set the permission to 640. However, it's still accessible by the browser. I would like to make it accessible by cron and the owner/group only.
I tried to move the script to
magentoroot/script/
, and change the following in the script:
$file = fopen('../../qty.csv', 'r', '"');
require DIR . '../app/bootstrap.php';
$writer = new ZendLogWriterStream(BP .
'../var/log/import-update.log');
then the script stop working. what should i change in the file?
<?php $file = fopen('../qty.csv', 'r', '"'); // set path to the CSV file
if ($file !== false) {
require __DIR__ . '/app/bootstrap.php';
$bootstrap = MagentoFrameworkAppBootstrap::create(BP, $_SERVER);
$objectManager = $bootstrap->getObjectManager();
$state = $objectManager->get('MagentoFrameworkAppState');
$state->setAreaCode('adminhtml');
// used for updating product info
$productRepository = $objectManager->get('MagentoCatalogModelProductRepository');
// used for updating product stock
$stockRegistry = $objectManager->get('MagentoCatalogInventoryApiStockRegistryInterface');
// add logging capability
$writer = new ZendLogWriterStream(BP . '/var/log/import-update.log');
$logger = new ZendLogLogger();
$logger->addWriter($writer);
.....
.....
.....
magento2 cron permissions script file-permissions
magento2 cron permissions script file-permissions
edited 2 mins ago
Kris Wen
asked 2 hours ago
Kris WenKris Wen
1589
1589
add a comment |
add a comment |
0
active
oldest
votes
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%2f270717%2fhow-to-run-external-script-outside-of-magento-2-root-directory%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
0
active
oldest
votes
0
active
oldest
votes
active
oldest
votes
active
oldest
votes
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%2f270717%2fhow-to-run-external-script-outside-of-magento-2-root-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