Magento

From Wiki
Jump to navigation Jump to search

Static Content Re-Generate

Before deleting pub/static make a backup of pub/static/.htaccess and restore it again. otherwise your all css and js will show 404 error!

Remove pub/static (keep the .htaccess backed up and copy it again)
Remove var/cache
Remove var/composer_home
Remove var/generation
Remove var/page_cache
Remove var/view_preprocessed
Run php bin/magento setup:static-content:deploy

Product not showing on frontend

php bin/magento indexer:reindex
php bin/magento cache:clean
php bin/magento cache:flush

Admin login not working

1. Clear the admin session table from phpmyadmin. tabke name: admin_user_session

2. Unlock the admin account

php bin/magento admin:user:unlock $user

3. Update Password of the admin user:

SET @salt = MD5(UNIX_TIMESTAMP());
UPDATE $admin_table SET `password` = CONCAT(SHA2(CONCAT(@salt, 'NewP@ssword'), 256), ':', @salt, ':1') WHERE username = '$admin_user';

For Example:
SET @salt = MD5(UNIX_TIMESTAMP());
UPDATE mgsv_admin_user SET `password` = CONCAT(SHA2(CONCAT(@salt, 'Magento@123'), 256), ':', @salt, ':1') WHERE username = 'mageplaza';

Empty Output Of Magento Commands

Open bin/magento in your preferred file editor and add the following line and save:

ini_set('display_errors', 1);  // allow PHP errors reporting

Run the command again and now it will show the exact error. After debugging, remove the above error code.

Allowed memory size of x bytes exhausted

Add "add -d memory_limit=XX" in the command:

Example: php -d memory_limit=4G bin/magento setup:di:compile


Cron for Magento is not running

1. Check if they have cronjob under cPanel >> Cronjobs.
2. If not, add the one like : /usr/bin/php  /home/user/public_html/bin/magento cron:run  | grep -v "Ran jobs by schedule" >>  /home/user/public_html/var/log/magento.cron.log
3. if they had the cronjob already, try to run it via command line
4. You may see memory error like : Fatal error: Allowed memory size of 134217728 bytes exhausted (tried to allocate 9305840 bytes)
5. Check the php path in the cron command and confirm the memory limit set is enough for that version.
6. At last check if the account has any .user.ini, php.ini or .htaccess files which will override the memory_limit