Search code examples
phpmagentomagento2

How to fix one or more indexers are invalid error in Magento?


I'm getting an error in Magento:

One or more indexers are invalid

I tried this in the command prompt:

php bin/magento indexer:reindex

but when I do, I get this error:

enter image description here

I'm not familiar with Windows; I'm used to working on a Ubuntu terminal.

please check the Magento dashboard error below: enter image description here


Solution

  • The PHP CLI as its called ( php for the Command Line Interface ) is called php.exe It lives in c:\wamp\bin\php\php5.x.y\php.exe ( where x and y are the version numbers of php that you have installed )

    If you want to create php scrips to run from the command line then great its easy and very useful.

    Create yourself a batch file like this, lets call it phppath.cmd :

    PATH=%PATH%;c:\wamp\bin\php\php5.x.y
    php -v
    

    Save this into one of your folders that is already on your PATH, so you can run it from anywhere.

    Now from a command window, cd into your source folder and run >phppath.

    Then run

    php bin/magento indexer:reindex
    

    It should work like a dream.