Skip to content

Instantly share code, notes, and snippets.

@hien
Forked from muhammad-owais-javed/My_Magento_Sheet.sh
Created November 23, 2021 07:59
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save hien/795f7ab7e25df1bf77b5f5b106cc9173 to your computer and use it in GitHub Desktop.
Save hien/795f7ab7e25df1bf77b5f5b106cc9173 to your computer and use it in GitHub Desktop.
#Magento Sheet:
#For search and replace in database file of magento
sed -i -e s'#DEFINER=`magento`@`%`#DEFINER=`cwdb`@`%`#'g file.sql
#Difference between Magento 1 and 2
env.php Magento 2
local.xml for Magento 1
"Magento 2.x"
#Cache Clearning
php bin/magento cache:clean
php bin/magento cache:flush
#For Indexing
php bin/magento indexer:reindex
#Static Content Deploying
php bin/magento setup:static-content:deploy
php bin/magento setup:static-content:deploy -f
#For Creating Magento New User:
bin/magento admin:user:create --admin-user="cloudways" --admin-password="cloudways1" --admin-email="abc@xyz.com" --admin-firstname="cloudways" --admin-lastname="cloudways"
#For running magento cron
bin/magento cron:run
bin/magento cron:run --group index
bin/magento cron:run --group default
#For disabling Captcha
php bin/magento config:set admin/captcha/enable 0
#For disabling captcha through MySQL query
Update core_config_data set value=0 WHERE path LIKE '%admin/captcha/enable%'
#For Unlocking Admin User
php bin/magento admin:user:unlock admin
#For enabling/disablng maintenance mode
php bin/magento maintenance:disable/enable
(Magneto detects Maintenance mode through var/.maintenance.flag)
#Add this line in index.php file and it will show real ip's
$_SERVER['REMOTE_ADDR'] = $_SERVER['HTTP_X_REAL_IP'];
#For changing php mimetype
php_value[default_mimetype] = application/json
#Magento configuration file
"Configuration must need to be check after migration"
main env.php
#Restting Passowrd from MySQL
UPDATE admin_user SET password = CONCAT(SHA2('xxxxxxxxNewPassword', 256), ':xxxxxxxx:1') WHERE username = 'admin';
"(The xxxxxxx character sequence is a cryptographic salt, it is saved in app\etc\env.php file)"
<?php
return array (
...
'crypt' =>
array (
'key' => '525701df74e6cba74d5e9a1bb3d935ad', //cryptographic salt
),
#For resetting permissions of Magento 2
find . -type d -print0 | xargs -0 chmod 0775
find . -type f -print0 | xargs -0 chmod 0664
find ./var -type d -exec chmod 777 {} \;
chmod -R 777 var/
find ./pub/media -type d -exec chmod 777 {} \;
find ./pub/static -type d -exec chmod 777 {} \;
chmod -R 777 pub/
chmod 777 ./app/etc
chmod 644 ./app/etc/*.xml
chmod u+x bin/magento
#CORS Header Rule for Apache
Header set Access-Control-Allow-Headers "Origin, X-Requested-With, Content-Type, Accept"
Header add Access-Control-Allow-Origin "*"
#Or
<FilesMatch "\.(ttf|json|html|otf|eot|woff|woff2)$">
<IfModule mod_headers.c>
Header set Access-Control-Allow-Headers "Origin, X-Requested-With, Content-Type, Accept"
Header add Access-Control-Allow-Origin "*"
</IfModule>
</FilesMatch>
#or
<IfModule mod_rewrite.c>
Header add Access-Control-Allow-Origin: "*"
Header add Access-Control-Allow-Methods: "GET,POST,OPTIONS,DELETE,PUT"
Header add Access-Control-Allow-Headers: "Content-Type"
RewriteEngine on
RewriteBase /
</IfModule>
(In case if error is arising from "pub/static", add rule in .htaccess file of directory "pub")
"Magento 1.x"
#Cache Clearning
php -r 'require "app/Mage.php"; Mage::app()->getCacheInstance()->flush();'
#For Indexing
php shell/indexer.php --status
php shell/indexer.php --reindexall
#Configuration checking after Magento migration
main local.xml
#Restting Passowrd from MySQL
UPDATE `admin_user` SET `password` = MD5('mypassword') WHERE `username` = 'admin';
#Debugging for Error
"In case of Following Error"
Call to undefined function xdebug_disable()
Run this:
composer remove magento/magento2-functional-testing-framework
In case of too much load over server from running crons, increase interval time of cron
#For the installation of mailchimp through composer.
composer require mailchimp/mc-magento2
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment