Pages

Tuesday, 16 September 2014

how to create catalog event in magento

Today I will show you how to create catalog event in magento. This feature is enabling to offering the limited period of time to sell the products.

From Catalog menu click the catalog event under the Categories. This page contains a grid listing all Events that you have created. To create a new Event, click Add Catalog Event in the top right of the page. You will need to first select the category for which the Event will be created. Click on the desired category from the category tree. Only one event can exist for a given category at one time, so any categories that already have an associated Event will be disabled in the category tree.
Add Catalog Event

When you click on a valid category, you will be redirected to the next page. This page contains fields for the start and end date of the event, the image which will be displayed in the Event Widget, the sort order in the Event Widget, and checkboxes for displaying a countdown ticker block on the category page and/or product page (of products associated to the given category). 

Add Catalog Event 2

This page also displays the category for which you are creating the Event, which will link back to the previous step if clicked (so you can select a different category).

Add Catalog Event 3

 This catalog event will be displayed the CMS page. See below pic.

Create Catalog Event

There are some configuration settings that must be completed relating to Events before they can be used. To do so, navigate to System > Configuration, in the Catalog tab select the Catalog Events section.
  • Enable Catalog Events Functionality - Determines whether the Events module is enabled.
  • Enable Catalog Event Widget - Determines if the Event Widget is displayed in the frontend. This is a static block containing information about Events in your site. Sometimes this feature is referred to as Lister Block. There is more information about the Event Widget below.
  • Number of Events to be Displayed on Category - Determines the number of Events that will display in the Event Widget on the category pages.
  • Number of Events to be Displayed on CMS Pages - Determines the number of Events that will display in the Event Widget on CMS pages, such as the home page.
In addition, because events are associated with categories in Magento, the category must be created before creating a category event.
Finally, because most events are promotions of some sort you will also have to create the catalog or shopping cart price rule to manage the offer/promotion in effect.
Category permissions and website restrictions can be used in conjunction with Invitations and Events to create private sales.


  • Category - Category to which this event will apply.
  • Start/End Date - Required. Start and end dates of the event.
  • Image
  • Sort Order
  • Display Countdown Ticker On - Determines if a countdown ticker will be displayed.
    • Category Page : The ticker block will display at the top of the category page.
    • Product Page : The ticker block will display at the top of each product view page of products assigned to the given category.
  • Status - Status is solely dependent upon the start and end date of the Event. Future Events are Upcoming, current Events are Open, and past Events are Closed.
 If you have any queries feel free to post a comment here..............

Thursday, 11 September 2014

how to add/show Custom attribute to Magento Cart price rule Condition Dropdown

To day I will show you how to create Magento Cart price rule Condition based on custom attribute. However, when we went to create the rule – based on SKU – we realized that the conditions dropdown was no longer displaying the attributes as it had in the past. The dropdown looked something like this:
Please choose a condition to add…
Conditions Combination
Cart Item Attribute
 – Price In cart
 – Quantity in cart
 – Row total in cart
Product Attribute
 – Attribute Set
 – Category
The fix that worked for me:
In the Magento Admin Panel go to Catalog > Attributes > Manage Attributes
how to add/show Custom attribute to Magento Cart price rule Condition Dropdown

Select any attribute that you’d like to be able to sort by in the conditions list. On the edit-a-attribute page, under “Frontend Properties” set “Use for Promo Rule Conditions” to “Yes”. Save the attribute.
Then go to System > Index Management and re-index.
Now – when you go back to creating your Shopping Cart Price Rule, you will see your attribute in the conditions list.

how to add/show Custom attribute to Magento Cart price rule Condition Dropdown 2
 Simply add custom/existing attribute like this.
If you have any queries feel free to leave a comment.

Thursday, 14 August 2014

Insert, Edit and Delete operations in PHP

In this article we will learn how to insert, edit, update and delete records from the database using PHP. Here we have to create five pages such as config.php (to provide the connection), view.php (to display the records from the database), insert.php (to insert records into the database), edit.php (to edit records), and delete.php (to delete records).

Table Structure



