Tuesday, May 31, 2011

Sunday, May 15, 2011

magento error and troubleshoot


After sharing the solutions on the magento forum, I thought I would blog it so one day or the other it might be useful to someone.
I would try to post it regularly on these kind of problems
1. Unable to login into admin after installation
If you are using Magento 1.4 then look into the following path
app/code/core/Mage/Core/Model/Session/Abstract/Varien.php
Find the following lines:
  1. // session cookie params  
  2.        $cookieParams = array(  
  3.            'lifetime' => $cookie->getLifetime(),  
  4.            'path'     => $cookie->getPath()/*, 
  5.            'domain'   => $cookie->getConfigDomain(), 
  6.            'secure'   => $cookie->isSecure(), 
  7.            'httponly' => $cookie->getHttponly()*/  
  8.        );  
  9.   
  10.        if (!$cookieParams['httponly']) {  
  11.            unset($cookieParams['httponly']);  
  12.            if (!$cookieParams['secure']) {  
  13.                unset($cookieParams['secure']);  
  14.                if (!$cookieParams['domain']) {  
  15.                    unset($cookieParams['domain']);  
  16.                }  
  17.            }  
  18.        }  
  19.   
  20.        if (isset($cookieParams['domain'])) {  
  21.            $cookieParams['domain'] = $cookie->getDomain();  
  22.        }  
Replace it with the following
  1. // session cookie params  
  2. $cookieParams = array(  
  3. 'lifetime' => $cookie->getLifetime(),  
  4. 'path'     => $cookie->getPath()/*, 
  5. 'domain'   => $cookie->getConfigDomain(), 
  6. 'secure'   => $cookie->isSecure(), 
  7. 'httponly' => $cookie->getHttponly()*/  
  8. );  
  9.   
  10. /*if (!$cookieParams['httponly']) { 
  11. unset($cookieParams['httponly']); 
  12. if (!$cookieParams['secure']) { 
  13. unset($cookieParams['secure']); 
  14. if (!$cookieParams['domain']) { 
  15. unset($cookieParams['domain']); 
  16. } 
  17. } 
  18. } 
  19.  
  20. if (isset($cookieParams['domain'])) { 
  21. $cookieParams['domain'] = $cookie->getDomain(); 
  22. }*/  
You would be able to login into your admin panel. By doing so it would work with your local development server. What we are doing is simply commenting out the code which doesn’t allow localhost or anything that is not a domain.
2. How best to clear cache:
In magento another major problem users face is they don’t know how to clear their cache.
Follow these steps carefully:
1. Backup your cache directory if in case you need it, its located at
var/cache/*
2. Delete all folders inside the var/cache/ folder, don’t delete the cache folder instead delete all folders inside the cache folder.
If you are using mangeto versions prior to 1.4 then you should adapt one more step too.
3. Backup app/etc/use_cache.ser, I mean you can also rename the file to app/etc/use_cache1.ser
4. Delete the app/etc/use_cache.ser file
5. Reload the magento in a new browser and you would be able to clear cache.