How to run external script outside of magento 2 root directory? Planned maintenance scheduled...

Do wooden building fires get hotter than 600°C?

Why should I vote and accept answers?

Did Krishna say in Bhagavad Gita "I am in every living being"

What would you call this weird metallic apparatus that allows you to lift people?

What is this clumpy 20-30cm high yellow-flowered plant?

Why is it faster to reheat something than it is to cook it?

Why do we need to use the builder design pattern when we can do the same thing with setters?

How to install press fit bottom bracket into new frame

What was the first language to use conditional keywords?

Is there any word for a place full of confusion?

Denied boarding although I have proper visa and documentation. To whom should I make a complaint?

ArcGIS Pro Python arcpy.CreatePersonalGDB_management

Why does it sometimes sound good to play a grace note as a lead in to a note in a melody?

As a beginner, should I get a Squier Strat with a SSS config or a HSS?

Central Vacuuming: Is it worth it, and how does it compare to normal vacuuming?

What does it mean that physics no longer uses mechanical models to describe phenomena?

How does light 'choose' between wave and particle behaviour?

Find 108 by using 3,4,6

How could we fake a moon landing now?

What is the topology associated with the algebras for the ultrafilter monad?

How do living politicians protect their readily obtainable signatures from misuse?

Can a new player join a group only when a new campaign starts?

How to tell that you are a giant?

SF book about people trapped in a series of worlds they imagine



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;
}







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);
.....
.....
.....









share|improve this question































    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);
    .....
    .....
    .....









    share|improve this question



























      0












      0








      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);
      .....
      .....
      .....









      share|improve this question
















      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






      share|improve this question















      share|improve this question













      share|improve this question




      share|improve this question








      edited 7 mins ago







      Kris Wen

















      asked 2 hours ago









      Kris WenKris Wen

      1589




      1589






















          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
          });


          }
          });














          draft saved

          draft discarded


















          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
















          draft saved

          draft discarded




















































          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.




          draft saved


          draft discarded














          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





















































          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







          Popular posts from this blog

          迭戈·戈丁...

          A phrase ”follow into" in a context The 2019 Stack Overflow Developer Survey Results Are...

          1960s short story making fun of James Bond-style spy fiction The 2019 Stack Overflow Developer...