Feb 24, 2012 ·
1 minute read
magento
Encrypting a string in Magneto is really easy and will use the encryption key specified in the local.xml file: <?php $encryptedData = Mage::helper('core')->encrypt("This will be encrypted"); There is one problem that you may encounter that can be a little bit problematic but there is an easy work around. The encryption process will strip out non-printing characters or character it does not recognise. Easiest way to get about this is to
Read On →
Feb 24, 2012 ·
1 minute read
php
If you ever need to create a custom field to save data against a customer in Magento you will probably need to create a custom attribute. Creating the attribute is easy, in your modules install script you do: <?php $installer = $this; $installer->startSetup(); $installer->addAttribute('customer', 'my_custom_attribute', array('type'=>'text')); $installer->endSetup(); Then on the customer object you can update and save it accordingly: <?php $customer = Mage::getModel('customer/customer')->load($customerId); $customer->setMyCustomAttribute("Some custom data that needs to be saved")->save(); echo Mage::getModel('customer/customer')->load($customerId)->getMyCustomAttribute(); // Outputs 'Some custom data that needs to be saved' To make your installer work you need to create a folder in the root of your module sql/mymodule_setup In there create the file mysql4-install-0.1.0.php And put the above installer code (plus any other install related code) in there.
Read On →
Feb 24, 2012 ·
1 minute read
java
Java is a bit more picky about SSL authorities than, say, Chrome or Firefox. Fortunately adding a certificates to Java to accept it as secure is fairly straight forward: sudo keytool -import -keystore /usr/lib/jvm/java-6-sun/jre/lib/security/cacerts -file cert.crt Password: changeit Of course acquiring the certificate file can be a little tricky as it’s entirely dependant on your setup. Also /usr/lib/jvm/java-6-sun/jre/lib/security/cacerts is the default location for the keystore on Ubuntu, this may differ depending on your OS/distribution.
Feb 23, 2012 ·
1 minute read
Cascading Style Sheets
I do a lot front end development with Magento, and one of the biggest time sinks for this is waiting for a page to load when you want to change a line of CSS. Whilst you can use Firebug / Chrome to edit CSS rules on the page, you still need check that the file is saved correctly. As this is Magento, this can take some time due to caching being disabled.
Read On →
Feb 23, 2012 ·
1 minute read
virtualbox
Virtualbox is an amazing tool for testing and developing on various systems. Now it’s even easier as there is a nicely organised repository of clean VirtualBox images you can download and get running with in a matter of minutes. http://virtualboxes.org/ We are going to use them for some Magento performance optimisation testing on various platforms as we perfect our Magento Server Optimisation skills and try to benchmark some new ideas.
Feb 22, 2012 ·
1 minute read
php
One of the features that makes PHP such a powerful language is it’s arrays. They allow for really complex data structures to be stored and worked on really easy. One interesting aspect of them is that they maintain there index if emptied one element at a time. Taken from php.net: http://php.net/manual/en/language.types.array.php <?php // Create a simple array. $array = array(1, 2, 3, 4, 5); print_r($array); // Now delete every item, but leave the array itself intact: foreach ($array as $i => $value) { unset($array[$i]); } print_r($array); // Append an item (note that the new key is 5, instead of 0).
Read On →