0

I just moved to another server and cannot reindex with Magmi, I receive the error below:

This script cannot be run from Browser. This is the shell script.

Thanks!

Dan
  • 9
  • 4

1 Answers1

1

This error occurs when you run Magmi from the browser, because Magmi runs the indexer using shell_exec command, and the $_SERVER['REQUEST_METHOD'] doesn't get unset.

You can try one of two things.

Method 1. Unset the $_SERVER['REQUEST_METHOD'] variable Magento uses to check if the shell file is being run from the browser.

To do this, open magmi/plugins/base/general/reindex/magmi_reindexing_plugin.php

Find:

    public function updateIndexes()
    {

At the top of the updateIndexes() function, add the following:

    if(isset($_SERVER['REQUEST_METHOD']))
    {
        unset($_SERVER['REQUEST_METHOD']);  
    }

So it will look like this:

    public function updateIndexes()
    {
        if(isset($_SERVER['REQUEST_METHOD']))
        {
            unset($_SERVER['REQUEST_METHOD']);  
        }

Method 2: Modify the _validate() function in [magento_root]/shell/abstract.php

Open [magento_root]/shell/abstract.php

Find:

    protected function _validate()
    {
        if (isset($_SERVER['REQUEST_METHOD'])) {
            die('This script cannot be run from Browser. This is the shell script.');
        }
    }

Replace with:

    protected function _validate()
    {
        if (isset($_SERVER['REQUEST_METHOD'])) {
            //die('This script cannot be run from Browser. This is the shell script.');
        }
    }
Axel
  • 10,732
  • 2
  • 30
  • 43
  • Thank you but didn't help, I copy a part of the code below. Then I was receiving error on line 111. public function getIndexList() { return $this->_indexlist; } public function updateIndexes() { if(isset($_SERVER['REQUEST_METHOD'])) { unset($_SERVER['REQUEST_METHOD']); } { //make sure we are not in session if(session_id()!=="") { session_write_close(); } $cl=$this->getParam("REINDEX:phpcli")." shell/indexer.php"; $idxlstr=$this->getParam("REINDEX:indexes",""); $idxlist=explode(",",$idxlstr); if(count($idxlist)==0) – Dan Oct 15 '13 at 17:46
  • Parse error: syntax error, unexpected T_PUBLIC in /home/public_html/magmi/plugins/base/general/reindex/magmi_reindexing_plugin.php on line 111. This error I receive it in magmi.php page at the profile section. – Dan Oct 15 '13 at 18:06
  • You didn't insert the code correctly. Make sure you are inserting it correctly and follow my instructions. I just copy/pasted the snippet and inserted it exactly where I said and I receive no error. – Axel Oct 15 '13 at 18:35
  • OK, thanks. Now I don't receive this error but reindex is actually not running. After I moved server and see it was not working I contacted my hosting and they told me to use /usr/bin/php5-cli instead of php, I don't know if this is related to something but I checked with both and reindex is not running after updating stock with Magmi. Any idea? Thanks again. – Dan Oct 16 '13 at 15:22
  • What are you seeing in the log output when the index is running within Magmi? – Axel Oct 16 '13 at 15:37
  • Hi Alex, please see below: Magmi Magento Reindexer v1.0.2 - Cleaning flat tables before reindex... Magmi Magento Reindexer v1.0.2 - running indexer Magmi Magento Reindexer v1.0.2 - Reindexing cataloginventory_stock.... Magmi Magento Reindexer v1.0.2 - Magmi Magento Reindexer v1.0.2 - done in 0.12 secs Magmi Magento Reindexer v1.0.2 - Reindexing catalogsearch_fulltext.... Magmi Magento Reindexer v1.0.2 - Magmi Magento Reindexer v1.0.2 - done in 0.12 secs But actually the reindex didn't run. – Dan Oct 21 '13 at 10:33
  • Login to your server using shell, and `cd` to the `/shell` directory in your Magento root folder. Once there, run the following command: `php indexer.php reindexall` and see if it re-indexes everything. – Axel Oct 21 '13 at 14:55
  • OK, good point, this is the output: Could not open input file: indexer.php What can be the problem? Probably permissions? – Dan Oct 21 '13 at 17:47
  • Make sure the permissions for the file are 755 for folders, 644 for files. `cd` to your Magento root and run the following command to set the correct permissions: `chmod -R 755 *; find -type f -print0|xargs -0 chmod 644` – Axel Oct 21 '13 at 17:52
  • My hosting ran the following but still the same: find ./ -type f -exec chmod 0644 {} \; find ./ -type d -exec chmod 0755 {} \; – Dan Oct 23 '13 at 16:37
  • Hi, I received this solution from hosting I can run reindex from ssh now: The indexer.php script is located in the 'shell' folder of your Magento root if I am not mistaken. Therefore, I believe your syntax should be as follows. > php ./shell/indexer.php reindexall What should I modify in magmi? Thank you. – Dan Oct 24 '13 at 06:05
  • The shell command isn't related to Magmi. You need to run it from the shell command line. If it doesn't work from there, it's not a Magmi related issue, but an issue with your Magento setup. I suggest hiring a Magento expert to look into it further as your issue is beyond the scope of what we can do on StackOverflow. – Axel Oct 24 '13 at 14:30