Re-indexing Magento through the command line

Author avatar

Douglas Radburn

    From time to time, you might find the need to re-index Magento via the command line. This could be for a whole host of reasons, for example, if the indexer is timing out or not finishing through the web interface.

    Magento includes an indexing script and you can find it in the shell folder.

    From here, you have a number of commands at your disposal.

    Checking for the status of all indexes


    php indexer.php --status

    Should give you output like this:

    Product Attributes:            Pending
    Product Prices:                Pending
    Stock Status:                  Pending
    Tag Aggregation Data:          Pending
    Default Values:                Pending
    Catalog URL Rewrites:          Pending
    Product Flat Data:             Require Reindex
    Category Flat Data:            Pending
    Category Products:             Pending
    Catalog Search Index:          Pending

    Re-indexing a single index

    Each index has its own index key that you can use to reference it when asking Magento to re-index. To get these keys, you can use the following command:

    php indexer.php --info

    Giving you:

    catalog_product_attribute     Product Attributes
    catalog_product_price         Product Prices
    cataloginventory_stock        Stock Status
    tag_summary                   Tag Aggregation Data
    mana_db_replicator            Default Values
    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

    To reindex a single index, run the following command.

    php indexer.php --reindex [Index Option Code]

    This can be comma delimited for multiple indices:

    php indexer.php --reindex catalog_product_price,catalog_url,catalog_product_flat

    Re-index all indices

    The following code will loop through each index and re-index it.

    php indexer.php --reindexall

    Bath

    +44 (0) 1225 480 480

    20 Manvers Street

    Bath

    BA1 1JW

    Leeds

    +44 (0) 113 260 4010

    2nd floor, 2180 Century Way,

    Thorpe Park,

    Leeds, LS15 8ZB.

    London

    +44 (0) 113 260 4010

    5th Floor, Cordy House,

    91 Curtain Road

    London, EC2A 3BS

    Part of the St. Ives Group

    • By pressing submit you consent for Edit to contact you via your email or telephone number for purposes relevant to your request for our goods or services. Your contact details, including your name, company, telephone number and email address will be used by Edit. By contacting you are agreeing to Edit’s Privacy Policy. If you have any questions, please ensure you review this section before submitting.

    • This field is for validation purposes and should be left unchanged.

    © 2018 Edit. St Ives Group. Company reg. no. 3624881, All rights reserved. VAT Registered GB 927458295 Privacy Policy | Terms & Conditions | Cookie Policy