Recent Blogs

  • Why A Travel Company Needs An Attractive Website?

    A website considered a great source of a marketing platform for a travel company. It is a place where you can share your availability and regularity all the time without unusual hindrances. A website should be responsive, user-friendly, and easy to operate. A travel company promotes itself through the best website to put trustworthy content. It may promote visitors and it would be a great platform to place tour packages.

    Why travel agencies needs a attractive website

    12-06-2020

How to use Command Line Interface CLI in Magento?

How to use Command Line Interface CLI in Magento

At times it becomes necessary to access Magento system outside the Magento. It can be done using PHP shell script that bootstraps Magento. There are number of such scripts comes with Magento package to run some functionalities outside Magento. Those functionalities are listed below.

Re-indexing Magento through the command line

You might need to re-index Magento via the command line. This could be for a whole host of reasons, for example, if the indexer is getting timed out or not finishing through the web interface. Magento includes an indexing script and you can find it in the shell folder and have a number of commands at your disposal. Re-indexing shell commands as follows,
1. Checking for the status of all indexes: php indexer.php --status
Output

Magento-root-path\shell>php indexer.php --status
Product Attributes:                     Pending
Product Prices:                         Pending
Catalog URL Rewrites:              Pending
Category Products:                      Pending
Catalog Search Index:                   Pending
Stock Status:                                   Pending
Tag Aggregation Data:               Pending

2. To get all index keys: php indexer.php –info
Output

Magento-root-path\shell>php indexer.php --info
catalog_product_attribute         Product Attributes
catalog_product_price             Product Prices
catalog_url                           Catalog URL Rewrites
catalog_category_product          Category Products
catalogsearch_fulltext                Catalog Search Index
cataloginventory_stock            Stock Status
tag_summary                           Tag Aggregation Data

3. Re-indexing a single index: php indexer.php --reindex [Index Option Code] Output

Magento-root-path\shell>php indexer.php --reindex catalogsearch_fulltext
Catalog Search Index index was rebuilt successfully

4. Re-indexing a multiple indices: php indexer.php --reindex [Index Option Code 1, Index Option Code 2, Index Option Code 3]
Output

Magento-root-path\shell>php indexer.php --reindex catalog_product_attribute,catalog_product_price,catalog_url
Product Attributes index was rebuilt successfully
Product Prices index was rebuilt successfully
Catalog URL Rewrites index was rebuilt successfully

5. Re-index all indices: php indexer.php --reindexall
Output

  
Magento-root-path\shell>php indexer.php --reindexall
Product Attributes index was rebuilt successfully
Product Prices index was rebuilt successfully
Catalog URL Rewrites index was rebuilt successfully
Category Products index was rebuilt successfully
Catalog Search Index index was rebuilt successfully
Stock Status index was rebuilt successfully
Tag Aggregation Data index was rebuilt successfully

Run Magento Compiler through command line

Sometimes it is needed to urgently disable and clear Magento compiler, e.g. after installation or some 3rd party Magento module. Magento always recommended disabling it before any module installation. You can easy to do it in Magento administrator panel, but what if you installed module by mistake, when compiler was active? Most likely your Magento admin panel will be not accessible. Magento ships with a command line script for interacting with the compiler. Fortunately, there is a way to clear and disable Magento compiler using command shell. Compiler shell commands as follows,
1. Compiler helps command: php -f compiler.php help
Output

Magento-root-path\shell>php -f compiler.php help
Usage:  php -f compiler.php -- [options]
  state             Show Compilation State
  compile           Run Compilation Process
  clear             Disable Compiler include path and Remove compiled files
  enable            Enable Compiler include path
  disable           Disable Compiler include path
  help              This help

2. Checking for the status of Compiler: php -f compiler.php state Output

Magento-root-path\shell>php -f compiler.php state
Compiler Status:              Disabled
Compilation State:            Not Compiled
Collected Files Count:        0
Compiled Scopes Count:   0

3. Run Compilation Process: php -f compiler.php compile
Output

Magento-root-path\shell>php -f compiler.php compile
Compilation successfully finished

4. Enable Compiler include path: php -f compiler.php enable
Output

Magento-root-path\shell>php -f compiler.php enable
Compiler include path enabled
5. Disable Compiler include path: php -f compiler.php disable
Output
Magento-root-path\shell>php -f compiler.php disable
Compiler include path disabled

6. Disable include path and Remove compiled files: php -f compiler.php clear
Output

Magento-root-path\shell>php -f compiler.php clear
Compilation successfully cleared

Thanks for reading my article on How to use Command Line Interface CLI in Magento. I hope it was useful.

Leave a Reply

Your email address will not be published. Required fields are marked *