PHP Tutorial – Part 4 – How to Use Loops and Arrays In PHP
May 2, 2010 by technology
Filed under PHP tutorials
Introduction
In the last parts of this tutorial I have showed you how to deal with text and variables in PHP and how you can use IF statements to compare them and to make decisions. In this part I am going to show you how to use another important part of PHP, loops.
The WHILE Loop
The WHILE loop is one of the most useful commands in PHP. It is also quite easy to set up and use. A WHILE loop will, as the name suggests, execute a piece of code until a certain condition is met.
Repeating A Set Number Of Times
If you have a piece of code which you want to repeat several times without retyping it, you can use a while loop. For instance if you wanted to print out the words “Hello World” 5 times you could use the following code:
$times = 5;
$x = 0;
while ($x < $times) {
echo "Hello World";
++$x;
}
I will now explain this code. The first two lines are just setting the variables. The $times variable holds the number of times you want to repeat the code. The $x variable is the one which will count the number of times the code has been executed. After these is the WHILE line. This tells the computer to repeat the code while $i is less than $times (or to repeat it until $i is equal to $times). This is followed by the code to be executed which is enclosed in { }.
After the echo line which prints out the text, there is another very important line:
++$x;
What this does is exactly the same as writing:
$x = $x + 1;
It adds one to the value of $x. This code is then repeated (as $x now equals 1). It continues being repeated until $x equals 5 (the value of times) when the computer will then move on to the next part of the code.
Using $x
The variable counting the number of repeats ($x in the above example) can be used for much more than just counting. For example if you wanted to create a web page with all the numbers from 1 to 1000 on it, you could either type out every single one or you could use the following code:
$number = 1000;
$current = 0;
while ($current < $number) {
++$current;
echo "$current
“;
}
There are a few things to notice about this code. Firstly, you will notice that I have placed the ++$current; before the echo statement. This is because, if I didn’t do this it would start printing numbers from 0, which is not what we want. The ++$current; line can be placed anywhere in your WHILE loop, it does not matter. It can, of course, add, subtract, multiply, divide or do anthing else to the number as well.
The other reason for this is that, if the ++$current; line was after the echo line, the loop would also stop when the number showed 999 because it would check $current which would equal 1000 (set in the last loop) and would stop, even though 1000 had not yet been printed.
Arrays
Arrays are common to many programing languages. They are special variables which can hold more than one value, each stored in its own numbered ‘space’ in the array. Arrays are extremely useful, especially when using WHILE loops.
Setting Up An Array
Setting up an array is slightly different to setting up a normal variable. In this example I will set up an array with 5 names in it:
$names[0] = ‘John’;
$names[1] = ‘Paul’;
$names[2] = ‘Steven’;
$names[3] = ‘George’;
$names[4] = ‘David’;
As you can see, the parts of an array are all numbered, starting from 0. To add a value to an array you must specify the location in the array by putting a number in [ ].
Reading From An Array
Reading from an array is just the same as putting information in. All you have to do is to refer to the array and the number of the piece of data in the array. So if I wanted to print out the third name I could use the code:
n
echo “The third name is $names[2]“;
Which would output:
The third name is Steven
Using Arrays And Loops
One of the best uses of a loop is to output the information in an array. For instance if I wanted to print out the following list of names:
Name 1 is John
Name 2 is Paul
Name 3 is Steven
Name 4 is George
Name 5 is David
I could use the following code:
$number = 5;
$x = 0;
while ($x < $number) {
$namenumber = $x + 1;
echo "Name $namenumber is $names[$x]
“;
++$x;
}
As you can see, I can use the variable $x from my loop to print out the names in the array. You may have noticed I am also using the variable $namenumber which is always 1 greater than $x. This is because the array numbering starts from 0, so to number the names correctly in the output I must add one to the actual value.
PHP Tutorial – Part 3 – How to Use IF- Else Statements in PHP
May 2, 2010 by technology
Filed under PHP tutorials
Introduction
Over the past two parts I have shown you the basics of text in PHP and how to store it as variables. In this part of the tutorial I will show you how to use IF statements to make decisions in your scripts.
The Basics Of IF
If statements are used to compare two values and carry out different actions based on the results of the test. If statements take the form IF, THEN, ELSE. Basically the IF part checks for a condition. If it is true, the then statement is executed. If not, the else statement is executed.
IF Strucure
The structure of an IF statement is as follows:
IF (something == something else)
{
THEN Statement
} else {
ELSE Statement
}
Variables
The most common use of an IF statement is to compare a variable to another piece of text, a number, or another variable. For example:
if ($username == “webmaster”)
which would compare the contents of the variable to the text string. The THEN section of code will only be executed if the variable is exactly the same as the contents of the quotation marks so if the variable contained ‘Webmaster’ or ‘WEBMASTER’ it will be false.
Constructing The THEN Statment
To add to your script, you can now add a THEN statement:
if ($username == “webmaster”) {
echo “Please enter your password below”;
}
This will only display this text if the username is webmaster. If not, nothing will be displayed. You can actually leave an IF statement like this, as there is no actual requirement to have an ELSE part. This is especially useful if you are using multiple IF statements.
Constructing The ELSE Statement
Adding The ELSE statement is as easy as the THEN statement. Just add some extra code:
if ($username == “webmaster”) {
echo “Please enter your password below”;
} else {
echo “We are sorry but you are not a recognised user”;
}
Of course, you are not limited to just one line of code. You can add any PHP commands in between the curly brackets. You can even include other IF statments (nested statements).
Other Comparisons
There are other ways you can use your IF statement to compare values. Firstly, you can compare two different variables to see if their values match e.g.
if ($enteredpass == $password)
You can also use the standard comparision symbols to check to see if one variable is greater than or less than another:
if ($age $finished)
You can also check for multiple tests in one IF statement. For instance, if you have a form and you want to check if any of the fields were left blank you could use:
if ($name == “” || $email == “” || $password == “”) {
echo “Please fill in all the fields”;
}
PHP Tutorial Part 2 – Displaying Information & Variables
May 2, 2010 by technology
Filed under PHP tutorials
Introduction
In the last part of the tutorial I explained some of the advantages of PHP as a scripting language and showed you how to test your server for PHP. In this part I will show you the basics of showing information in the browser and how you can use variables to hold information.
Printing Text
To output text in your PHP script is actually very simple. As with most other things in PHP, you can do it in a variety of different ways. The main one you will be using, though, is print. Print will allow you to output text, variables or a combination of the two so that they display on the screen.
The print statement is used in the following way:
print(“Hello world!”);
I will explain the above line:
print is the command and tells the script what to do. This is followed by the information to be printed, which is contained in the brackets. Because you are outputting text, the text is also enclosed instide quotation marks. Finally, as with nearly every line in a PHP script, it must end in a semicolon. You would, of course, have to enclose this in your standard PHP tags, making the following code:
Which will display:
Hello world!
on the screen.
Variables
As with other programming languages, PHP allows you to define variables. In PHP there are several variable types, but the most common is called a String. It can hold text and numbers. All strings begin with a $ sign. To assign some text to a string you would use the following code:
$welcome_text = “Hello and welcome to my website.”;
This is quite a simple line to understand, everything inside the quotation marks will be assigned to the string. You must remember a few rules about strings though:
Strings are case sensetive so $Welcome_Text is not the same as $welcome_text
String names can contain letters, numbers and underscores but cannot begin with a number or underscore
When assigning numbers to strings you do not need to include the quotes so:
$user_id = 987
would be allowed.
Outputting Variables
To display a variable on the screen uses exactly the same code as to display text but in a slightly different form. The following code would display your welcome text:
As you can see, the only major difference is that you do not need the quotation marks if you are printing a variable.
Formatting Your Text
Unfortunately, the output from your PHP programs is quite boring. Everything is just output in the browser’s default font. It is very easy, though, to format your text using HTML. This is because, as PHP is a server side language, the code is executed before the page is sent to the browser. This means that only the resulting information from the script is sent, so in the example above the browser would just be sent the text:
Hello and welcome to my website.
This means, though, that you can include standard HTML markup in your scripts and strings. The only problem with this is that many HTML tags require the ” sign. You may notice that this will clash with the quotation marks used to print your text. This means that you must tell the script which quotes should be used (the ones at the beginning and end of the output) and which ones should be ignored (the ones in the HTML code).
For this example I will change the text to the Arial font in red. The normal code for this would be:
As you can see this code contains 4 quotation marks so would confuse the script. Because of this you must add a backslash before each quotation mark to make the PHP script ignore it. The code would chang
e to:
You can now include this in your print statement:
print(“Hello and welcome to my website.“);
which will make the browser display:
Hello and welcome to my website.
because it has only been sent the code:
Hello and welcome to my website.
This does make it quite difficult to output HTML code into the browser but later in this tutorial I will show you another way of doing this which can make it a bit easier.
Learn PHP yourself by this tutorial – Introduction to PHP
May 2, 2010 by technology
Filed under PHP tutorials
Introduction
Up until recently, scripting on the internet was something which very few people even attempted, let alone mastered. Recently though, more and more people have been building their own websites and scripting languages have become more important. Because of this, scripting languages are becomming easier to learn and PHP is one of the easiest and most powerful yet.
What Is PHP?
PHP stands for Hypertext Preprocessor and is a server-side language. This means that the script is run on your web server, not on the user’s browser, so you do not need to worry about compatibility issues. PHP is relatively new (compared to languages such as Perl (CGI) and Java) but is quickly becomming one of the most popular scripting languages on the internet.
Why PHP?
You may be wondering why you should choose PHP over other languages such as Perl or even why you should learn a scripting language at all. I will deal with learning scripting languages first. Learning a scripting language, or even understanding one, can open up huge new possibilities for your website. Although you can download pre-made scripts from sites like Hotscripts, these will often contain advertising for the author or will not do exactly what you want. With an understanding of a scripting language you can easily edit these scripts to do what you want, or even create your own scripts.
Using scripts on your website allows you to add many new ‘interactive’ features like feedback forms, guestbooks, message boards, counters and even more advanced features like portal systems, content management, advertising managers etc. With these sort of things on your website you will find that it gives a more professional image. As well as this, anyone wanting to work in the site development industry will find that it is much easier to get a job if they know a scripting language.
What Do I Need?
As mentioned earlier, PHP is a server-side scripting language. This means that, although your users will not need to install new software, you web host will need to have PHP set up on their server. It should be listed as part of your package but if you don’t know if it is installed you can find out using the first script in this tutorial. If you server does not support PHP you can ask your web host to install it for you as it is free to download and install. If you need a low cost web host which supports PHP I would recommmend HostRocket.
Writing PHP
Writing PHP on your computer is actually very simple. You don’t need any specail software, except for a text editor (like Notepad in Windows). Run this and you are ready to write your first PHP script.
Declaring PHP
PHP scripts are always enclosed in between two PHP tags. This tells your server to parse the information between them as PHP. The three different forms are as follows:
PHP Code In Here
All of these work in exactly the same way but in this tutorial I will be using the first option (). There is no particular reason for this, though, and you can use either of the options. You must remember, though, to start and end your code with the same tag (you can’t start with <? and end with for example).
Your First Script
The first PHP script you will be writing is very basic. All it will do is print out all the information about PHP on your server. Type the following code into your text editor:
As you can see this actually just one line of code. It is a standard PHP function called phpinfo which will tell the server to print out a standard table of information giving you information on the setup of the server.
One other thing you should notice in this example is th
at the line ends in a semicolon. This is very important. As with many other scripting and programming languages nearly all lines are ended with a semicolon and if you miss it out you will get an error.
Finishing and Testing Your Script
Now you have finished your script save it as phpinfo.php and upload it to your server in the normal way. Now, using your browser, go the the URL of the script. If it has worked (and if PHP is installed on your server) you should get a huge page full of the information about PHP on your server.
If your script doesn’t work and a blank page displays, you have either mistyped your code or your server does not support this function (although I have not yet found a server that does not). If, instead of a page being displayed, you are prompted to download the file, PHP is not installed on your server and you should either serach for a new web host or ask your current host to install PHP.
It is a good idea to keep this script for future reference.
Part 2
In this part I have introduced you to the basics of writing and running PHP. By this time you should now know if your host supports PHP and should have a basic understanding of how PHP scripts are structured. In part 2 I will show you how to print out information to the browser.
Creating simple PHP contact form by yourself in php
May 2, 2010 by technology
Filed under PHP Scripts
Overview
if you want to test on you own computer you must set your computer as a mail server by using Argosoft mail server or relate software.
read this tutorial
In this tutorial create 2 files
1. contact.php
2. send_contact.php
Step
1. Create file contact.php.
2. Create file send_contact.php.
Create file contact.php
############### Code
| Contact Form |
Create file send_contact.php
Diagram
############### Code
<?php
// Contact subject
$subject ="$subject";
// Details
$message="$detail";
// Mail of sender
$mail_from="$customer_mail";
// From
$header="from: $name “;
// Enter your email address
$to =’someone@somewhere.com’;
$send_contact=mail($to,$subject,$message,$header);
// Check, if message sent to your email
// display message “We’ve recived your information”
if($send_contact){
echo “We’ve recived your contact information”;
}
else {
echo “ERROR”;
}
?>
Tutorial: Creating Products in magento commerece
May 1, 2010 by technology
Filed under Magento
It’s hard to run an eCommerce site without products. If your store is missing this very important component, please read on:
Initial Setup
For the simplest of products, we’ll create a coffee cup.

- In the Magento admin, navigate to “Catalog -> Manager Products”
- In the top right, select “Add Product”
- Select an attribute set. Select “default” if you haven’t created any attribute sets.
(Be sure to read the section about creating attribute sets.) - Select a product type. For this example, select a “simple” product.
(For the other types, checkout the Grouped and Configurable product tutorials.) - Press continue.
Data Entry
After setting up the product you’re brought to the product detail view. All the product’s data is managed from this page. Let’s go over the tabs:
General

- Name: The product name as it will appear in the front-end.
- Description: The description that appears in the center of the product page.
- Short Description: The description that appears at the top of the product page.
- SKU: The products SKU. Magento uses SKU as a unique identifier for this product, across all stores and websites. SKU is global, meaning if you update the SKU for a product in one store, it will update in all other stores as well.
- Weight: The products weight – usually used for shipping calculations
- Set product as new from/to date: The date range in which this product can be promoted as a new product in various locations throughout your site.
- Status: “Enabled” displays in the front-end, and “Disabled” doesn’t display in the front-end.
- Tax Class: The product’s tax class. Magento comes with one tax class by default, but you can add more in Sales > Tax > Product Tax Classes.
- URL key: The Search Engine Friendly URL Identifier is the name used of the product used in the URL for the product. In our example, you’d be able to navigate to something like http://www.mymagentostore.com/cups/a-coffee-cup.html and see this product. You cannot use spaces in this field. If it is left blank, one will be automatically generated by Magento.
- Visibility: Determines if the product will display in the catalog pages and/or search results.
- Allow Gift Message: Determines whether custoemrs will be able to add gift messages to this particular product during checkout.
Price
Enter the price, cost, and special price information for this product here. You can also add pricing tiers. Read about tier pricing here.

