Magento Themes and Magento Extensions

Magento Product Collections

Posted on December 14th, 2012 | Posted by admin

Using product collections can be very beneficial to Magento developers. In order to understand  Magento Product Collections, you should have an understanding of what a Collection is, in addition to having an understanding of Magento Models.

In short, a Magento Model is similar to an object in the sense that it contains both data and methods. A Magento Collection is a Model type that contains other models. So when we use the terminology “product collection”, we’re basically talking about all of the products in any given situation.

To retrieve all the products of a particular category, we simply open the category Model and load the product collection of that category. It looks something like this:

Hide categories that have no products magento

Posted on December 13th, 2012 | Posted by admin

I have many sites that use the same root category of the Main Site. Each product that is added is added to the site it was added to (wow.) and also the Main Site. However, I would like categories on a per site basis to only appear if there are products on that site.

If I have:


But Site1 only has products in Category1 and Category2, whereas Site2 and Site3 have products in Category2 and Category3; I only want Category1/2 to appear on Site1 and only Category2/3 to only appear on Site2 and Site3.


Posted on December 12th, 2012 | Posted by admin

By looking at Mage_Core_Model_Session_Abstract class in Magento, you can easily set, retrieve, and unset session variables. So if you’re planning to code related in session, use the built in code of magento instead of hardcoding it. Here are some examples:

1. To set Magento Session

$yourSessionValue = 'session Value';

2. To retrieve Session Variables


How to create a custom router in Magento?

Posted on December 11th, 2012 | Posted by admin

How to create a custom router in Magento?

If you want to create a router for your own modules, perform the following steps.

1. open /app/etc/local.xml
2. Insert the following source code between config tag

01 <frontend>
02 <routers>
03 <$name>
04 <use>standard</use>
05 <args>
06 <module>$module_name</module>
07 <frontName>$router</frontName>
08 </args>
09 </$name>
10 </routers>
12 </frontend>

$name = name of your router.
$module_name = name of your module where your router redirects. For example, Moon_Products.
$router = router name.

Magento – Display the SKU on a Product Page

Posted on December 10th, 2012 | Posted by admin

Magento’s default theme doesn’t display the SKU on the product page. This is a pretty easy modification to get this working properly.

In whichever theme you’re using, in the file template/catalog/product/view.phtml, add the line:

<?php echo $this->htmlEscape($_product->getSku()) ?>

Here’s a few lines of my view.phtml to give you some context:

Page 4 of 6« First...«23456»