Skip to content

Instantly share code, notes, and snippets.

@vijayrami
Last active April 13, 2022 17:48
Show Gist options
  • Save vijayrami/bfe4ce62e4a0af77f200c8f2db7d38d6 to your computer and use it in GitHub Desktop.
Save vijayrami/bfe4ce62e4a0af77f200c8f2db7d38d6 to your computer and use it in GitHub Desktop.
basic Magento2 Comamnd list

https://devdocs.magento.com/guides/v2.3/config-guide/redis/redis-pg-cache.html

install extension

php bin/magento deploy:mode:set developer

mkdir -p app/code/Litespeed/Litemage

mv /path/to/magento2-LiteSpeed_LiteMage-master/* app/code/Litespeed/Litemage/

php bin/magento module:enable Litespeed_Litemage --clear-static-content

php bin/magento setup:upgrade --keep-generated (to update the database schema and data, preserving generated static files.)

php bin/magento cache:clean

php bin/magento setup:di:compile

php bin/magento deploy:mode:set production --skip-compilation

php bin/magento setup:static-content:deploy -f

Enable Module:

  1. Disable the cache under System->Cache Management.

  2. Enter the following in the command line:

php bin/magento module:enable --clear-static-content Component_Name

php bin/magento setup:upgrade

php bin/magento cache:clean
  1. Check under System > Tools > Web Setup Wizard > Module Manager that the component is present.

install extension

composer update vendor/module-name or

composer require vendor/module-name ^x.x.x

===============================================================

==============================================================

Go to the root folder of your Magento project and run the following commands :

rm -rf var/cache var/generation var/di

php bin/magento setup:upgrade

php bin/magento setup:di:compile

php bin/magento cache:clean

chmod 777 -R var/

====================================================

php bin/magento maintenance:disable

===============================================

The below command is for creating a new user but you can also use it to reset the admin password in Magento 2 if the user is already available

php bin/magento admin:user:create --admin-user=admin --admin-password=admin123

==================================================

php bin/magento deploy:mode:show

php bin/magento deploy:mode:set developer

php bin/magento deploy:mode:set production

php bin/magento deploy:mode:set production --skip-compilation

And once the mode is switched you can deploy static content with GB locale.

php bin/magento setup:static-content:deploy en_GB

Magento default locale is en_US so you have to define your language.

==============================================

php bin/magento dev:template-hints:enable

php bin/magento dev:template-hints:disable

php bin/magento cache:clean

php bin/magento cache:flush

=======================================================

php bin/magento app:config:dump write configuration data into config.php file

Update the configuration

php bin/magento app:config:import

enable/disable debug logging (var/log/debug.log)

php bin/magento setup:config:set --enable-debug-logging=true

php bin/magento setup:config:set --enable-debug-logging=false

enable/disable db logging (var/debug/db.log)

php bin/magento dev:query-log:enable

php bin/magento dev:query-log:disable

enable/disable Syslog logging

php bin/magento setup:config:set --enable-syslog-logging=true

php bin/magento setup:config:set --enable-syslog-logging=false

indexer commnads

php bin/magento indexer:info

php bin/magento indexer:status

php bin/magento indexer:reindex

php bin/magento indexer:show-mode

bin/magento indexer:set-mode {realtime|schedule} [indexer]

create db_schema_whitelist.json file with command

php bin/magento setup:db-declaration:generate-whitelist --module-name=Vendor_Modulename

check language list command

php bin/magento info:language:list

Create LESS files

php bin/magento dev:source-theme:deploy

Check the Magento version

php bin/magento --version

http:///magento_version

run test

pho bin/magento dev:tests:run integration

Convert layout XML files

pho bin/magento dev:xml:convert

generate profiles

php bin/magento setup:perf:generate-fixtures setup/performance-toolkit/profiles/ce/small.xml

###taking backup of code,media and database of magento2

php bin/magento setup:backup --code --media --db

Run Magento Cron

php bin/magento cron:run

php bin/magento cron:run --group="custom_crongroup"

Enter the magento cron:run command two or three times. (cron_schedule database table)

The first time you enter the command, it queues jobs; subsequently, the cron jobs are run. You must enter the command at least twice.

To view a list of all consumers:

php bin/magento queue:consumers:list (To view a list of all consumers:)

To start message queue consumers:

php bin/magento queue:consumers:start (To start message queue consumers:)

To retrieve information about dependency injection configuration for a class.

php bin/magento dev:di:info "Magento\Quote\Model\Quote\Item\ToOrderItem"

===============================================================

truncate below tables from M1 before migration:

log_url

log_url_info

log_visitor

log_visitor_info

================================================================

Install composer package by ignoring the platform requirements

When it comes to installing and updating packages you may at times want to ignore the platform requirements. For example, when adding or updating a dev dependency that will never be installed on the production environment. For this we can use the --ignore-platform-reqs flag.

composer update phpunit/phpunit --ignore-platform-reqs

or run composer from different path:

php7.1 /usr/local/bin/composer

php7.2 /usr/local/bin/composer

php7.3 composer

run magento commands from lower version of PHP:

/usr/bin/php7.2 bin/magento cache:clean

============================================================

admin stuck on " It's time to change your password.

php bin/magento config:set admin/security/password_is_forced 0

=================================================================

Add more than one block:

https://magento.stackexchange.com/questions/177812/adding-more-than-one-product-tabs-magento2?rq=1 https://webkul.com/blog/call-phtml-file-cms-page-magento2/

https://magento.stackexchange.com/questions/191613/magento-2-display-custom-attribute-value-under-the-product-name-on-category-pag

https://magento.stackexchange.com/questions/134774/how-to-remove-limiter-from-product-listing-page-in-magento-2

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment