Magento – Form Not Submitting In Backend – Formkey

In Magento back end to properly submit a form, a value called formkey must be submitted with the form. Or else the form will never submit itself. The formkey can be submitted with a hidden field as below – $formKey = Mage::getSingleton(‘core/session’)->getFormKey();

Magento – Load A Product By Any Attribute

While generally we load a product in Magento by its id, it is also possible to load it by any of its attribute. To do that use the following code – $_p = Mage::getModel(‘catalog/product’)->loadByAttribute(‘attr_name’, $attrib); Just replace ‘attr_name’ with the name of the attribute and $attrib with the value and then Magento will fetch matching products.

Change CSS Class With JavaScript

If we need to change the CSS class of a div or any other element with onclick or onmouseover etc. dynamically using JavaScript, you can do so using className. Follow the below example – Click here to see the class change Mouse over to see the class change

Style HR Tag With CSS

There are pages which have a few hr tags thrown here and there. If the page is designed nicely, the hr tags look ugly, if not styled properly. To make them look fine use the following CSS properties. 1. border:none;                                         – Will remove the border2. background-color:#000000;       – Add color as required3. height:1px;                                             – Adjust the… Continue reading Style HR Tag With CSS

Handle Quotes In MySQL Query Using Zend Framework

When a value that needs to be inserted into database, contains a mix of   ‘ and ”  , problem will arise with normal MySQL query. We can handle the situation when using plain PHP with this solution. But if we are using Zend Framework the solution will be – $db = Zend_Db::factory(‘PDO_MYSQL’, $params);$sql =… Continue reading Handle Quotes In MySQL Query Using Zend Framework