Meta Information
SEO-related meta information is controlled from here: Page Title, meta keywords and meta description can be entered for this product. Page title will be the title of the product page. Meta keywords and description will show in the tag of the products html source.

Images
Magento requires three images per product – a base image, a small image, and a thumbnail. For each of these three image types, you can select which image to use to fulfill the requirement. If no image is uploaded, Magento will use the placeholder images that you can establish in System > Configuration. All images will also display under “More Images” on the product info page unless you select to Exclude it. Clicking one causes it to open in a popup. If you have multiple additional images, you can navigate through them using the popup.

Design
You can control the look of each product page individually in from the Design tab in the product page. It is very similar to the individual design options for categories. If your product page has a design separate from the category page to which it is associated, then the product level design will supercede the category level design. Select the design you want from the Custom Design drop-down. Magento comes with several different design options out of the box, but you can add you own. If you leave this drop-down blank, it will automatically use the Current package name design. This can be edited by navigating to System > Configuration and clicking the Design tab. Enter the name of the design you want in the Current package name field, and this design will apply to all products for which you do not specify a different design. With the Active From and Active To fields, you can select a time frame in which the category will automatically switch to a design, and then switch back to the blank option when the time frame ends. This is perfect for the holidays, so that you can create a holiday design for your pages, and then have your site automatically switch back to the normal design whenever you want, without having to remember to do it yourself. The Custom Layout Update is essentially a static block, with a few differences. Rather than HTML, the structure must be in XML format. The Update will display on the product page, below the product information, whereas a static block will only display on a category page. The Update will display on the page only during the dates specified in the Active date range.
Inventory
For all other fields, you can check the Use Config Settings checkbox in order to use the settings for this field in System > Configration > Inventory. To change any of these settings in order to make the settings unique for this product, uncheck the checkbox, which will unlock the field.
Websites
If you’re managing multiple Websites, you can select which websitesthis product belongs to by associating it to Websites from here. Just check the Websites you want the product to be available from.
Categories
Select what categories this product will belong to.

