Magento Themes and Magento Extensions

Magento – Nested ifconfig for better Layouts

Share
Posted on February 27th, 2013 | Posted by admin

By default, Magento allows you to use ifconfig in the following way:

10 <action method="addItem" ifconfig="path/to/config/status/enabled"><type>skin_js</type><name>js/script_one.js</name></action>

the javascript js/script_one.js will be included if path/to/config/status/enabled is true.
Unfortunately, Magento does not allow you to use the “else” block for ifconfig.

for example:
Let’s say, you want to implement the following logic:
if path/to/config/status/enabled is true
then
include the javacript js/script_one.js
else
include the javacript js/script_two.js

An Overview of Magento’s Get and Set Methods

Share
Posted on February 26th, 2013 | Posted by admin

Magento handles its get and set methods in a way that if you do not understand how it works it can be confusing to you. In the beginning of this article you have to take a leap of faith and believe in magic.
In Magento you can take nearly any model and get all the information about it with a simple function call. See the example below:

$product = Mage::getModel('catalog/product')->load(1500);
print_r($product->debug());

This code will return an array of all the basic information about the product. For this example lets say that it only returned two elements to the array “name” and “meta_description”.

Now in order to get this information you will have to take the information and camel case it to create the function. So to get the information you would write the following:

echo $product->getName();
echo $product->getMetaDescription();

Do you see how the Meta Description function was formatted? The first letter of the words are capitalized (or camelized) to create the function. So lets say you had an attribute called this_really_important_long_attribute you would call $product->getThisReallyImportantLongAttribute()

Now that you understand that, in order to set the attributes value, you simply replace “get” with “set” and pass the variable as a parameter of the function. So to set the name you would make the following function call:

$product->setName($new_name);

Ok remember when I said that you had to believe in magic? That is because if you look at the Product model, you will not find these functions defined anywhere. In fact if you are hardcore you can follow the class all the way to the top and you will not find these functions defined.

Ok now that you believe in magic, let’s take the curtain away and show you how Magneto accomplishes this. Nearly every class in Magento extends from the Varien Object (which is located in the /lib/Varien/Object.php file). You will see there is a getData() and setData() functions. These look like they could do the actual setting and getting but this is not the magic we are looking for.

Farther down in the file you are going to find the __call() function. This is the magic. This magic here is actually from PHP. The __call() function gets called anytime you call a function on a class that does not exist. The __call() function takes two parameters. The first one is the name of function that was called, the second one is the data that was passed to the function.

Magento Pre Launch Checklist

Share
Posted on February 25th, 2013 | Posted by admin

When all the design work is completed, and the store is fully stocked with products, it’s time to start thinking about going live. It can be intimidating, especially if you haven’t done it before. Hopefully our Magento Launch Checklist will take some of the stress out of going live…

Magento Launch Checklist

  1. Favicon
  2. Place a favicon image in your theme’s folder skin/frontend/default/your-theme/favicon.ico

  3. HTML Head
  4. Change the title and set the meta description and keywords, these are important for SEO.
    System → Configuration →General → Design → HTML Head.

  5. Placeholder Images
  6. Create placeholder images for your site and place them in: catalog/products/placeholder/image.jpg, catalog/products/
    placeholder/small_image.jpg and catalog/products/placeholder/thumbnail.jpg. Alternatively they
    can be uploaded in admin: System → Configuration → Catalog → Catalog → Product Image Placeholders.

MAGENTO WITH VARNISH

Share
Posted on February 24th, 2013 | Posted by admin

IS VARNISH RIGHT FOR YOU?

Varnish isn’t the be-all and end-all of Magento performance. Its great to offset load from bots & window-shoppers – but it shouldn’t be your first port of call to actually making your store faster.

In fact, implementing Varnish should be the last performance modification to your store. Only drop it in once you are seeing the page load times Magento is capable of delivering without it (Eg. <600ms page load times).

YOUR STORE STILL NEEDS TO BE FAST

As Varnish still requires at least a single page load to prime the cache, it means your un-cached performance still needs to be very good. A vast majority of unique URLs (layered navigation hits, search queries etc.) will never really end up being served from Varnish unless either:

Magento Zip+4 Tax Calculation During Checkout – Solution Restrict Length to 5 Digits

Share
Posted on February 23rd, 2013 | Posted by admin

Problem
There is a bug in Magento that prevents Zip+4 tax codes from accurately being calculated. If a customer enters their zip code during Magento checkout in the Zip+4 format (XXXXX-XXXX) or makes a typo during entry, i.e. includes an extra or non-digit character, any applicable taxes are not calculated by Magento. This causes headaches for orders where tax should have been collected: following up with customers, running additional charges, and keeping track of these manual tax collections is an inconvenience for business owners and customers alike.

Since the solution to this problem is not well-documented by the Magento community, we have posted it below for others to refer to. Plus note that the instructions are for Magento 1.7.x (see the bottom of the post for info about applying this fix in Magento 1.4.x):

Page 1 of 3123»