Zoomtutorials
  • Cloud
    • Cloud Hosting
      • AWS
      • Azure
      • GCP
      • Oracle Cloud
      • Alibaba Cloud
      • IBM Cloud
      • DigitalOcean
      • Linode
  • DevOps
    • DevOps Tools
      • Terraform
      • Git
      • GitHub
      • Jenkins
      • Docker
      • Kubernetes
      • Ansible
      • Python
      • Monitoring
    • Azure DevOps
      • Azure Boards
      • Azure Repos
      • Azure Pipelines
      • Azure Test Plans
      • Azure Artifacts
      • Extensions Marketplace
    • AWS DevOps
      • CodeStar
      • CodeCommit
      • CodeBuild
      • CodeDeploy
      • CodePipeline
      • CodeArtifact
  • Programming
    • Application
      • Magento 2
      • Magento
      • WordPress
      • PHP
      • .Net
      • .Net Core
      • NodeJS
      • JAVA
    • Database
      • Microsoft SQL Server
      • MySQL
      • MariaDB
      • Amazon Aurora
      • SQL Proxy
    • Web Server
      • IIS
      • Apache
      • NGINX
      • Tomcat
      • NodeJS
    • Microsoft Dynamics ERP
      • Dynamics 365
        • D365 FnO
        • D365 BC
      • Dynamics AX
      • Dynamics NAV
      • Dynamics GP
      • Dynamics CRM
  • HowTos
    • Linux OS
      • RHEL
      • Ubuntu
      • CentOS
      • Fedora
      • Debian
    • Linux Tips
      • Linux Commands
      • Linux Tricks
      • Linux Cheatsheet
    • Windows OS
      • Server 2019
      • Server 2016
      • Server 2012
      • Server 2008
      • Windows 11
      • Windows 10
      • Windows 8
      • Windows 7
    • Windows Tips
      • Windows Commands
      • Windows Shortcuts
    • Microsoft
      • Office 365
      • Microsoft 365
      • SharePoint
      • MS Dynamics ERP
  • Tools
    • Monitoring
      • New Relic
      • ELK Stack
      • Loggly
      • DataDog
      • Papertrial
      • Graylog
      • UptimeRobot
    • Security
      • Firewall
      • Internet Security
      • Antivirus
    • Backup
      • SQL Backup
      • Iperius Backup
  • Hire Us
  • Courses
  • Submit Tutorials
  • More…
    • …
      • Services
      • News
      • Write For Us
      • Community
      • Donate ❤️
      • Contact Us
Facebook Twitter Instagram
Zoomtutorials
  • Cloud
    • Cloud Hosting
      • AWS
      • Azure
      • GCP
      • Oracle Cloud
      • Alibaba Cloud
      • IBM Cloud
      • DigitalOcean
      • Linode
  • DevOps
    • DevOps Tools
      • Terraform
      • Git
      • GitHub
      • Jenkins
      • Docker
      • Kubernetes
      • Ansible
      • Python
      • Monitoring
    • Azure DevOps
      • Azure Boards
      • Azure Repos
      • Azure Pipelines
      • Azure Test Plans
      • Azure Artifacts
      • Extensions Marketplace
    • AWS DevOps
      • CodeStar
      • CodeCommit
      • CodeBuild
      • CodeDeploy
      • CodePipeline
      • CodeArtifact
  • Programming
    • Application
      • Magento 2
      • Magento
      • WordPress
      • PHP
      • .Net
      • .Net Core
      • NodeJS
      • JAVA
    • Database
      • Microsoft SQL Server
      • MySQL
      • MariaDB
      • Amazon Aurora
      • SQL Proxy
    • Web Server
      • IIS
      • Apache
      • NGINX
      • Tomcat
      • NodeJS
    • Microsoft Dynamics ERP
      • Dynamics 365
        • D365 FnO
        • D365 BC
      • Dynamics AX
      • Dynamics NAV
      • Dynamics GP
      • Dynamics CRM
  • HowTos
    • Linux OS
      • RHEL
      • Ubuntu
      • CentOS
      • Fedora
      • Debian
    • Linux Tips
      • Linux Commands
      • Linux Tricks
      • Linux Cheatsheet
    • Windows OS
      • Server 2019
      • Server 2016
      • Server 2012
      • Server 2008
      • Windows 11
      • Windows 10
      • Windows 8
      • Windows 7
    • Windows Tips
      • Windows Commands
      • Windows Shortcuts
    • Microsoft
      • Office 365
      • Microsoft 365
      • SharePoint
      • MS Dynamics ERP
  • Tools
    • Monitoring
      • New Relic
      • ELK Stack
      • Loggly
      • DataDog
      • Papertrial
      • Graylog
      • UptimeRobot
    • Security
      • Firewall
      • Internet Security
      • Antivirus
    • Backup
      • SQL Backup
      • Iperius Backup
  • Hire Us
  • Courses
  • Submit Tutorials
  • More…
    • …
      • Services
      • News
      • Write For Us
      • Community
      • Donate ❤️
      • Contact Us
Facebook Twitter Instagram YouTube LinkedIn
Zoomtutorials
Magento 2

Magento 2 Commands and the Use Cases

ZT Senior EditorBy ZT Senior EditorAugust 18, 2021Updated:December 18, 2022No Comments3 Mins Read
Facebook Twitter Pinterest LinkedIn Tumblr Email
Share
Facebook Twitter LinkedIn Pinterest Email

We as System Admin often see many Magento developers running the Magento commands every time they change something like css, js or HTML.

