Archive for the 'Tips' Category

Magento 1.4 and TBT Enhanced Grid 1.2

If you have just upgraded to Magento 1.4.0.1 and installed the latest TBT enhanced grid version 1.2 and you are encountering an error regarding the PDO::quote expecting a String instead of an object, here is the solution:

1) Open up app\code\community\TBT\Enhancedgrid\Block\Catalog\Product\Grid.php

2) Goto line 171 and find
private function loadColumnOptions($attr_code) {
$attr = Mage::getModel(’eav/entity_attribute’)->loadByCode(’catalog_product’, $attr_code);
if(sizeof($attr->getData()) > 0) {
if($attr->getFrontendInput() == ’select’) {
$values = Mage::getResourceModel(’eav/entity_attribute_option_collection’)
->setAttributeFilter($attr->getId())
->setStoreFilter($this->_getStore()->getId(), false)

the bold code is what you need to add because the store filter takes the store ID instead of the store object. What happens on the backend is Magento basically takes the value and makes it part of an SQL statement so an object doesn’t really make sense.

Hope this helps anyone stuck with this issue.

How to show error description in Magento 1.4

Simply go to your magento installation folder, locate the errors folder and you will find local.xml.sample, simply duplicate the file and rename it local.xml

Virtualmin MySQL Backup using strftime

If you are trying to make MySQL backups in Virtualmin that create individual time-based folders like

12-11-2009
13-11-2009

You can turn on strftime substitution in the module config for MySQL in Webmin. This is off by default.

Here is the screen shot:

Capture

Cheers and happy new year to everyone :)

iPhone and Linksys WRT54G2

If you are using iPhone to connect to the Linksys router WRT54G2 on WPA2 Personal. Make sure that the encryption scheme is TKIP+AES and not AES alone. Otherwise the iPhone will not connect. Incidentally other machines (notebooks) on the network has to reconnect to the router as well upon the new security settings.

PHP Session lost after header redirect

I was just working on some PHP and encountered a problem where my session was lost after doing a header redirect. After googling and doing some read up, I realised that the problem lies with using simplexml with the session variables:

For example:
$name = $simplexml -> table[0] -> name
$_SESSION["name"] = $name;

if you attempt to do a header redirect thereafter: header(”anotherpage.php”); , and try to access the session variable in anotherpage.php like

echo $_SESSION["name"];

Then an error might occur which says “Warning: session_start() [function.session-start]: Node no longer exists in …”

The solution to this problem is simple, simply cast the $name above to (string)$name so it looks like:

$name = $simplexml -> table[0] -> name
$_SESSION["name"] = (string)$name;

Virtualmin on EC2 Mailman cannot be created issue

If you are getting the following error:

Failed to create virtual server : Mailman cannot be enabled unless the administration list mailman has been created.This can be done in the Mailman plugin module.

I had just came across a solution that I have tried and verified to be working from tidiar on the Amazon Web Services Developer Community. The link to the thread is http://developer.amazonwebservices.com/connect/entry.jspa?externalID=767

Click on the Network Configuration link

Click on the Network Configuration link

Click on the Hostname and DNS Client

Click on the Hostname and DNS Client

Set the Hostname field to your EC2 instance external address

Set the Hostname field to your EC2 instance external address

Thereafter just head to Virtualmin Mailman Mailing Lists in webmin, if mailman does not exist, you will find a block that looks like this:

This block will show if the default mailman is not created

This block will show if the default mailman is not created

Fill in an administration username and password. You can leave the Associate with Domain to

Hit “Create” and you are done.

You should see the following box appear on top now:

After default mailman has been created

After default mailman has been created

You can now enable mailman mailing lists when you create your virtual websites under virtualmin and you should not get the error anymore.

Again credits to tidiar on AWS forums for sharing the solution.

MySQL prompt Display all possibilities when running stored procedures

If you keep getting the Display all <insert number> possibiilities prompt when you are pasting queries into your mysql shell, it will cause your queries to fail. This is due to the use of the tab character that triggers the behaviour. To resolve this, convert the tab characters in your statement to spaces.

Most SQL management software like EMS allows you to use spaces instead of tabs. They usually fall under the options.

MySQL Error/Warning: Too Many Connections

This post is to help server administrators who are managing MySQL servers. If you run into users complaining about error regarding too many connections to MySQL, do check the script that runs and make sure that connections are closed.

For example if you open a connection in php using:

$mysqli = new MySQLI(’localhost’,'root’,'password’,'dBName’);

At the end of the script, do remember to close the connection by calling:

mysqli_close($mysqli);

To verify that things are working, SSH into your system,

1) go into MySQL command line by typing something like mysqld -u root -p
2) type in “show processlist;
3) take note of the processes already running
4) Run the php (or .net or whichever script)
5) type in “show processlist;” again a while after the script has finished executing
6) If you see new processes being in Sleep status then the script is not closing the connections properly (unless this is a deliberate action by the developer to re-use a connection, but this usually should not happen)
7) You can manually kill the process by typing “kill <process id>;” (You can see the process id in the process list table

So if the script is not closing connections, the script should be checked to ensure that they are closed and run through the test above again. This will assist in the server’s performance as well.

Note: The default max_connections, which govern the maximum number of connections to the MySQL server instance is 100, you can increase this, but it is not a good solution compared to the above which addresses the root of the issue. MySQL has a suggestion that dynamically increases the max_connections which works as well but it has to be dependent on the scenario you are facing.

EMS SQL Manager Lite

I had been working with this wonderful piece of software and had no problems with it until today when I realise that the software maintains a consistent connection to MySQL server until you hit the commit transactions button. This means any queries from somewhere else like PHP will get hung up and timeout, so if you are wondering why things are not moving, do check this piece out.

Godaddy servers block port 25 outgoing

I had just realised that Godaddy servers block port 25 outgoing even on their private dedicated servers in order to reduce spam. While I don’t agree with this action, there really isn’t much I can do about it, but one thing im pretty sure is that I will move everything off their servers as early as I can. For people looking for a workaround, you can use k2smtpout-v01.prod.mesa1.secureserver.net as a smtp smarthost for now.