Magento Downloadable Product

Hello friends,

While working with magento store, sometimes it can be a requirement of store owner to provide digital file/s as a product.

For Example: image file, music file or computer software.

Don’t worry! To satisfy the above requirement, magento facilitate downloadable product type.

Downloadable products enables customer to download one or more digital files. Those files can either be uploaded by magento admin or by server FTP.

To create a downloadable product in magento follow the under given steps:

Step 1: Login to your magento admin.

Step 2: Go to Catalog -> Manage Products.

Click on “Add Product” button.

Select the downloadable product type and click on continue button.

Step 3: Fill the basic information of product. Like: product’s name, price, description, quantity, status, visibility, meta tags, etc.

Before you add the Downloadable Information click on Save and Continue Edit button.

 

 

 

Step 4: Click on Downloadable Information link from left menu.

Click on “Links” tab.

Enter the proper text in Title textbox.

Click on Add New Row button.

Click on file button to browse the file or enter the url in textbox.

Then click on Upload Files button to upload the file.

Here you can also upload the sample file or give url of it.

Click the Save and Continue Edit button.

 

Step 5: Go to System -> Configuration -> Catalog -> Downloadable Product Options and set the “Order Item Status to Enable Downloads” to “Pending” and save.

Now we can see the downloadable product in our store front side.

Once we purchase that item, we are able to download the file from “My Downloadable Products” section of my account page.

Hope this will help you.

Thanks.

Advertisements

10 Myths which panics SEOs Part 1

SEO Myths Part 1There are so many myths roaming around the SEO world, it is the reason why most of the SEOs worry about some SEO tactics. For now, we have collected 10 Myths to stop worry about. So Read On! Read the rest of this entry »

JAVA:Registration form using JSP,Bean,and Mysql

Hello  friends,

In this section you will learn about the handling of user registration form using jsp and bean.

STEP 1Create simple registration form using jsp/html

<html>
<body >
<form action="process.jsp" method="post"><center>
<span style="font-size: x-large;">User Registration</span>

<span style="color: red; font-size: small;"><sup>*</sup> Required Fields</span>
<table border="1" cellspacing="1" cellpadding="2" bgcolor="lightblue">
<tbody>
<tr bgcolor="lightblue">
<td valign="top">
<strong>First Name<sup>*</sup></strong>

<input type="text" name="firstName" value="" size="20" maxlength="20" /></td>
<td valign="top">
<strong>Last Name<sup>*</sup></strong>

<input type="text" name="lastName" value="" size="15" maxlength="20" /></td>
</tr>
<tr bgcolor="lightblue">
<td valign="top">
<strong>E-Mail<sup>*</sup></strong>

<input type="text" name="email" value="" size="25" maxlength="125" /></td>
<td valign="top">
<strong>Age<sup>*</sup></strong>

<input type="text" name="age" value="" size="6" maxlength="5" /></td>
</tr>
<tr bgcolor="lightblue">
<td valign="top">
<strong>City<sup>*</sup></strong>

<input type="text" name="city" value="" size="20" maxlength="20" /></td>
<td valign="top">
<strong>Zip Code<sup>*</sup></strong>

<input type="text" name="zip" value="" size="10" maxlength="8" /></td>
</tr>
<tr bgcolor="lightblue">
<td colspan="2" valign="top">
<strong>User Name<sup>*</sup></strong>

<input type="text" name="userName" value="" size="20" maxlength="15" /></td>
</tr>
<tr bgcolor="lightblue">
<td valign="top">
<strong>Password<sup>*</sup></strong>

<input type="password" name="password1" value="" size="15" maxlength="15" /></td>
<td valign="top">
<strong>Confirm Password<sup>*</sup></strong>

<input type="password" name="password2" value="" size="15" maxlength="15" /></td>
</tr>
<tr bgcolor="lightblue">
<td colspan="2" align="center"><input type="submit" value="Submit" /><input type="reset" value="Reset" /></td>
</tr>
</table>
</center></form>
</body></html>

Step 2:  Create controller JSP .These pages would still specify the bulk of the processing to component beans, but they would also contain some conditional logic to respond to a user’s actions. But these controller pages would never contain presentation logic to display UI elements. This task would always be externalized into separate JSPs, which will be invoked as needed by the controller

process.jsp
<%@page contentType="text/html" pageEncoding="UTF-8"%>
<!DOCTYPE html>
<%@ page language="java" %>
<%@ page import="java.util.*" %>
<%!%>
<jsp:useBean id="formHandler" scope="request">
<jsp:setProperty name="formHandler" property="*"/>
</jsp:useBean>

