Magento themes and extensions

Insert Static Blocks Into Magento Templates

Posted on September 19th, 2012 | Posted by admin

How insert static blocks into Magento templates?
The should work for any block and template combination

* Insert into magento_template.phtml
echo $this->getLayout()->createBlock('cms/block')->setBlockId('cms_block_name_here')->toHtml() ;

Magento: How to set and get registry?

Posted on September 18th, 2012 | Posted by admin

Registry means registering or creating a new variable which is to be used later on in the project/code. The registry variable acts as a global variable which can be used anywhere.

We register a variable with register() function.
We can unregister the variable with unregister()function.
To fetch the registry variable, we use registry()function.
We can store anything in the registry variable. It can be integer, string, array, etc.

In the example below, I will be showing you how to create, fetch and destroy registry variable. In other words, I mean how to register, fetch and unregister variables in Magento.

Catalog Rules in magento

Posted on September 17th, 2012 | Posted by admin

After discovering how Magento works with categories, I continued to research on Catalog Rules and found them very interesting. Thus I cannot wait any longer to share the useful information with you.

As you may know, Magento has two types of price rules: catalog and shopping cart price rules. While shopping cart price rules are applied in the shopping cart, catalog rules are applied on products before they are added to the cart. They are used when you have a new sales policy for a set of products.

  • Rule model and conditions

Firstly, conditions are the core of a catalog rule model. They help the system determine products that were discounted. Catalog rules use product conditions which are similar to:

CSS In Magento

Posted on September 16th, 2012 | Posted by admin

The first thing that you need to do with Magento is famililarise yourself with the CSS files, as you will be using these an awful lot. There are 7 different files in total, so you need to know what is located where and the things you will need to edit.

Most of the editing is done in the “boxes.css” file. All of the css files are located in“…/skin/frontend/YOUR_THEME/YOUR_THEME/css”. If you have not changed the name of the theme or created a new one then it will be called “default”(“…/skin/frontend/default/default/css”) If you wish to change the colours or settings of any forms, tables, menus, buttons, error messages; then this is the place to be.

Programmatically Add Grouped Product to Cart in Magento

Posted on September 16th, 2012 | Posted by admin

Programmatically Add Grouped Product to Cart in Magento

Adding simple products to cart through custom PHP code is pretty straight forward. You just need to call the ‘$cart->addProduct()’ function with the product_id and quantity as parameters. But if you want to add grouped products to cart through your code, you will need to perform few additional steps. The process is very easy – create an ‘$super_group’ array of the associated products with the specified quantities. Then you need to pass the array to the ‘addProduct()’ function. See the actual code below that makes it work:

//Array for holding the associated products
$super_group = array();

//Id of the grouped product
$parentId = <grouped_product_id>;

//Create an array of associated products
$children = array('<child_id_1>','<child_id_2>','<child_id_3>');

//Quantity of each child product to be addede to cart
$child_qty = 2;