SET SQL_MODE="NO_AUTO_VALUE_ON_ZERO";

--
-- Database: `Sample`
--

-- --------------------------------------------------------

--
-- Table structure for table `employee`
--

CREATE TABLE `employee` (
`id` int(12) NOT NULL auto_increment,
`name` varchar(255) NOT NULL,
`address` varchar(255) NOT NULL,
`city` varchar(255) NOT NULL,
PRIMARY KEY (`id`)
) ENGINE=MyISAM DEFAULT CHARSET=latin1 AUTO_INCREMENT=7 ;

--
-- Dumping data for table `employee`
--

INSERT INTO `employee` (`id`, `name`, `address`, `city`) VALUES
(1, 'Raj', '10 street dane', 'Pune'),
(2, 'Ravi', '12907A 53 St NW', 'Mumbai'),
(3, 'Rahul', '3rd Floor, 888 Fort Street', 'Noida'),
(4, 'Harry', 'Sir Frederick W Haultain Building 9811 109 ST NW', 'London'),
(5, 'Ian', 'Suite 303, 13220 St. Albert Trail', 'Sydney'),
(6, 'Shaun', '9700 Jasper Avenue', 'Perth');

Code part

Config.php


<?php

/* Database Connection */

$sDbHost = 'localhost';
$sDbName = 'Sample';
$sDbUser = 'root';
$sDbPwd = '';

$dbConn = mysql_connect ($sDbHost, $sDbUser, $sDbPwd) or die ('MySQL connect failed. ' . mysql_error());
mysql_select_db($sDbName,$dbConn) or die('Cannot select database. ' . mysql_error());

?>
View.php

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<html>
<head>
<title>View Records</title>
</head>
<body>
<?php

include('config.php');

$result = mysql_query("SELECT * FROM employee")
or die(mysql_error());

echo "<table border='1' cellpadding='10'>";
echo "<tr>
<th><font color='Red'>Id</font></th>
<th><font color='Red'>Name</font></th>
<th><font color='Red'>Address</font></th>
<th><font color='Red'>City</font></th>
<th><font color='Red'>Edit</font></th>
<th><font color='Red'>Delete</font></th>
</tr>";

while($row = mysql_fetch_array( $result ))
{

echo "<tr>";
echo '<td><b><font color="#663300">' . $row['id'] . '</font></b></td>';
echo '<td><b><font color="#663300">' . $row['name'] . '</font></b></td>';
echo '<td><b><font color="#663300">' . $row['address'] . '</font></b></td>';
echo '<td><b><font color="#663300">' . $row['city'] . '</font></b></td>';
echo '<td><b><font color="#663300"><a href="edit.php?id=' . $row['id'] . '">Edit</a></font></b></td>';
echo '<td><b><font color="#663300"><a href="delete.php?id=' . $row['id'] . '">Delete</a></font></b></td>';
echo "</tr>";

}

echo "</table>";
?>
<p><a href="insert.php">Insert new record</a></p>
</body>
</html>

 
Insert.php

<?php
function valid($name, $address,$city, $error)
{
?>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<html>
<head>
<title>Insert Records</title>
</head>
<body>
<?php

if ($error != '')
{
echo '<div style="padding:4px; border:1px solid red; color:red;">'.$error.'</div>';
}
?>

<form action="" method="post">
<table border="1">
<tr>
<td colspan="2"><b><font color='Red'>Insert Records </font></b></td>
</tr>
<tr>
<td width="179"><b><font color='#663300'>Name<em>*</em></font></b></td>
<td><label>
<input type="text" name="name" value="<?php echo $name; ?>" />
</label></td>
</tr>

<tr>
<td width="179"><b><font color='#663300'>Address<em>*</em></font></b></td>
<td><label>
<input type="text" name="address" value="<?php echo $address; ?>" />
</label></td>
</tr>

<tr>
<td width="179"><b><font color='#663300'>City<em>*</em></font></b></td>
<td><label>
<input type="text" name="city" value="<?php echo $city; ?>" />
</label></td>
</tr>

<tr align="Right">
<td colspan="2"><label>
<input type="submit" name="submit" value="Insert Records">
</label></td>
</tr>
</table>
</form>
</body>
</html>
<?php
}

