Catalog / Magento 2 Cheatsheet
Magento 2 Cheatsheet
A quick reference guide for Magento 2 developers, covering essential commands, configurations, code snippets, and best practices.
Essential CLI Commands
Setup Commands
|
Upgrades Magento modules and database schema. |
|
Compiles dependency injection configurations. |
|
Deploys static view files. |
|
Cleans Magento cache. |
|
Flushes Magento cache storage. |
|
Sets configuration values. |
Cache Management
|
Enables specified cache types. |
|
Disables specified cache types. |
|
Shows the status of Magento cache types. |
Index Management
|
Reindexes specified indexers. |
|
Shows information about indexers. |
|
Resets indexers. |
|
Shows the status of indexers. |
File System
Directory Structure
|
|
|
|
|
|
File Permissions
Set file permissions to
|
For production environments, follow Magento’s official security guidelines for file permissions. |
Code Snippets
Object Manager
Note: Avoid using Object Manager directly in your code. Use dependency injection instead. |
Dependency Injection
|
Events
Example of dispatching an event:
|
Example of listening to an event, in
|
Database Operations
Resource Model
|
InstallSchema
Example of creating a table in
|