Related Products, Up-sells, Cross-sells
Select which products are related, up-sells or cross-sells of the product being edited. Read more about product relations here.
Product Reviews
You’ll see a list of all reviews that have been added to this product. This tab will only appear after the product has been saved.
Product Tags
Shows all tags that this product has been given by users, and the number of times each tag has been used. This tab will only appear after the product has been saved. Read more about product tags here.
Customers Tagged Product
A breakdown of individual customers who have tagged this product – the grid shows their first and last name, email, and tag used. This tab will only appear after the product has been saved. Read more about product tags here.
Saving the Product
Now you’re ready to save the product and check the fruits of your labor in the front-end. Click the image below to view the product.
Tutorial: Creating Attributes (custom fields) in magento
May 1, 2010 by technology
Filed under Magento
So you’re ready to add some custom data to your products? Luckily, this isn’t complicated. Today we’re going to create an attribute called “Hard Drive Size” for the external hard drives we’re about to sell in our store, and also an attribute called “Manufacturer” to use in our layered navigation. Let’s start with the simpler one – Hard Drive Size. In the front-end, this will appear on products like “Hard Drive Size: {whatever options you create and select}” – For example: “Hard Drive Size: 100GB”.
Creating a simple attribute – Hard Drive Size
- Log into the Magento admin panel
- Navigate to “Manage Attributes” under Catalog -> Attributes -> Manage Attributes
- In the top right, click on “Add New Attribute”
- You’re now on the Attribute edit page and Properties tab. It looks like this:
Properties Tab

