While working on some ASP.NET form validation today, I came across a great regex tester / builder called Regex Hero. The main feature is their .NET Regex Tester, a Silverlight app, and while it requires registration (Google, Yahoo, AOL, OpenID, etc.), this gives you the ability save your regular expressions to your personal library on the site. You can also use the site’s public library, but contributions are a little anemic at this point. The app has a few other nice features, including real-time expression matching, a built-in regular expression reference, .NET code generation, and performance benchmarking.
The app is free for basic use, but it will nag you every 5 minutes to buy the paid version. The full version is $20 and comes with the nice addition of Intellisense-like code completion and a desktop version of the app. Future upgrades are free for the full version.
Things you Should Know Before Developing With Magento
—————————————————————-
Now being more experienced with Magento we definitely feel the need to share our findings with the masses. We only wish we knew these things prior to trying to the hack the crap out of magento to make it do what we want.
Turning on Template Path Hints
If you’re new to Magento you will realize that it is quite a hassle to understand the logic behind the file structure and block structure of a magento layout when trying to customize your storefront. There is a very under-publicized built-in magento feature that we’d like to share with you that should help you on your journey. Magento actually has the ability to display hints showing where the different files of your layout is contained so that you can edit it.
To achieve this, Follow these simple steps…
Now when you navigate to your storefront you’ll see a bunch of red boxes displaying the underlying structure of the pages regarding templates and blocks.
Note: This should only be used in a development environment, considering this will make your storefront look hideous with big red blocks everywhere.
—————————————————————-
Never edit core files
Problem: When developing with Magento you will find it necesary to edit core files to achieve certain functionality. However, By editting a core file you are basically blocking yourself into a corner. DON’T DO IT! If you ever wish to upgrade at any point in the future you will not be able to because any changes that you have made in the core files will be overwritten. Never fear, there is a way around this.
Solution: The “local” folder (\app\code\local\) is your saviour. Say you need to edit the “Shipping.php” file located at “\app\code\core\Mage\Shipping\Model\Shipping.php” you can create the same basic directory structure in the local folder and copy and paste the Shipping.php file into the new directory. So, your new “local” Shipping.php file will be located at \app\code\local\Mage\Shipping\Model\Shipping.php. You will be able to safely edit anything and everything within that local file and never have to worry about it being overwritten during an upgrade. This trick works because Magento will look for files in a local directory before looking for a file in the core directory.
Note: The above solution will only overpower files that exist within the \app\code\core\ or \app\code\community\ directories. Also note that any files within your magento theme (\app\design\frontend\default\YOURTHEME\) or (\skin\frontend\default\YOURTHEME\) are not considered core files and you are free to edit them as you please.
These are just to name a few… Follow our blog to read more!
If you’re running Magento on OpenSuse (or any platform for that matter), you can really benefit from turning on http compression, especially to remote areas or from hosts that have limited bandwidth.
There are a lot of references out there on this, but you have to sort of pull it all together on your own for this particular combination.
Verify that mod_deflate has been installed in Apache:
1. Open /etc/sysconfig/apache2.
2. Find the line that starts:
APACHE_MODULES=…
3. Verify that “deflate” is one of the modules listed (may not be in alphabetical order).
Now, enable compression in the virtual host file for your site:
1. Open /etc/apache2/vhosts.d/.conf.
2. Add the following lines inside the tag:
<IfModule mod_deflate.c>
DeflateBufferSize 32768
DeflateCompressionLevel 5
<Location />
SetOutputFilter DEFLATE
BrowserMatch ^Mozilla/4 gzip-only-text/html
BrowserMatch ^Mozilla/4\.0[678] no-gzip
BrowserMatch \bMSIE !no-gzip !gzip-only-text/html
SetEnvIfNoCase Request_URI \.(?:gif|jpe?g|png|tiff)$ no-gzip dont-vary
# Header append Vary User-Agent env=!dont-vary
</Location>
</IfModule>
Now restart Apache using:
sudo /etc/init.d/apache2 restart
and you should be in business!
Validate that compression is working
A great, handy online site that you can use to validate that compression is working is http://www.gidnetwork.com/tools/gzip-test.php.
=============================
“e-commerce done right”
http://www.ifuelinteractive.com
My previous post on adding to the cart with ajax in Magento has generated enough interest – and pointed out enough flaws in my overly complex code – that I’ve decided to put together a simplified version, so here goes:
Step 1: Create the server side script.
My sample script is called “addToCartTest.php” and I put it in a /scripts folder in the root of my Magento installation.
< ?php
include_once '../app/Mage.php';
Mage::app();
try{
// usage /scripts/addToCartTest.php?product_id=838&amp;amp;amp;amp;qty=1
$product_id = '';
// get query string
if (!isset($_GET['product_id'])) { $product_id = ''; } else { $product_id = $_GET['product_id']; }
if (!isset($_GET['qty'])) { $qty = '1'; } else { $qty = $_GET['qty']; }
$product = Mage::getModel('catalog/product')->load($product_id);
$session = Mage::getSingleton('core/session', array('name'=>'frontend'));
$cart = Mage::helper('checkout/cart')->getCart();
$cart->addProduct($product, $qty);
$session->setLastAddedProductId($product->getId());
$session->setCartWasUpdated(true);
$cart->save();
$result = "{'result':'success'}";
echo $result;
} catch (Exception $e) {
$result = "{'result':'error'";
$result .= ", 'message': '".$e->getMessage()."'}";
echo $result;
}
Updated: 10/14/2009
Over the years I’ve collected together a list of the tools I use all the time. I know there are lots of other lists like this out there, but, well, they’re not mine!!
I’m going to try to keep adding to this list on a regular basis as I find new tools, or decide to move on from others.
After using many many commerce packages – and WRITING many many commerce packages from scratch, we’ve standardized on Magento Commerce for all new e-commerce sites. It’s an awesome platform, with huge potential for customization and extension. The list of existing modules (plug-ins basically) is very large and growing all the time. This is the way to put up new e-commerce sites, no question about it!
We’ll be posting lots and lots of Magento information in the weeks and months to come as we continue on our journey with this great tool!