Moving Magento database through phpmyadmin

Magento database uses Innodb as storage engine and uses foreign keys to check the integrity between the tables. So, importing the sql dump will cause an integrity violation and we need to disable the integrity check before the import session.

Before importing the dump file, we need to insert this string at the beginning of the sql file itself:

SET FOREIGN_KEY_CHECKS = 0;

then save the file and eventually gzip it.

We can now proceed to the import process :)

 

Magento module creator version 0.0.9.1

I was looking at some guides about the Magento’s  module creator that is very helpful tool to create a module skeleton. On the developer’s github account, I was able only to download the latest version 0.0.9.2 (4 years old) that creates two modules for the frontend and backend  and, the most important thing, it seems to not work on Magento 1.8.

While googling for a solution, I found the previous version on a forum and I’ve downloaded. It works perfectly and I’ve  pushed it on my github account, so if anyone need it, here is the link: https://github.com/apedicdev/magento-module-creator

Akismet and jquery easing conflict

Recently, I’ve got a problem working on a wordpress website that uses jQuery easing to display posts. Clicking on one post, the first time the post was loaded but it lacks of images and comments, the second time the post was loaded but in a new page without the lighbox effect. So, I’ve activated firebug and I’ve seen that there was  an endless count of errors on the jquery easing function. As the first time the comments were not displayed, I tried to disable the akismet plugin and it works fine! I don’t know if the issue was due because akismet was not configured or because there is really a conflict with jquery library, but if you have a  wordpress template that loads posts in lightbox and they are not displayed, try disable akismet.

 

Special characters into mysql database

I’ve often to store, in mysql databases, text strings containing special chars, especially accented characters we use in italian language. It is very important to manage them correctly otherwise, when you have to render them in html, the output could not to be fine. Moreover, the mysql query could fail if the strings are not correctly escaped.

Here is a short PHP snippet that I use before the INSERT query:

htmlentities(mysql_real_escape_string($string), ENT_QUOTES, "UTF-8");

Using that command, the string is escaped and then the special chars will be converted in html entities, using UTF-8 as charset and will be converted both double and single quotes.

WordPress Contact form 7 with GET input parameters

Contact form 7 is a very powerful wordpress plugin that helps to develop easily web forms using shortcodes. It has also some addons to extend the functionalities. One I’ve found useful is Contact Form 7 Get and Show Parameter from URL plugin. It retrieves Get parameters from the URL and they can be used in the form and in the email sent after form submission.

Use [getparam parameter] to retrieve the GET parameters then use [showparam parameter] in the form body to show the input parameter. Use [parameter] in the email to pass the value after the form submission.