Reindexing

In some situation when you want to re-index Magento catalog you will get an error message or reindex process will be broken. This problem is appearing when you have a lot of products in database and limited server resource. You can try to reindex from command line or shell.
In Magento there is folder with name “shell” in this folder you will find file with name “indexer.php” this is shell script for reindexing. You will ask yourself how to call this script, and take a look on my examples below and everything will be clear.

First of all you need to have access to linux commnad line or shell, and then go to your “MAGENTO_ROOT_FOLDER/shell“.

Our first example is how to get help from “indexer.php” script, you need to execute next comand “php -f indexer.php help” and you will get response as in example below.

$ php -f indexer.php help
  --status <indexer>            Show Indexer(s) Status
  --mode <indexer>              Show Indexer(s) Index Mode
  --mode-realtime <indexer>     Set index mode type "Update on Save"
  --mode-manual <indexer>       Set index mode type "Manual Update"
  --reindex <indexer>           Reindex Data
  info                          Show allowed indexers
  reindexall                    Reindex Data by all indexers
  help                          This help
 
  <indexer>     Comma separated indexer codes or value "all" for all indexers

You can see that you can make reindexall but I don’t recommend that you execute full reindex in one step, beacuse you can cause MySql/Server overload. Reindexall calls 8 indexers in a row and process of reindexing can cause database LOCK on some database tables.

I recommend that you execute one by one indexer. Your process will be faster and load of database will be smaller.

In Magento there are 8 indexers, you can get list of indexers if you call next command: php -f indexer.php info

exemple:

$ php -f indexer.php info
catalog_product_attribute     Product Attributes
catalog_product_price         Product Prices
catalog_url                   Catalog Url Rewrites
catalog_product_flat          Product Flat Data
catalog_category_flat         Category Flat Data
catalog_category_product      Category Products
catalogsearch_fulltext        Catalog Search Index
cataloginventory_stock        Stock status

For example if you want to reindex “catalog_url” you need to execute next command: php -f indexer.php — -reindex catalog_url 

example:

$ php -f indexer.php -- -reindex catalog_url
Catalog URL Rewrites index was rebuilt successfully

I recommend that you use indexer from shell because this process isn’t executing over web server/Apache and makes smaller impact on server resources.

One note: I had problem with php memory limit, error message: “Fatal error: Allowed memory size of 67108864 bytes exhausted (tried to allocate 88 bytes)“. I increased memory size to 256MB, I added next statement on beginning of script: ini_set(‘memory_limit’, ‘256M’); .

  • 2 Korisnici koji smatraju članak korisnim
Je li Vam ovaj odgovor pomogao?

Vezani članci

Transactional emails variables

We do receive from time to time the request of "what are the accepted variables in the...

SQLSTATE[23000]: Integrity constraint violation: 1062 Duplicate entry '2828-148-1-471' for key 'PRIMARY'

While trying to reindex your store using the command line, you stumble on the following...

How to Show or hide out of stock products in Magento

The process is fairly straight forwardShow out of stock products in Magento   Login to the...

How to disable guest checkout

By default guests can shop without creating a customer account on your eCommerce. You can...

SCRIPT_NAME & SCRIPT_FILENAME errors with cron

CRON ErrorsYou may encounter those errors in your log while inspecting those:[23-Oct-2016...