Here, I will discuss which Magento changes require which commands to reflect changes on the frontend or backend of Magento 2.

A. php bin/magento cache:flush  (or php bin/magento c:f)

php bin/magento cache:flush

or

php bin/magento c:f

You need to run this command, If you made changes in admin configuration, layout xml, ui component, phtml, … file or overwrite html, css, js in frontend theme.

Here is the list of caches in Magento 2

  1. Configuration: After adapting configuration files, it is necessary to flush them including configuration and store specific settings
  2. Layouts: After adapting layout files, it is necessary to flush them including the compiled page layout from all components
  3. Blocks HTML output: After adapting the view layers, it is necessary to flush them including page fragments per block
  4. Collections Data: By Magento, it can flush automatically database queries. However, Custom modules may write entries which make Magento can not clean by itself, in case, Magento can not clean so we need to clean the cache
  5. Reflection Data: API interfaces reflection data will be flushed
    Database DDL operations: it can be flush automatically by Magento, but 3rd party can plus more data, after making custom changes to the database schema, which can clean the cache
  6. EAV types and attributes: The metadata regarding the entity attributes into the cache, in general, it should not flush the cache
  7. Integrations Configuration: Caches the compiled integrations on your store. Clean after adding new or changing existing integrations
  8. Integrations API Configuration: Compiled integration APIs configuration of the Store’s Integrations
  9. Page Cache: This cache links the HTML pages so it is necessary to clean this type of cache regularly
  10. Translations: After merging translations from all modules, the merger cache will be cleaned
  11. Web Services Configuration: Caching the Web API Structure

[the_ad_placement id=”after-content”]

B. php bin/magento setup:upgrade (or php bin/magento s:up)

php bin/magento setup:upgrade

or

php bin/magento s:up

You should run this command only on following senarios

  1. When you made changes in the Setup script(InstallData, InstallSchema,
    UpgradeData, UpgradeSchem)
  2. When you install a new module
  3. When you change setup_version in module.xml
  4. After upgrade Magento version

C. php bin/magento setup:di:compile (or php bin/magento s:d:c)

php bin/magento setup:di:compile

or

php bin/magento s:d:c

If you made changes like add new dependency in __construct(), changes in di.xml, Add new controller…

If you are in developer mode you can simply delete changed files from var/generation folder for Magento 2.2.x version and /generated folder for Magento 2.3.x and above.

[the_ad_placement id=”after-content”]

D. php bin/magento setup:static-content:deploy (or php bin/magento s:s:d)

php bin/magento setup:static-content:deploy

or

php bin/magento s:s:d

You need to run this command only when you made changes in HTML, CSS, JS…

If you are in developer mode and enabled symlinks in system you need not run this command. If disabled symlinks, need to delete particular changed files from pub/static folder or run the command.

D. php bin/magento indexer:reindex (or php bin/magento i:rein)

php bin/magento indexer:reindex

or

php bin/magento i:rein

Sometimes not all indexers are reindexed using admin reindex even if time & date is showing as updated in magento admin. In that scenario, to double check the reindex process we should use the SSH/CLI reindex method below.

Reindex all Magento 2 indexers:

php bin/magento indexer:reindex

Check the status of the indexers:

php bin/magento indexer:status

Show the list of the indexers:

php bin/magento indexer:info

Reset the index which is in “Reindex required” state:

php bin/magento indexer:reset [index_name]

Reindex each indexer that has status “Reindex required”:

php bin/magento indexer:reindex [index_name]

[the_ad_placement id=”after-content”]

magento 2 magento 2 commands
Share. Facebook Twitter Pinterest LinkedIn Tumblr Email
Avatar photo
ZT Senior Editor
  • Website

The editor is the founder and chief editor of ZoomTutorials Blog, a leading tutorials and technology blogging site specializing in DevOps, SysAdmin and Cloud Technologies to help IT professionals in their day to day work. He is a Senior Cloud and DevOps Solutions Engineer at a leading eCommerce development Company and has more than 11+ years of Cloud, DevOps and SysAdmin experience working with Fortune 500 companies to solve their most important IT backbones. He lives in Hyderabad with his wife, a son and a daughter.

Related Posts

List of Useful Magento 2 Commands

August 18, 2021

Magento Community read/write splitting with Database Proxy

July 30, 2021

Leave A Reply Cancel Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.

Buy Me a Coffee Plz...

Get our latest tutorials
Recent Posts
  • Install Latest Git 2.x on CentOS/RHEL
  • How to Use the slmgr Command in Windows
  • How To Extend Windows Server Evaluation after Trial Period Expiry
  • List of Useful Magento 2 Commands
  • Magento 2 Commands and the Use Cases
  • MySQL and MariaDB Performance Tuning and Optimization
  • Microsoft Dynamics AX End of Support/Life
  • Magento Community read/write splitting with Database Proxy
  • Git Commands for developers and sysadmins
  • Install the git credential-oskeychain
December 2022
M T W T F S S
 1234
567891011
12131415161718
19202122232425
262728293031  
« Aug    
Archives
Facebook Twitter Instagram YouTube LinkedIn
  • Donation ❤️
  • About
  • Services
  • Submit Tutorials
  • Contact Us
  • Privacy Policy
  • Terms of Use
Copyright © 2023 by ZT Consulting. Designed with ❤️ by CloudSols.com. Hosting Partner Contabo.com. SSL Partner SSL.com. Monitoring Partner UptimeRobot.com

Type above and press Enter to search. Press Esc to cancel.