include('config.php');

if (isset($_POST['submit']))
{

$name = mysql_real_escape_string(htmlspecialchars($_POST['name']));
$address = mysql_real_escape_string(htmlspecialchars($_POST['address']));
$city = mysql_real_escape_string(htmlspecialchars($_POST['city']));

if ($name == '' || $address == '' || $city == '')
{

$error = 'Please enter the details!';

valid($name, $address, $city,$error);
}
else
{

mysql_query("INSERT employee SET name='$name', address='$address', city='$city'")
or die(mysql_error());

header("Location: view.php");
}
}
else
{
valid('','','','');
}
?>

 
Edit.php

<?php
function valid($id, $name, $address,$city, $error)
{
?>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<html>
<head>
<title>Edit Records</title>
</head>
<body>
<?php

if ($error != '')
{
echo '<div style="padding:4px; border:1px solid red; color:red;">'.$error.'</div>';
}
?>

<form action="" method="post">
<input type="hidden" name="id" value="<?php echo $id; ?>"/>

<table border="1">
<tr>
<td colspan="2"><b><font color='Red'>Edit Records </font></b></td>
</tr>
<tr>
<td width="179"><b><font color='#663300'>Name<em>*</em></font></b></td>
<td><label>
<input type="text" name="name" value="<?php echo $name; ?>" />
</label></td>
</tr>

<tr>
<td width="179"><b><font color='#663300'>Address<em>*</em></font></b></td>
<td><label>
<input type="text" name="address" value="<?php echo $address; ?>" />
</label></td>
</tr>

<tr>
<td width="179"><b><font color='#663300'>City<em>*</em></font></b></td>
<td><label>
<input type="text" name="city" value="<?php echo $city; ?>" />
</label></td>
</tr>

<tr align="Right">
<td colspan="2"><label>
<input type="submit" name="submit" value="Edit Records">
</label></td>
</tr>
</table>
</form>
</body>
</html>
<?php
}

include('config.php');

if (isset($_POST['submit']))
{

if (is_numeric($_POST['id']))
{

$id = $_POST['id'];
$name = mysql_real_escape_string(htmlspecialchars($_POST['name']));
$address = mysql_real_escape_string(htmlspecialchars($_POST['address']));
$city = mysql_real_escape_string(htmlspecialchars($_POST['city']));


if ($name == '' || $address == '' || $city == '')
{

$error = 'ERROR: Please fill in all required fields!';


valid($id, $name, $address,$city, $error);
}
else
{

mysql_query("UPDATE employee SET name='$name', address='$address' ,city='$city' WHERE id='$id'")
or die(mysql_error());

header("Location: view.php");
}
}
else
{

echo 'Error!';
}
}
else

{

if (isset($_GET['id']) && is_numeric($_GET['id']) && $_GET['id'] > 0)
{

$id = $_GET['id'];
$result = mysql_query("SELECT * FROM employee WHERE id=$id")
or die(mysql_error());
$row = mysql_fetch_array($result);

if($row)
{

$name = $row['name'];
$address = $row['address'];
$city = $row['city'];

valid($id, $name, $address,$city,'');
}
else
{
echo "No results!";
}
}
else

{
echo 'Error!';
}
}
?>

 
Delete.php

<?php
include('config.php');

if (isset($_GET['id']) && is_numeric($_GET['id']))
{
$id = $_GET['id'];

$result = mysql_query("DELETE FROM employee WHERE id=$id")
or die(mysql_error());

header("Location: view.php");
}
else

{
header("Location: view.php");
}
?>


Output

Insert, Edit and Delete operations in PHP


Insert, Edit and Delete operations in PHP 2


Insert, Edit and Delete operations in PHP 3



After inserting 6 records

Insert, Edit and Delete operations in PHP



Insert, Edit and Delete operations in PHP 5


After editing the address of Name (Raj)

Insert, Edit and Delete operations in PHP 6