- Attribute Identifier: This is the name of the attribute used by the system. Spaces can not be used in this field. We’ll type hard_drive_size.
- Scope: This determines the store level at which this attribute will save for all products. If you choose Global, and edit “Hard Drive Size” for product 123 in store A to “50 GB”, product 123’s hard drive size in store B (and any other stores) will also update to “50 GB”. For hard drive size, we’ll make it globally editable – we won’t sell the exact same hard drive in different stores with different sizes… that’s not possible. An example where we might want globally editable: no is “Price.” We might want to sell the Hard drive for $20 more in Store A.
- Catalog Input Type: This describes what kind of data the attribute will store. What’s set here determines how data entry for this attribute will take place. We’ll use Text Field since we want to enter the value for each product manually into a text field.
- Default Value: You can enter a value that will automatically populate for new products. We have many different hard drive sizes, so we will leave this blank.
- Unique Value: If “yes”, the data saved in this attribute has to be unique for each product. In this case, we’ll say “no”, because multiple hard drives can have the same hard drive size.
- Values Required: If “yes”, you will be required to enter data in this attribute field when saving a product that uses it.
- Input Validation: This decides whether the data entered by the store owner is validated when the product is saved. If validation is set to “Digits”, we’ll only be able to enter 0-9 in this field. An error will be thrown if we try to put letters in the field. In the case of Hard Drive Size, we don’t need validation on this field.
- Apply To: This determines for which Product Types this attribute will display. For example, price wouldn’t make sense in a grouped product, as each Simple Product associated to the Grouped Product will have its own price. Therefore, you can set price to not apply to grouped product, and you won’t be scratching your head over what numbers to write in there.
Manage Label / Options

Under this tab, you can enter the label for the attribute in the front-end. If you control stores in multiple languages, you can enter the label in each language under this tab. If a store’s label is blank, this store will look to the default label and use this one. Here we’ll enter “Hard Drive Size” under “Default”.
Frontend Properties
Click here to see how the attribute appears in the front-end.
Creating an attribute with controlled options – Manufacturer
The next attribute we’ll create is going to be “Manufacturer.” Let’s say you carry televisions by 4 manufacturers. Rather than having to type the name of each manufacturer, why not just make it an attribute and assign four possible options to it: Varien, Panasonic, JVC, and Sony.
Attribute Properties
For our “Manufacturer” attribute, we’ll use Catalog Input Type “Dropdown” since we want this attribute to have limited data. Using “Dropdown” also enables us to show the attribute as a layered navigation filter. Below is what the Properties tab looks like for “Manufacturer”:

Manage Label/Options
Since we select Dropdown as the input type, we have the ability to create the possible options for this attribute from this tab. Under “Manage Labels” tab is “Manage Options”. Press “Add Option” to add an option. It functions similarly to labels – any blank fields will look to the “default”. You can also set the positions of each value and select one of the values as the default. See below for how it looks after adding four manufacturers as options.

Applying to a product
Now, to apply this selectable attribute to a product, just add it to an attribute set and create a new product using this set. Below is a simplified example of the General tab of creating a new product in the admin:

Front-end
Click here to see how the attribute appears in the front-end.
![]()
Mmm, nice. Now you’ll never have to type these manufacturers again. Also, data entry will be more consistent, since it is impossible to have a typo or spelling error if a drop-down is used.
Tutorial: Creating and Managing Categories in magento
May 1, 2010 by technology
Filed under Magento
Selecting a Store
The first thing to do is select the store where you would like to add the category from the Choose Store View dropdown menu. The default is for all stores managed by the admin panel, but you can elect to create the category in only one of the stores by selecting that store.
After that you will need to enter a name for the category which will appear on the sites selected. You can then select the location the category will be located in. The default is Root Catalog, meaning the category will be a top-level category. If you select an existing category the new category will be created as a sub-category of the one you selected.
You can then enter a description, upload an image and enter meta information for the category.
Display Options
After that it really gets interesting. If you would like customers to be taken to a landing page – instead of the standard product listing page – when they select the category, you can select Static Block Only from the Display Mode dropdown and then select a static block from the CMS Block dropdown. This list will contain all the Static Blocks created in the Magento CMS (Don’t have any static blocks? Why don’t you check out How do I create and edit static blocks?). An example would be to create a Nike static block and direct all customers to that page when they select the Nike category. There are three options in the Display Mode dropdow:
Display products only
If you don’t need this category to look particularly fancy, select this mode. It will display the products you associated, the description you enter, and the image you upload. (If you want an image or description – if not, just leave these fields blank.)
Display only Static Block
Have a bunch of specific content you want to show for a certain category? The “Static Block only” display mode will not display products on the page – it will only display the static block you select, making this page appear as a landing page to your customers. Editing Static Blocks is done under the CMS menu, and is covered by this article. This is perfect if you want to get your customers excited about the category before showing them products.
Tip: Make this page an anchor category and let your customers use layered navigation to find their products after viewing the landing page!
Display Static Block and products
So you have several category pages where you want the same content, but feature different products? Easy – use this display mode:
- Create a static block for the content you want to use between categories.
- Now go back to manage categories, and find your category
- Select display mode “Static block and products”
- Select the static block you created in step 1. The static block will appear above the list of products.
That’s it! Repeat for any other categories where you want to show this content.
Is Active: Yes or No
You then select whether the category is active on the site. Selecting no will hide the category on the site.
Is Anchor: Yes or No
Finally you select whether the category page is an anchor. Anchors are used for the Layered Navigation in Magento.
If you set the category to be an Anchor the layered navigation (see How Does Layered Navigation Work in Magento? for a look at the layered navigation) will display the sub-categories of this category in the layered navigation. The layered navigation then takes all the products underneath, including ones in the sub-categories, and displays all the filterable attributes of those products. If you do not set the category as an Anchor it will not display the filterable attributes in the layered navigation.
Here is a look at the layered navigation for the Apparel category which is set to be an anchor.

Adding products to the category
Now you can select products to populate the category from the Category Products tab and you have created a new category for your online store. In the Category Products tab (accessible from the top of the category page), search for the products you want to associate and then click the checkboxes of these products. After the products are checked you’ll be able to control their Position in the category listing. Example in the screenshot below:

Adding customer design to the category page
You can customize the design of each category individually in the Custom Design tab. This controls the look of the category page, including the objects on the page and the structure of the page. Select the design you want from the Custom Design drop-down. Magento comes with several different design options out of the box, but you can add your own. If you leave this drop-down blank, it will automatically use the Current package name design. This can be edited by navigating to System > Configuration and clicking the Design tab. Enter the name of the design you want in the Current package name field, and this design will apply to all categories for which you do not specify a different design. Select your preference from the Apply To drop-down. This category only means that the design will only apply to this one category page. This category and its products means that the design will apply on this category page, and on the pages of all products associated to this category. If a product is associated to multiple categories, each with a different design, the design displayed on that product page will be determined by the design of the category page from which the user navigates to that product. This category and its child categories means that the design will apply on this category page, and on the pages of all sub-categories, sub-sub-categories, and so on. All mean thats the design will apply to this category, its child categories, and its products. With the Active From and Active To fields, you can select a time frame in which the category will automatically switch to a design, and then switch back to the blank option when the time frame ends. This is perfect for the holidays, so that you can create a holiday design for you pages, and then have your site automatically switch back to the normal design whenever you want, without having to remember to do it yourself. The Page Layout drop-down determines the structural aspects of the page. No layout updates uses the default settings that come with the Magento installation. Empty displays the category page without any objects, except for the content (products or static blocks only), category name, and view options (number to display per page, view as grid or list, and sort be options). 1 column displays the contents, category name and view options, as well as the header, footer, search field, and navigation bar. Column on the left adds the left column to the 1 column display, which by default includes the currency selection and layered navigation. Column on the right adds the right column to the 1 column display, which by default includes the shopping cart view, wishlist, compared products list, polls, and newsletter sign-up. 3 columns displays both the left and the right column. The Custom Layout Update is essentially a static block, with a few differences. Rather than HTML, the structure must be in XML format. The Update will display at the bottom of the page, below the products, whereas a static block will display above the products (if the static block is set to display with products). The Update will display on the page only during the dates specified in the Active date range.
Front-end
Finally navigate to the front-end and view the products. Below is a screenshot with product images removed:

The products will adhere to the Position entered in the admin panel.
Tutorial: Creating a Grouped Product in magento
May 1, 2010 by technology
Filed under Magento

There are three kinds of products in Magento: Simple, Grouped, and Configurable. If you want to make a simple product, they are covered in detail in the “Creating products” tutorial.
Advanced Products
Advanced products in Magento are a way to consolidate product variants onto a single product info page in the front-end. The variants themselves have their own SKUs and stock management. This is very powerful – it allows you to let customers search for the individual variants, but browse only to the consolidated product pages. (If it’s the implementation you want – you could also let customers browse the individual SKUs.)
Grouped Products display several products on one page. For example – if you’re selling chef’s knives and you have the same knife in four sizes, you can make a grouped product to display all four sizes. Customers can select the size(s) they want and add to cart from this page. Another example would be a themed bedroom set – you can create a grouped product and sell the sheets, comforter, and pillow cases all from the same page.
Creating a Grouped Product
There are a few steps involved:
- Create the invidivual products you want to sell on the Grouped Product page
- Create the grouped product itself
- Add the individual products to this grouped product
Creating the individual products
Before adding anything to the grouped product, you have to create the individual products you want to sell from the grouped product page. For our example, we’re going to use Chef’s knives. Let’s say you have 4 chef’s knives of the same manufacturer and series, and want to sell them all on one page – customers can add whichever of the set they want to cart.
- Navigate to Catalog -> Manage Products
- Click on “Add Product”
- Select “Simple Product”, use whichever attribute set you need for the product. For this example, the Default attribute set was fine – we aren’t using any attributes besides the system attributes.
- Do whatever data entry you desire for each simple product to be in the Grouped product. Below is what the General tab looks like for one of our knives:
- When you’re done with data entry for the product, press “Save”.
- Now repeat steps 2-4 for each product you will sail through the Grouped Product. You can also use the Duplicate Product feature to create the 4 seperate products without having to enter every value 4 times. Once you have created and saved your first product select the Duplicate button on the product page in the admin panel. The duplicate product will not copy unique values, such as SKU, as you need to edit these anyway. The duplicate product will be created with a status of disabled.

Creating the Grouped Product
- Navigate to “Catalog -> Manage Products”
- Click “Add Product”
- Select “Grouped Product” for the product type. We’re still OK with the default attribute set.
- On the general tab for the Grouped Product, you’ll notice a few fields are missing: Weight and Qty. These don’t make sense when applied to Grouped products, since the weights and quantities are determined by the individual products:
- There’s also an additional tab: Associated Products. This is where you will add the individual knives you just created to this Grouped Product. Let’s click on that tab now.
- If you type “Chef’s” into “Name” and hit “Search” you should find the 4 chef’s knives you just created.


If you check an item, it gets added to the grouped product. When checked, two fields unlock: Default Qty and Position. You can control the sort order of the items in the Position field. As with all sort orders in Magento, the product with the lowest number will have the highest position on the page. You can also enter a default quantity which will be a pre-populated value in the front-end qty box.
Grouped Products in the Front-end
Below is how the grouped product will appear in the front-end:

As you can see, the Position and Default Quantity fields reflect the information entered in the admin.
Tutorial: Creating a Configurable Product in magento
May 1, 2010 by technology
Filed under Magento
There are three kinds of products in Magento: Simple, Grouped, and Configurable. If you want to make a simple product.
Advanced Products
Advanced products in Magento are a way to consolidate product variants onto a single product info page in the front-end. The variants themselves have their own SKUs and stock management. This is very powerful – it allows you to let customers search for the individual variants, but browse only to the consolidated product pages. (If that’s the implementation you want – you could also let customers browse the individual SKUs.)
Configurable Products let your customers select the variant they desire by choosing options. For example, you sell t-shirts in two colors and three sizes. You’d create the six variants as invidivual products (with their own skus) and then add these six to a configurable product from where customers can choose size and color, then add to cart. If desired you could also have customers search for “red medium t-shirt” and land on the specific page for this variant.
Creating a Configurable Product
There are a few steps involved:
- Create the attributes that will be configurable by the user – for our example they will be Size and Color
- Create the attribute set that will be assigned to the variant products – for our example, we’ll call it “T-shirt”
- Create the invidivual variant products
- Create the configurable product, and add the “T-shirt” attribute set
- Add the individual variants to this configurable product
Creating Attributes
Below are screenshots of how the configurable attribute “Size” is set up.
Attribute Properties

Notice the “Catalog Input Type” is set to dropdown – this is required for the attribute to be compatible with configurable products. The Scope is also set to Global. When both of these settings are cconfigured in this manner, the Use To Create Configurable Product dropdown will appear. This must be set to Yes. Required is also set to “Yes”. In order for a Simple Product to be associated to a Configurable Product, it must have a value for all configurable attributes, so making it required ensures that you will remember to add a value for this attribute for all Simple Products.
Labels/Options

Note how the size options and their sort order have been entered above.
The attribute “Color” will be set up exactly the same, with only the Labels/Options page changed. It will look as follows with these 4 colors:

Creating the attribute set
Now we’re ready to create an attribute set called “T-shirt” to start using for this product. Go to “Catalog -> Attributes -> Manage Attribute Sets” and press “Add New Set”.
In our example, the name is “T-shirt” and we’re basing it on the default set:

Continue to the next page. Drag the two attributes into a new group which I called “Selectable Options”:

If any of that’s confusing, be sure to read the section called ”How do I create an attribute set?”.
Creating the simple products
Now that we created the attribute set, we’re ready to start entering the data for the simple products that will be part of the configurable product.
- Navigate to “Catalog -> Manage Products”. Press “New Product”
- Create a Simple Product based on the “T-shirt” attribute set
- Fill in all the required information, and make sure to fill in options for the “Selectable Options” tab, as shown below:
- After you’re done, press “Save Product”


Now, repeat these steps for every combination of options your super product will contain. Since this example had 3 sizes and 4 colors, you would create the 12 options individually. You can create duplicates of the first product you create to vastly speed up this process.
You should have a product list similar to this one when you’re done (of course, titles and SKUs can be whatever you choose, this example just uses the attributes in the title and sku):

After you’re done, you’re ready for the next and final step!
Creating the Configurable Product
- After making all the variants, navigate to “Catalog -> Manage Products”
- Press “New Product
- Select ‘Configurable’ based on the T-shirt attribute set
- The next screen lets you pick which attributes you want to associate. It picks attributes from the set that are Input Type: Dropdown, Scope: Global, and Use To Create Configurable Product: Yes
- Select both “Size” and “Color” and press “Continue”
- The next page is the regular create product page, with the addition of the “Associated Products” tab at the bottom. The general tab used for the sample product looks like this:
- Finally, let’s take a look at the “Associated Products” tab: If you push “Reset Filter”, you’ll see all products associated to the T-shirt Attribute Set that have options for the Size and Color attributes. If you check one (or all) you’ll see the “Associated Products Attributes Configuration” above the list. This is where you decide the sort order of the selectable attributes (click and drag an attribute to change) and also any price adjustments that selecting a specific attribute will have on the configurable product. For example: If you wanted the Magento shirt to be $5.00 more, you just have to enter “5” in the text field. Price adjustments can be either percentage based or a fixed amount. For our example, the Large size is 10% more, and the Magento shirt is $5.00 more.



In the above image you’ll notice an option called Attribute Name. This is the text that will display in the front-end for this product. In the example, “Select Color” and “Select Size” are the desired text for the front-end.
Above this, you will see a button called Create Empty. This allows you to create a Simple Product in a pop-up window that will automatically be associated to this Configurable Product. It is very useful if you have forgotten to create all of your Simple Products prior to beginning the Configurable Product creation phase.
When you’re done with all this, associate the product with a store and front-end category, and you’ll be able to find it in the front-end. You’re done!
Front-end
Here’s a section from the front-end for this configurable product, done and ready to use:


