Sunday, October 6, 2013

Magento Mcrypt Extension Issue

Last week When I was making one of magento project live I had to shift entire code to production server. Code was running fine except a small issue.
 When I  login on checkout page, after adding items in my cart, it sends me back to cart url with a blank page. Looking at apache logs revealed -
 Call to undefined function mcrypt_module_open() in /var/www/html/domain.com/lib/Varien/Crypt/Mcrypt.php on line 63, referer: http://domain.com/checkout/onepage/index/

Solution -
How to install php mcrypt extension. 
Couldn't find any pre-built packages.

1 .Download Following RPM Packages -
# wget http://dl.fedoraproject.org/pub/epel/6/x86_64/php-mcrypt-5.3.3-1.el6.x86_64.rpm
# wget http://dl.fedoraproject.org/pub/epel/6/x86_64/libmcrypt-2.5.8-9.el6.x86_64.rpm
 
2. Install - 
yum localinstall php-mcrypt-5.3.3-1.el6.x86_64.rpm libmcrypt-2.5.8-9.el6.x86_64.rpm 

Ref -
http://injustfiveminutes.wordpress.com/2012/11/23/install-php-mcrypt-extension-on-rhel-6/


Friday, October 4, 2013

Magento Reset Admin Panel Password

Whenever I try to set up any third party magento code base I keep coming across this issue. Why not reset the password instead of calling the client/vendor to ask for the admin credentials.
We just need to know how magento encrypts the password and stores in db.



take a note it is resetting the password not hacking the password :)
Steps -
1.Choose any two characters eg. XY.
2.Generate MD5 of two characters and your password e.g MD5('XYmypaswd').You can generate MD5 using query SELECT MD5('XYmypaswd');
3.copy this md5,append your two characters at the end of the md5 string followed by ":".so  your string would be MD5 string:XY.
4.Update the row in the database of admin user.

Happy Coding :)

Magento page.xml changes not getting reflected

Recently I was trying to include a small JS snippet in footer. I created another block for this and tried to put in page.xml.



inside footer block I added my custom intercom block -
 <block type="page/html_footer" name="footer" as="footer" template="page/html/footer.phtml">
<block type="page/html_intercom" name="intercom" as="intercom"  template="page/html/intercom.phtml"  />
....
...
</block>

But the changes didn't reflect on frontend. Ohhh did I clean cache ?  Yes I did , twice thrice still no changes on frontend. After struggling for couple of hours I came to know that teh page.xml file was not even getting used. Magento theme (dresscode theme) has created another file local.xml adjacent to page.xml.
I had to do my changes in local.xml file

<default>
  <layout>
....
...

     <reference name="footer">
            <block type="core/template" name="intercom" as="intercom" template="page/html/intercom.phtml"/>
      </reference>

...
....
   </layout>
  </default>

Some times Magento themes create local.xml  in app\design\frontend\default\theme-name\layout\
and uses it in place of page.xml.
Beware of this :)

Mysql Physical Backup

Ever looked in Mysql installation directory ? I recently did.(E:\wamp\bin\mysql\mysql5.5.24\)
found various strange files which can be used as Mysql DB physical backup if you dont have time to run the mysql server and then run mysql dump for all databases.



So what files are of our interest ?
 Base folder-> E:\wamp\bin\mysql\mysql5.5.24\
1. Lets say you have database name test. You can find a directory named test under data folder. In test you can find .FRM, .MYD , .MYI, .TRG, .TRN files for most of the tables. Take backup of all of these files.
2. You will also find ib_logfile0, ib_logfile1, ibdata1 in base folder. For few tables data is stored in these files as well.

Take above mentioned file backup and put in new mysql installation directory and you are good to go.
As written. here -
http://kedar.nitty-witty.com/blog/mysql-related-file-types-and-basic-information

.frm is for table definition
.myd is for table data
.myi is for table indices
.trg, .trn for trigger definitions

Happy backing up :)