<%
if (formHandler.validate())
{
formHandler.insertData();%>
<jsp:forward page="successful.jsp"/>
<%   }
else  {
%>
<jsp:forward page="retry.jsp"/>
<%}%>

Step3:Java Bean
In this step when developing beans for processing form data, you can follow a common design pattern 
by matching the names of the beans properties with the names of the form input elements. you would also need to 
define the corresponding getter and setter methods for each property within the bean.

package register;

import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.Statement;
import java.util.Hashtable;
import java.util.logging.Level;
import java.util.logging.Logger;
public class RegistrationDetails
{
private String firstName,lastName,email,userName,password1,password2,zip,city,notify;
private int age;
private Hashtable errors;
private Connection connection=null;
Statement st;

public boolean validate() {
boolean bool=true;

if (firstName.equals(""))
{
errors.put("firstName","Please enter your first name");
firstName="";
bool=false;
}
if (lastName.equals(""))
{
errors.put("lastName","Please enter your last name");
lastName="";
bool=false;
}
if (email.equals("") || (email.indexOf('@') == -1))
{
errors.put("email","Please enter a valid email address");
email="";
bool=false;
}

if (age130)
{
errors.put("age","Please enter a valid Age");
age=0;
bool=false;
}

if (city.equals(""))
{
errors.put("city","Please enter your city name");
city="";
bool=false;
}

if (zip.equals("") || zip.length() !=6 )
{
errors.put("zip","Please enter a valid zip code");
zip="";
bool=false;
}
else
{
try {
int x = Integer.parseInt(zip);
} catch (NumberFormatException e)
{
errors.put("zip","Please enter a valid zip code");
zip="";
bool=false;
}
}

if (userName.equals(""))
{
errors.put("userName","Please enter a username");
userName="";
bool=false;
}

if (password1.equals("") )
{
errors.put("password1","Please enter a valid password");
password1="";
bool=false;
}

if (!password1.equals("") && (password2.equals("") || !password1.equals(password2)))
{
errors.put("password2","Please confirm your password");
password2="";
bool=false;
}
return bool;
}

public String getErrorMsg(String s)
{
String errorMsg =(String)errors.get(s.trim());
return (errorMsg == null) ? "":errorMsg;
}
public void insertData()
{
try {
try {
Class.forName("com.mysql.jdbc.Driver");
} catch (Exception ex)
{
System.out.println("Error in class.forname"+ex.getCause());
Logger.getLogger(RegistrationDetails.class.getName()).log(Level.SEVERE, null, ex);
}
connection = (Connection) DriverManager getConnection. ("jdbc:mysql://localhost:3306/RegistrationForm","root", "root");
st= (Statement) connection.createStatement();
String table = "create table if not exists Registration(First_Name varchar(20),Last_Name varchar(20),
                                EmailAddress varchar(40),Age int(4),Cityvarchar(15),Zip_Code varchar(10),
                                UserName varchar(15),Password varchar(15))";
st.executeUpdate(table);
firstName=getFirstName();
lastName=getLastName();
email=getEmail();
age=getAge();
city=getCity();
zip=getZip();
userName=getUserName();
password1=getPassword1();
st.executeUpdate("insert into Registration(First_Name,Last_Name,EmailAddress,Age,City,Zip_Code,
                                UserName,Password) values('"+firstName+"','"+lastName+"','"+email+"','"+age+"','"
                                +city+"','"+zip+"','"+userName+"','"+password1+"')");
System.out.println("Store into the database");
} catch (Exception ex)
{
System.out.println("Error in connection::"+ex.getCause());
}
}

public RegistrationDetails()
{
firstName="",lastName="",email="",age=0,userName="",password1="",password2="";
city="",zip="",notify="";
errors = new Hashtable();
}

public String getFirstName() {
return firstName;}
public String getLastName() {
return lastName;}

public String getEmail() {
return email;}

public int getAge() {
return age;}

public String getUserName() {
return userName;}

public String getPassword1() {
return password1;}

public String getPassword2() {
return password2;}

public String getCity() {
return city;}

public String getZip() {
return zip;}

public void setFirstName(String fname) {
firstName =fname;}

public void setLastName(String lname) {
lastName =lname;}

public void setEmail(String eml) {
email=eml;}

public void setAge(int age) {
this.age=age;}

public void setUserName(String u) {
userName=u;}

public void setPassword1(String p1) {
password1=p1;}

public void setPassword2(String p2) {
password2=p2;}

public void setCity(String city) {
this.city=city;}

public void setZip(String z) {
zip=z;}
}

Step 4: Retry Page.

Create a "retry.jsp" file for displaying error. If  the user submits the form without fulfilling field, proces.jsp 
will return on retry.jsp page. The processing logic within the controller page is straight forward. After the bean 
is instantiated, its validate() method is invoked. The validate() method has a two-pronged effect. If an error is 
encountered during the validation of any form input element, the validate() method not only resets the value of 
the corresponding bean property, but also sets an appropriate error message, which can later be displayed for that 
input element. If any of the required form elements cannot be successfully validated, the controller forwards the 
request to the JSP page retry.jsp allowing the user to make changes and resubmit the form. If there are no 
validation errors, the request is forwarded to success.jsp.

This page will be mostly same as index/first page expect some error message so I am not posting the code for retry.

Step5: Success Page

Create a "success.jsp" file for displaying all data entered by user. As stated earlier, the controller forwards 
the request to success.jsp only after all of the submitted form data has been successfully validated.Success.jsp 
in turn extracts the bean component from the request and confirms the registration to the client.

<html>
<body>
<center>
<span style="font-size: x-large;">User Registration Successfull!</span>
<table border="1" cellspacing="1" cellpadding="1">
<tr>
<td valign="top"><strong>First Name</strong></td>
<td valign="top"><strong>Last Name</strong></td>
<td valign="top"><strong>E-Mail</strong></td>
<td valign="top"><strong>Age</strong></td>
<td valign="top"><strong>City</strong></td>
<td valign="top"><strong>Zip Code</strong></td>
<td colspan="2" valign="top"><strong>User Name</strong></td>
</tr>
</table>
</center>
</body></html>

Hope it helps .

Posted in JAVA. 2 Comments »

Magento Upgrade

Hello friends,

The term upgrade refers to the replacement of a product with a newer version of the same product.

In the world of information and technology each technology improves day by day in terms of speed and features, so the new technology will replace the old one.

The same rule will apply while working with magento, because day by day newer versions of magento have been found with better features.

To use the new features of magento, store owners are required to upgrade their store with the latest magento version.

We can upgrade the magento full version via SVN or by using Magento Connect Manager, but it is better to use Magento Connect Manager to upgrade.

The steps to upgrade magento store using Magento Connect Manager is as under:

Step1: Login to your magento admin.

Step2: Go to System -> Magento Connect -> Magento Connect Manager from the header menu.

Step3: Login to your Magento Connect Manager with same username and password, which are used for admin login.

Step4: Click on Check for Upgrades button.

Step5: Select the “clear all sessions after successful install or upgrade” option.

Step6: Select the upgrade to latest version action from the action combo box for the magento core packages.

Step7: Click on “Commit Changes” button, and it will upgrade your magento store packages to the latest versions.

Hope this will help you.

Thanks.

Some Penguin Friendly Link Building Tips

Google Penguin Friendly Link BuildingAs the Penguin update rolled out many websites’ ranking goes up and down, there are question about which link building methods to follow to stay away from Penguin penalty. Many traditional link building methods were and now being penalized after Penguin came. So here I’m going to show you some link building methods which will continue to help you websites’ ranking grow up in this Penguin Crisis. So now let’s get straight to the Point.

  • Get More Social, Power Your Fan-base
    Social signal will be more important than ever in this year of 2012. Share your content on all the social networks you have. The likes, re-tweets, +1s will give your content boost to get rank higher. There are also possibilities of getting your content viral which can get you a lot of traffic. Read the rest of this entry »

Magento Migration

Hello friends,

While working with magento store, sometimes we required the migration of our magento store from one to another domain.

At that time we may need to change our store’s database name, its username, its password and store’s url. It means we have to reconfigure our magento store.

So here we are discussing the steps of magento migration.

Step1: Take a backup of your magento store database.

Step2: Take a backup of your magento store file structure.

Step3: Go to the phpmyadmin of your new domain server. Here create a database, its user and password. And restore the database backup in the created one.

Step4: Go to the file manager of your new domain server, and restore the file structure.

Step5: Now in phpmyadmin of your new domain server open the restored database. Open the “core_config_data” table and edit the values of “web/unsecure/base_url” and “web/secure/base_url” according to your store’s configuration.

Step6: Open the “/app/etc/local.xml” and put the values in it according to your new configuration.


<host><![CDATA[your server’s host name]]></host>

<username><![CDATA[database user name]]></username>

<password><![CDATA[database password]]></password>

<dbname><![CDATA[database name]]></dbname>

Hope this will help you.

Thanks.