Pages

Tuesday, 18 June 2013

multiple store with multiple domain

all code of the index . php file in magento

*******************************************************

<?php
/**
 * Magento
 *
 * NOTICE OF LICENSE
 *
 * This source file is subject to the Open Software License (OSL 3.0)
 * that is bundled with this package in the file LICENSE.txt.
 * It is also available through the world-wide-web at this URL:
 * http://opensource.org/licenses/osl-3.0.php
 * If you did not receive a copy of the license and are unable to
 * obtain it through the world-wide-web, please send an email
 * to license@magentocommerce.com so we can send you a copy immediately.
 *
 * DISCLAIMER
 *
 * Do not edit or add to this file if you wish to upgrade Magento to newer
 * versions in the future. If you wish to customize Magento for your
 * needs please refer to http://www.magentocommerce.com for more information.
 *
 * @category   Mage
 * @package    Mage
 * @copyright  Copyright (c) 2008 Irubin Consulting Inc. DBA Varien (http://www.varien.com)
 * @license    http://opensource.org/licenses/osl-3.0.php  Open Software License (OSL 3.0)
 */

if (version_compare(phpversion(), '5.2.0', '<')===true) {
    echo  '<div style="font:12px/1.35em arial, helvetica, sans-serif;">
<div style="margin:0 0 25px 0; border-bottom:1px solid #ccc;">
<h3 style="margin:0; font-size:1.7em; font-weight:normal; text-transform:none; text-align:left; color:#2f2f2f;">
Whoops, it looks like you have an invalid PHP version.</h3></div><p>Magento supports PHP 5.2.0 or newer.
<a href="http://www.magentocommerce.com/install" target="">Find out</a> how to install</a>
 Magento using PHP-CGI as a work-around.</p></div>';
    exit;
}

/**
 * Error reporting
 */
error_reporting(E_ALL | E_STRICT);

/**
 * Compilation includes configuration file
 */
define('MAGENTO_ROOT', getcwd());

$compilerConfig = MAGENTO_ROOT . '/includes/config.php';
if (file_exists($compilerConfig)) {
    include $compilerConfig;
}

$mageFilename = MAGENTO_ROOT . '/app/Mage.php';
$maintenanceFile = 'maintenance.flag';

if (!file_exists($mageFilename)) {
    if (is_dir('downloader')) {
        header("Location: downloader");
    } else {
        echo $mageFilename." was not found";
    }
    exit;
}

if (file_exists($maintenanceFile)) {
    include_once dirname(__FILE__) . '/errors/503.php';
    exit;
}

require_once $mageFilename;

#Varien_Profiler::enable();

if (isset($_SERVER['MAGE_IS_DEVELOPER_MODE'])) {
    Mage::setIsDeveloperMode(true);
}

#ini_set('display_errors', 1);

umask(0);

/* Store or website code */
$mageRunCode = isset($_SERVER['MAGE_RUN_CODE']) ? $_SERVER['MAGE_RUN_CODE'] : '';

/* Run store or run website */
$mageRunType = isset($_SERVER['MAGE_RUN_TYPE']) ? $_SERVER['MAGE_RUN_TYPE'] : 'store';

/*$url_xyz=$main_url= $_SERVER['HTTP_HOST'].$_SERVER['REQUEST_URI'];
if($url_xyz=='www.willowdalebotanicalscience.com' || $url_xyz=='http://www.willowdalebotanicalscience.com')
{
Mage::run("willowdalebotanicalscience","store");
}
elseif($url_xyz=='www.celluvati.com' || $url_xyz=='http://www.celluvati.com')
{
Mage::run("celluvati","store");
}
else
{
Mage::run("default", "store");
}*/



//Mage::run("celluvati","store");


//Mage::run($mageRunCode, $mageRunType);


   $x= $_SERVER['HTTP_HOST'];
  
switch ($x)
{
case 'celluvati.com':
 Mage::run("celluvati","store");
  break;
case 'www.celluvati.com':
 Mage::run("celluvati","store");
  break;
  case 'http://www.celluvati.com':
 Mage::run("celluvati","store");
  break;
  case 'https://www.celluvati.com':
 Mage::run("celluvati","store");
  break;


case 'wbscience.com':
  Mage::run("wbscience","store");
  break;
  case 'www.wbscience.com':
  Mage::run("wbscience","store");
  break;
  case 'http://www.wbscience.com':
  Mage::run("wbscience","store");
  break;
  case 'https://www.wbscience.com':
  Mage::run("wbscience","store");
  break;

 case 'willowdalebotanicalscience.com':
  Mage::run("default","store");
  break;
  case 'www.willowdalebotanicalscience.com':
  Mage::run("default","store");
  break;
  case 'http://www.willowdalebotanicalscience.com':
  Mage::run("default","store");
  break;
  case 'https://www.willowdalebotanicalscience.com':
  Mage::run("default","store");
  break;

default:
 Mage::run("default","store");
}



?>
***********************************************************

Set up multy domain and multi store website in magento

Simply add this code in index.php and change your adons name and store name in that file.


<?php
 $x= $_SERVER['HTTP_HOST'];
  
switch ($x)
{
case 'celluvati.com':
 Mage::run("celluvati","store");
  break;
case 'www.celluvati.com':
 Mage::run("celluvati","store");
  break;
  case 'http://www.celluvati.com':
 Mage::run("celluvati","store");
  break;
  case 'https://www.celluvati.com':
 Mage::run("celluvati","store");
  break;


case 'wbscience.com':
  Mage::run("wbscience","store");
  break;
  case 'www.wbscience.com':
  Mage::run("wbscience","store");
  break;
  case 'http://www.wbscience.com':
  Mage::run("wbscience","store");
  break;
  case 'https://www.wbscience.com':
  Mage::run("wbscience","store");
  break;

 case 'willowdalebotanicalscience.com':
  Mage::run("default","store");
  break;
  case 'www.willowdalebotanicalscience.com':
  Mage::run("default","store");
  break;
  case 'http://www.willowdalebotanicalscience.com':
  Mage::run("default","store");
  break;
  case 'https://www.willowdalebotanicalscience.com':
  Mage::run("default","store");
  break;

default:
 Mage::run("default","store");
}



?>

Show all categories in magento


<?php //Display all category in all page  ?>

<?php foreach ($this->getStoreCategories() as $_category): ?>
<li>
<a href="<?php echo $this->getCategoryUrl($_category) ?>">
<?php echo $this->htmlEscape($_category->getName()) ?>
</a>
<?php
$_catid = $_category->getId();
$category = Mage::getModel('catalog/category')->load($_catid);
$subcategory = $category->getAllChildren(true);
array_shift($subcategory);
if($subcategory!=null)
{?>
<ul>
<?php
foreach ($subcategory as $sub)
{
$sub1 = Mage::getModel('catalog/category')->load($sub);
?>
<li class="lvel<?php echo $sub1->getLevel(); ?>">
<a href="<?php echo $sub1->getUrl();?>"><span><?php echo $sub1->getName(); ?></span></a>
</li>
<?php } ?>
</ul>
<?php }?>
</li>
<?php endforeach ?>

Show all categories in magento


<?php //Display all category in all page  ?>

<?php foreach ($this->getStoreCategories() as $_category): ?>
<li>
<a href="<?php echo $this->getCategoryUrl($_category) ?>">
<?php echo $this->htmlEscape($_category->getName()) ?>
</a>
<?php
$_catid = $_category->getId();
$category = Mage::getModel('catalog/category')->load($_catid);
$subcategory = $category->getAllChildren(true);
array_shift($subcategory);
if($subcategory!=null)
{?>
<ul>
<?php
foreach ($subcategory as $sub)
{
$sub1 = Mage::getModel('catalog/category')->load($sub);
?>
<li class="lvel<?php echo $sub1->getLevel(); ?>">
<a href="<?php echo $sub1->getUrl();?>"><span><?php echo $sub1->getName(); ?></span></a>
</li>
<?php } ?>
</ul>
<?php }?>
</li>
<?php endforeach ?>

Wednesday, 8 May 2013

Delete all orders in magento | Truncate all order in magento


SET FOREIGN_KEY_CHECKS=0;

TRUNCATE `sales_flat_order`;
TRUNCATE `sales_flat_order_address`;
TRUNCATE `sales_flat_order_grid`;
TRUNCATE `sales_flat_order_item`;
TRUNCATE `sales_flat_order_payment`;
TRUNCATE `sales_flat_order_status_history`;

TRUNCATE `sales_flat_creditmemo`;
TRUNCATE `sales_flat_creditmemo_comment`;
TRUNCATE `sales_flat_creditmemo_grid`;
TRUNCATE `sales_flat_creditmemo_item`;

TRUNCATE `sales_flat_invoice`;
TRUNCATE `sales_flat_invoice`;
TRUNCATE `sales_flat_invoice_grid`;
TRUNCATE `sales_flat_invoice_item`;

TRUNCATE `sales_flat_quote`;
TRUNCATE `sales_flat_quote_address`;
TRUNCATE `sales_flat_quote_address_item`;
TRUNCATE `sales_flat_quote_item`;
TRUNCATE `sales_flat_quote_item_option`;
TRUNCATE `sales_flat_order_item`;

TRUNCATE `sales_flat_shipment`;
TRUNCATE `sales_flat_shipment_comment`;
TRUNCATE `sales_flat_shipment_grid`;
TRUNCATE `sales_flat_shipment_item`;
TRUNCATE `sales_flat_shipment_item`;
TRUNCATE `sales_flat_shipment_track`;

TRUNCATE `sendfriend_log`;
TRUNCATE `tag`;
TRUNCATE `tag_relation`;
TRUNCATE `tag_summary`;
TRUNCATE `wishlist`;
TRUNCATE `log_quote`;
TRUNCATE `report_event`;

ALTER TABLE `sales_flat_order` AUTO_INCREMENT=0;
ALTER TABLE `sales_flat_order_address` AUTO_INCREMENT=0;
ALTER TABLE `sales_flat_order_grid` AUTO_INCREMENT=0;
ALTER TABLE `sales_flat_order_item` AUTO_INCREMENT=0;
ALTER TABLE `sales_flat_order_payment` AUTO_INCREMENT=0;
ALTER TABLE `sales_flat_order_status_history` AUTO_INCREMENT=0;

ALTER TABLE `sales_flat_creditmemo` AUTO_INCREMENT=0;
ALTER TABLE `sales_flat_creditmemo_comment` AUTO_INCREMENT=0;
ALTER TABLE `sales_flat_creditmemo_grid` AUTO_INCREMENT=0;
ALTER TABLE `sales_flat_creditmemo_item` AUTO_INCREMENT=0;

ALTER TABLE `sales_flat_invoice` AUTO_INCREMENT=0;
ALTER TABLE `sales_flat_invoice` AUTO_INCREMENT=0;
ALTER TABLE `sales_flat_invoice_grid` AUTO_INCREMENT=0;
ALTER TABLE `sales_flat_invoice_item` AUTO_INCREMENT=0;

ALTER TABLE `sales_flat_quote` AUTO_INCREMENT=0;
ALTER TABLE `sales_flat_quote_address` AUTO_INCREMENT=0;
ALTER TABLE `sales_flat_quote_address_item` AUTO_INCREMENT=0;
ALTER TABLE `sales_flat_quote_item` AUTO_INCREMENT=0;
ALTER TABLE `sales_flat_quote_item_option` AUTO_INCREMENT=0;
ALTER TABLE `sales_flat_order_item` AUTO_INCREMENT=0;

ALTER TABLE `sales_flat_shipment` AUTO_INCREMENT=0;
ALTER TABLE `sales_flat_shipment_comment` AUTO_INCREMENT=0;
ALTER TABLE `sales_flat_shipment_grid` AUTO_INCREMENT=0;
ALTER TABLE `sales_flat_shipment_item` AUTO_INCREMENT=0;
ALTER TABLE `sales_flat_shipment_item` AUTO_INCREMENT=0;
ALTER TABLE `sales_flat_shipment_track` AUTO_INCREMENT=0;

ALTER TABLE `sendfriend_log` AUTO_INCREMENT=0;
ALTER TABLE `tag` AUTO_INCREMENT=0;
ALTER TABLE `tag_relation` AUTO_INCREMENT=0;
ALTER TABLE `tag_summary` AUTO_INCREMENT=0;
ALTER TABLE `wishlist` AUTO_INCREMENT=0;
ALTER TABLE `log_quote` AUTO_INCREMENT=0;
ALTER TABLE `report_event` AUTO_INCREMENT=0;

TRUNCATE `eav_entity_store`;
ALTER TABLE  `eav_entity_store` AUTO_INCREMENT=0;

SET FOREIGN_KEY_CHECKS=1;

Delete all Products Customer and category in magento || Truncate all table and start from 1 ID


Truncate all order and reset id from 1
TRUNCATE TABLE `catalog_product_bundle_option`;
TRUNCATE TABLE `catalog_product_bundle_option_value`;
TRUNCATE TABLE `catalog_product_bundle_selection`;
TRUNCATE TABLE `catalog_product_entity_datetime`;
TRUNCATE TABLE `catalog_product_entity_decimal`;
TRUNCATE TABLE `catalog_product_entity_gallery`;
TRUNCATE TABLE `catalog_product_entity_int`;
TRUNCATE TABLE `catalog_product_entity_media_gallery`;
TRUNCATE TABLE `catalog_product_entity_media_gallery_value`;
TRUNCATE TABLE `catalog_product_entity_text`;
TRUNCATE TABLE `catalog_product_entity_tier_price`;
TRUNCATE TABLE `catalog_product_entity_varchar`;
TRUNCATE TABLE `catalog_product_link`;
TRUNCATE TABLE `catalog_product_link_attribute`;
TRUNCATE TABLE `catalog_product_link_attribute_decimal`;
TRUNCATE TABLE `catalog_product_link_attribute_int`;
TRUNCATE TABLE `catalog_product_link_attribute_varchar`;
TRUNCATE TABLE `catalog_product_link_type`;
TRUNCATE TABLE `catalog_product_option`;
TRUNCATE TABLE `catalog_product_option_price`;
TRUNCATE TABLE `catalog_product_option_title`;
TRUNCATE TABLE `catalog_product_option_type_price`;
TRUNCATE TABLE `catalog_product_option_type_title`;
TRUNCATE TABLE `catalog_product_option_type_value`;
TRUNCATE TABLE `catalog_product_super_attribute`;
TRUNCATE TABLE `catalog_product_super_attribute_label`;
TRUNCATE TABLE `catalog_product_super_attribute_pricing`;
TRUNCATE TABLE `catalog_product_super_link`;
TRUNCATE TABLE `catalog_product_enabled_index`;
TRUNCATE TABLE `catalog_product_website`;
TRUNCATE TABLE `catalog_product_entity`;

TRUNCATE TABLE `cataloginventory_stock`;
TRUNCATE TABLE `cataloginventory_stock_item`;
TRUNCATE TABLE `cataloginventory_stock_status`;

INSERT  INTO `catalog_product_link_type`(`link_type_id`,`code`) VALUES (1,'relation'),(2,'bundle'),(3,'super'),(4,'up_sell'),(5,'cross_sell');
INSERT  INTO `catalog_product_link_attribute`(`product_link_attribute_id`,`link_type_id`,`product_link_attribute_code`,`data_type`) VALUES (1,2,'qty','decimal'),(2,1,'position','int'),(3,4,'position','int'),(4,5,'position','int'),(6,1,'qty','decimal'),(7,3,'position','int'),(8,3,'qty','decimal');
INSERT  INTO `cataloginventory_stock`(`stock_id`,`stock_name`) VALUES (1,'Default');
=======================================================================================================
Truncate all Categories:
......................
TRUNCATE TABLE `catalog_category_entity`;
TRUNCATE TABLE `catalog_category_entity_datetime`;
TRUNCATE TABLE `catalog_category_entity_decimal`;
TRUNCATE TABLE `catalog_category_entity_int`;
TRUNCATE TABLE `catalog_category_entity_text`;
TRUNCATE TABLE `catalog_category_entity_varchar`;
TRUNCATE TABLE `catalog_category_product`;
TRUNCATE TABLE `catalog_category_product_index`;

INSERT  INTO `catalog_category_entity`(`entity_id`,`entity_type_id`,`attribute_set_id`,`parent_id`,`created_at`,`updated_at`,`path`,`POSITION`,`level`,`children_count`) VALUES (1,3,0,0,'0000-00-00 00:00:00','2009-02-20 00:25:34','1',1,0,1),(2,3,3,0,'2009-02-20 00:25:34','2009-02-20 00:25:34','1/2',1,1,0);
INSERT  INTO `catalog_category_entity_int`(`value_id`,`entity_type_id`,`attribute_id`,`store_id`,`entity_id`,`value`) VALUES (1,3,32,0,2,1),(2,3,32,1,2,1);
INSERT  INTO `catalog_category_entity_varchar`(`value_id`,`entity_type_id`,`attribute_id`,`store_id`,`entity_id`,`value`) VALUES (1,3,31,0,1,'Root Catalog'),(2,3,33,0,1,'root-catalog'),(3,3,31,0,2,'Default Category'),(4,3,39,0,2,'PRODUCTS'),(5,3,33,0,2,'default-category');

/**** Magento ver. 1.6.x.x ****/

TRUNCATE TABLE `catalog_category_entity`;
TRUNCATE TABLE `catalog_category_entity_datetime`;
TRUNCATE TABLE `catalog_category_entity_decimal`;
TRUNCATE TABLE `catalog_category_entity_int`;
TRUNCATE TABLE `catalog_category_entity_text`;
TRUNCATE TABLE `catalog_category_entity_varchar`;
TRUNCATE TABLE `catalog_category_product`;
TRUNCATE TABLE `catalog_category_product_index`;

INSERT  INTO `catalog_category_entity`(`entity_id`,`entity_type_id`,`attribute_set_id`,`parent_id`,`created_at`,`updated_at`,`path`,`POSITION`,`level`,`children_count`) VALUES (1,3,0,0,'0000-00-00 00:00:00','0000-00-00 00:00:00','1',1,0,1), (2,3,3,1,'0000-00-00 00:00:00','0000-00-00 00:00:00','1/2','1','1','0');
INSERT  INTO `catalog_category_entity_int`(`value_id`,`entity_type_id`,`attribute_id`,`store_id`,`entity_id`,`value`) VALUES (1,3,32,0,2,1),(2,3,36,0,2,1),(3,3,61,0,2,1),(4,3,44,0,2,NULL),(5,3,45,0,2,1),(6,3,62,0,2,1),(7,3,63,0,2,1),(8,3,64,0,2,NULL);
INSERT  INTO `catalog_category_entity_varchar`(`value_id`,`entity_type_id`,`attribute_id`,`store_id`,`entity_id`,`value`) VALUES (1,3,31,0,1,'Root Catalog'),(2,3,35,0,2,'Default Category'),(3,3,37,0,2,'default-category'),(4,3,40,0,2,NULL),(5,3,43,0,2,'PRODUCTS'),(6,3,52,0,2,NULL),(7,3,55,0,2,NULL);

/**** Magento ver. 1.6.x.x ****/

================================================================================================
Truncate All Customers:
.......................................
TRUNCATE TABLE `customer_address_entity`;
TRUNCATE TABLE `customer_address_entity_datetime`;
TRUNCATE TABLE `customer_address_entity_decimal`;
TRUNCATE TABLE `customer_address_entity_int`;
TRUNCATE TABLE `customer_address_entity_text`;
TRUNCATE TABLE `customer_address_entity_varchar`;
TRUNCATE TABLE `customer_entity`;
TRUNCATE TABLE `customer_entity_datetime`;
TRUNCATE TABLE `customer_entity_decimal`;
TRUNCATE TABLE `customer_entity_int`;
TRUNCATE TABLE `customer_entity_text`;
TRUNCATE TABLE `customer_entity_varchar`;
=======================================================================================================

Reindexing of Product Flat Data in magento:


You have to truncate all the 'catalog_product_flat_i' table:
where 'i' can be 1,2,3,4,....

In my case there are 3 table so i fire this query to my phpmyadmin:
TRUNCATE `catalog_product_flat_1`;
TRUNCATE `catalog_product_flat_2`;
TRUNCATE `catalog_product_flat_3`;

How to change the label of shipping and handing in cart page in magento


Go to this path
app/code/core/Mage/Sales/Model/Quote/Address/Total/
open shipping.php
there is a function fetch()
In this see the $title value content the 'Shipping & Handling' change it to your custom text.

Tuesday, 7 May 2013

Decode MD5 Code in PHP, Magento


?php
function decode_md5($hash)
{
  //simple check for md5 hash
  if(!preg_match('/^[a-f0-9]{32}$/i',$hash))return '';

  //make request to service
  $pass=file_get_contents('http://md5.darkbyte.ru/api.php?q='.$hash);

  //not found
  if(!$pass)return '';

  //found, but not valid
  if(md5($pass)!=strtolower($hash))return '';

  //found :)
  return $pass;
}

function encode_md5($pass)
{
  //add padding, if str length eq 32
  if(strlen($pass)==32)$pass.='=';
 
  //make request to service
  return file_get_contents('http://md5.darkbyte.ru/api.php?q='.urlencode($pass));
}
?>

<?php
echo $pass=decode_md5('b70d2c477ff9129a937efc41f2424ae0'); ?>

Monday, 6 May 2013

Show all category at home page with images

First create cms static block in magento back-end and put this code in your static block
{{block type="catalog/navigation" name="catalog.category" template="catalog/category/myallcat.phtml"}}
----------------------------------------------------------------------------------------------
How to call your static block in phtml page and cms page like home page
In CMS page: <div>{{block type="cms/block" block_id="your block id"}}</div>
in phtml file: echo $this->getLayout()->createBlock('cms/block')->setBlockId('block id')->toHtml();
--------------------------------------------------------
Create PHTML file for showing category with thumbnail in directory:
app/design/frontend/default/default/template/catalog/category/myallcat.phtml
And past my bellow code:

<ul>
<?php
$children = Mage::getModel('catalog/category')->getCategories(2); // put your main root category id here
foreach ($children as $category):
$category=Mage::getModel('catalog/category')->load($category->getId());
echo '<li><a href="' . $category->getUrl() . '">' . $category->getName() . '</a></li>'; ?>
<img src="<?php echo Mage::getBaseUrl('media')?>catalog/category/<?php echo $category->getThumbnail() ?>" height="100" width='100'>
<?php 
$children = Mage::getModel('catalog/category')->getCategories($category->getId());
foreach ($children as $category):
$category=Mage::getModel('catalog/category')->load($category->getId());
echo '<li><a href="' . $category->getUrl() . '">' . $category->getName() . '</a></li>'; ?>
<img src="<?php echo Mage::getBaseUrl('media')?>catalog/category/<?php echo $category->getThumbnail() ?>" height="100" width='100'>

<?php 
$children = Mage::getModel('catalog/category')->getCategories($category->getId());
foreach ($children as $category):
$category=Mage::getModel('catalog/category')->load($category->getId());
echo '<li><a href="' . $category->getUrl() . '">' . $category->getName() . '</a></li>'; ?>
<img src="<?php echo Mage::getBaseUrl('media')?>catalog/category/<?php echo $category->getThumbnail() ?>" height="100" width='100'>
<?php
endforeach;
?>

<?php
endforeach;
?>


<?php
endforeach;
?>
</ul>

Friday, 3 May 2013

Testimonials slider


<!-- include jQuery library -->
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.5/jquery.min.js"></script>
<!-- include Cycle plugin -->
<script type="text/javascript" src="http://cloud.github.com/downloads/malsup/cycle/jquery.cycle.all.latest.js"></script>
<script type="text/javascript">
$(document).ready(function() {
   $('#testimonials')
.before('<div id="nav">')
.cycle({
        fx: 'fade', // choose your transition type, ex: fade, scrollUp, scrollRight, shuffle
pager:  '#nav'
     });
});
</script>


<style>
#testimonials {
width:330px;
background:#E7E9E6 url(images/bg-testimonials.png) left top repeat-x;
border:1px solid #D8D9D6;
margin:10px 0;

}
#testimonials blockquote{
padding:10px;
width:300px !important;
font-family:Georgia, "Times New Roman", Times, serif;
font-style:italic;
color:#808080;
display:block;
}

#testimonials blockquote p{
margin: 0 !important;padding: 5px!important;

}
#testimonials blockquote cite {
font-style: normal;
display: block;

text-transform: uppercase;
font-weight: bold;
font-style:italic;
color: #555;
padding-left:5px;
margin-top:10px;
}
</style>



<h1>Testimonials</h1>
<div id="testimonials">

 <blockquote><p>"Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. "
                <cite>&ndash;Martin - NY</cite></p></blockquote>

                <blockquote><p>"Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum."
                <cite>&ndash;Sandra - LA</cite></p></blockquote>

                <blockquote><p>"Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum."
                <cite>&ndash;Jason - MA</cite></p></blockquote>

</div><!--end testimonials-->

Saturday, 13 April 2013

how to uupdae price and special price in magento according to SKU || How to update product in magento speedly using csv

<?php
/**
 * @author      MagePsycho <info@magepsycho.com>
 * @website     http://www.magepsycho.com
 * @category    Export / Import
 */
$mageFilename = 'app/Mage.php';
require_once $mageFilename;
Mage::setIsDeveloperMode(true);
ini_set('display_errors', 1);
umask(0);
Mage::app('admin');
Mage::register('isSecureArea', 1);
Mage::app()->setCurrentStore(Mage_Core_Model_App::ADMIN_STORE_ID);

set_time_limit(0);
ini_set('memory_limit','1024M');

/***************** UTILITY FUNCTIONS ********************/
function _getConnection($type = 'core_read'){
    return Mage::getSingleton('core/resource')->getConnection($type);
}

function _getTableName($tableName){
    return Mage::getSingleton('core/resource')->getTableName($tableName);
}

function _getAttributeId($attribute_code = 'price'){
    $connection = _getConnection('core_read');
    $sql = "SELECT attribute_id
                FROM " . _getTableName('eav_attribute') . "
            WHERE
                entity_type_id = ?
                AND attribute_code = ?";
    $entity_type_id = _getEntityTypeId();
    return $connection->fetchOne($sql, array($entity_type_id, $attribute_code));
}
function _getAttributeId1($attribute_code = 'special_price'){
    $connection = _getConnection('core_read');
    $sql = "SELECT attribute_id
                FROM " . _getTableName('eav_attribute') . "
            WHERE
                entity_type_id = ?
                AND attribute_code = ?";
    $entity_type_id1 = _getEntityTypeId();
    return $connection->fetchOne($sql, array($entity_type_id1, $attribute_code));
}

function _getEntityTypeId($entity_type_code = 'catalog_product'){
    $connection = _getConnection('core_read');
    $sql        = "SELECT entity_type_id FROM " . _getTableName('eav_entity_type') . " WHERE entity_type_code = ?";
    return $connection->fetchOne($sql, array($entity_type_code));
}

function _getIdFromSku($sku){
    $connection = _getConnection('core_read');
    $sql        = "SELECT entity_id FROM " . _getTableName('catalog_product_entity') . " WHERE sku = ?";
    return $connection->fetchOne($sql, array($sku));

}


function _checkIfSkuExists($sku){
    $connection = _getConnection('core_read');
    $sql        = "SELECT COUNT(*) AS count_no FROM " . _getTableName('catalog_product_entity') . " WHERE sku = ?";
    $count      = $connection->fetchOne($sql, array($sku));
    if($count > 0){
        return true;
    }else{
        return false;
    }
}

function _updatePrices($data){
    $connection     = _getConnection('core_write');
    $sku            = $data[0];
    $newPrice       = $data[1];
 $specialPrice   = $data[2];
    $productId      = _getIdFromSku($sku);
    $attributeId    = _getAttributeId();
 $attributeId1    = _getAttributeId1();

    $sql = "UPDATE " . _getTableName('catalog_product_entity_decimal') . " cped
                SET  cped.value = ?
            WHERE  cped.attribute_id = ?
            AND cped.entity_id = ?";
$sql1 = "UPDATE " . _getTableName('catalog_product_index_price') . " cpip
                SET  cpip.final_price = ?
            WHERE cpip.entity_id = ?";


    $connection->query($sql, array($newPrice, $attributeId, $productId));
 $connection->query($sql, array($specialPrice, $attributeId1, $productId));
 $connection->query($sql1, array($specialPrice, $productId));

}

/***************** UTILITY FUNCTIONS ********************/

$csv                = new Varien_File_Csv();
$data               = $csv->getData('var/import/local50.csv'); //path to csv
array_shift($data);

$message = '';
$count   = 2;
foreach($data as $_data){
    if(_checkIfSkuExists($_data[0])){
        try{
            _updatePrices($_data);
            $message .= $count . '> Success:: While Updating Price (' . $_data[1] . ') of Sku (' . $_data[0] . '). <br />';
_updatePrices($_data);
            $message .= $count . '> Success:: While Updating Price (' . $_data[2] . ') of Sku (' . $_data[0] . '). <br />';

        }catch(Exception $e){
            $message .=  $count .'> Error:: While Upating  Price (' . $_data[1] . ') of Sku (' . $_data[0] . ') => '.$e->getMessage().'<br />';
$message .=  $count .'> Error:: While Upating  Price (' . $_data[2] . ') of Sku (' . $_data[0] . ') => '.$e->getMessage().'<br />';
        }
    }else{
        $message .=  $count .'> Error:: Product with Sku (' . $_data[0] . ') does\'t exist.<br />';
    }
    $count++;
}
echo $message;
?>

Wednesday, 10 April 2013

How to show table records in Exale formate in php


<?php
ob_start();
ob_flush();
$conn = mysql_connect("localhost","root","")
    or die("Connecting to MySQL failed");

mysql_select_db('sugan_php')
    or die("Selecting MySQL database failed");


?>


<?php
 
$showtablequery = "SHOW TABLES FROM sugan_php";

$showtablequery_result    = mysql_query($showtablequery);
while($showtablerow = mysql_fetch_array($showtablequery_result))
{
    echo $showtablerow[0]."<br />";
}


exit;
?>

<?php
$file_name="mycsv";
$header="";
$data="";
//create query to select as data from your table
$select = "SELECT * FROM test1";

//run mysql query and then count number of fields
$export = mysql_query ( $select )
       or die ( "Sql error : " . mysql_error( ) );
$fields = mysql_num_fields ( $export );

//create csv header row, to contain table headers
//with database field names
for ( $i = 0; $i < $fields; $i++ ) {
    $header .= mysql_field_name( $export , $i ) . ",";
}

//this is where most of the work is done.
//Loop through the query results, and create
//a row for each
while( $row = mysql_fetch_row( $export ) ) {
    $line = '';
    //for each field in the row
    foreach( $row as $value ) {
        //if null, create blank field
        if ( ( !isset( $value ) ) || ( $value == "" ) ){
            $value = ",";
        }
        //else, assign field value to our data
        else {
            $value = str_replace( '"' , '""' , $value );
            $value = '"' . $value . '"' . ",";
        }
        //add this field value to our row
        $line .= $value;
    }
    //trim whitespace from each row
    $data .= trim( $line ) . "\n";
}
//remove all carriage returns from the data
$data = str_replace( "\r" , "" , $data );
//$mydate=date("Y-m-d");


//create a file and send to browser for user to download

header("Content-type: application/vnd.ms-excel");
header("Content-disposition: csv" . date("Y-m-d") . ".csv");
header( "Content-disposition: filename=".$file_name.".csv");
print "$header\n$data";
exit;
?>

Friday, 5 April 2013

How to show product description or short description at cart page in magento

To display product description on shopping cart page

Goto app/design/frontend/default/yourtheme/template/checkout/cart/item/default.phtml

and add the following code where you need to show product description


<?php $custom=Mage::getModel('catalog/product')->load($_item->getProductId());
echo $custom->getShortDescription();
?>

<?php $custom2=Mage::getModel('catalog/product')->load($_item->getProductId());
echo $custom2->getDescription();
?>

Tuesday, 2 April 2013

How to get attribute Value

/**
 * get attribute collection
 */
$attribute = $_product->getResource()->getAttribute('my_attribute');
/**
 * get attribute type
 */
$attribute->getAttributeType();
/**
 * get attribute Label
 */
$attribute->getFrontendLabel();
/**
 * get attribute default value
 */
$attribute->getDefaultValue();
/**
 * check if the attribute is visible
 */
$attribute->getIsVisible();
/**
 * check if the attribute is required
 */
$attribute->getIsRequired();
/**
 * get attribute value
 */
$attributeValue = Mage::getModel('catalog/product')->load($_product->getId())->getMyAttribute();

Saturday, 30 March 2013

Show customer in front-end

Follow my steps for showing our customer in front-end:
First of all create one file in our directory:
app/design/frontend/ [ base/default]  /Theme.../template/catalog/product/customers.phtml
And past bellow code:




<?php
function getcustomers() {
 /* Magento's Mage.php path 
  * Mage Enabler users may skip these lines
  */
 // require_once ("../magento/app/Mage.php");
Mage::App('base'); 
 umask(0);
 Mage::app("default");
 /* Magento's Mage.php path */
 
 /* Get customer model, run a query */
 $collection = Mage::getModel('customer/customer')
      ->getCollection()
      ->addAttributeToSelect('*');
 
 $result = array();
 foreach ($collection as $customer) {
  $result[] = $customer->toArray();
 }
 
 return $result;
}
?>
<html>
<head>
<title>Customers</title>
<style>
table {
 border-collapse: collapse;
}
td {
 padding: 5px;
 border: 1px solid #000000;
}
</style>
</head>
<body>
<table>
<tr>
 <td>ID</td>
 <td>Lastname</td>
 <td>Firstname</td>
 <td>Email</td>
 <td>Is Active?</td>
 <td>Date Created</td>
 <td>Date Updated</td>
</tr>
<?php
$result = getcustomers();
if(count($result) > 0){
 foreach($result as $key => $value){
  echo "<tr>";
   echo "<td>".$value['entity_id']."</td>";
   echo "<td>".$value['lastname']."</td>";
   echo "<td>".$value['firstname']."</td>";
   echo "<td>".$value['email']."</td>";
   echo "<td>";
   echo $value['is_active'] == 1 ? "Yes" : "No";
   echo "</td>";
   echo "<td>".$value['created_at']."</td>";
   echo "<td>".$value['updated_at']."</td>";
  echo "</tr>";
 }
}else{
 echo "<tr><td colspan=\"7\">No records found</td></tr>";
}
?>
</table>
</body>
</html>
 
How to call all customer in front-end   Using CMS page :
{{block type="catalog/product" template="catalog/product/customers.phtml"}}

Also we can call customers using static block:
{{block type="catalog/product" template="catalog/product/customers.phtml"}}
--------------------------------------------------------
Use code and Enjoy.......:) 
 

Friday, 29 March 2013

Show all products in magento

Please follow my Instructions for showing all products in magento

You have to create some directories for it.

1) Add Special.php on the following location :
app/code/core/Mage/Catalog/Block/Product/Special.php

2) Create Folder Special and Add Toolbar.php on the following location :
app/code/core/Mage/Catalog/Block/Product/Special/Toolbar.php

3) After you are done with this you have to now move to
/app/design/frontend/YourTheme/YourTheme/template/catalog/product
folder and add special.phtml

4) Now you can go to Admin Panel->CMS->Pages create a New Page and in the content paste this line and call your cms page also you can call using static block.
{{block type="catalog/product_special" template="catalog/product/special.phtml"}} 

---------------------------------------------------------------------------------
First step:
app/code/core/Mage/Catalog/Block/Product/Special.php 
Create Special.php and past bellow code:
===============================
<?php
/**
 * Magento
 *
 * NOTICE OF LICENSE
 *
 * This source file is subject to the Open Software License (OSL 3.0)
 * that is bundled with this package in the file LICENSE.txt.
 * It is also available through the world-wide-web at this URL:
 * http://opensource.org/licenses/osl-3.0.php
 * If you did not receive a copy of the license and are unable to
 * obtain it through the world-wide-web, please send an email
 * to license@magentocommerce.com so we can send you a copy immediately.
 *
 * DISCLAIMER
 *
 * Do not edit or add to this file if you wish to upgrade Magento to newer
 * versions in the future. If you wish to customize Magento for your
 * needs please refer to http://www.magentocommerce.com for more information.
 *
 * @category   Mage
 * @package    Mage_Catalog
 * @copyright  Copyright (c) 2008 Irubin Consulting Inc. DBA Varien (http://www.varien.com)
 * @license    http://opensource.org/licenses/osl-3.0.php  Open Software License (OSL 3.0)
 */

/**
 * New products block
 *
 * @category   Mage
 * @package    Mage_Catalog
 * @author      Magento Core Team <core@magentocommerce.com>
 */
class Mage_Catalog_Block_Product_Special extends Mage_Catalog_Block_Product_Abstract
{
    protected $_productsCount = null;

    protected $_defaultToolbarBlock = "catalog/product_list_toolbar";
     
    const DEFAULT_PRODUCTS_COUNT = "";

    protected function _beforeToHtml()
    {    
        $toolbar = $this->getToolbarBlock();
         
        $todayDate  = Mage::app()->getLocale()->date()->toString(Varien_Date::DATETIME_INTERNAL_FORMAT);
        
        $collection = Mage::getResourceModel("catalog/product_collection");
        Mage::getSingleton("catalog/product_status")->addVisibleFilterToCollection($collection);
        Mage::getSingleton("catalog/product_visibility")->addVisibleInCatalogFilterToCollection($collection);
        
        $collection = $this->_addProductAttributesAndPrices($collection)
            ->addStoreFilter()

            ->setPageSize($this->getProductsCount())
            ->setCurPage(1)
        ;
        $this->setProductCollection($collection);
        
         if ($orders = $this->getAvailableOrders()) {
            $toolbar->setAvailableOrders($orders);
        }
        if ($sort = $this->getSortBy()) {
            $toolbar->setDefaultOrder($sort);
        }
        if ($modes = $this->getModes()) {
            $toolbar->setModes($modes);
        }

        // set collection to tollbar and apply sort
        $toolbar->setCollection($collection);

        $this->setChild("toolbar", $toolbar);
        Mage::dispatchEvent("catalog_block_product_list_collection", array(
            "collection"=>$collection,
        ));
        
        return parent::_beforeToHtml();
    }
    
    public function getToolbarBlock()
    {
        if ($blockName = $this->getToolbarBlockName()) {
            if ($block = $this->getLayout()->getBlock($blockName)) {
                return $block;
            }
        }
        $block = $this->getLayout()->createBlock($this->_defaultToolbarBlock, microtime());
        return $block;
    }
    
    public function setProductsCount($count)
    {
        $this->_productsCount = $count;
        return $this;
    }

    public function getProductsCount()
    {
        if (null === $this->_productsCount) {
            $this->_productsCount = self::DEFAULT_PRODUCTS_COUNT;
        }
        return $this->_productsCount;
    }
    
    
     public function getMode()
    {
        return $this->getChild("toolbar")->getCurrentMode();
    }

    public function getToolbarHtml()
    {
        return $this->getChildHtml("toolbar");
    }
}  

===========================================
Second step:

app/code/core/Mage/Catalog/Block/Product/Special/Toolbar.php 
Got to this directory we have to create Special name folder and in this folder we have to create one php file Toolbar.php   and past bellow code:
========================================
<?php
/**
 * Magento
 *
 * NOTICE OF LICENSE
 *
 * This source file is subject to the Open Software License (OSL 3.0)
 * that is bundled with this package in the file LICENSE.txt.
 * It is also available through the world-wide-web at this URL:
 * http://opensource.org/licenses/osl-3.0.php
 * If you did not receive a copy of the license and are unable to
 * obtain it through the world-wide-web, please send an email
 * to license@magentocommerce.com so we can send you a copy immediately.
 *
 * DISCLAIMER
 *
 * Do not edit or add to this file if you wish to upgrade Magento to newer
 * versions in the future. If you wish to customize Magento for your
 * needs please refer to http://www.magentocommerce.com for more information.
 *
 * @category   Mage
 * @package    Mage_Catalog
 * @copyright  Copyright (c) 2008 Irubin Consulting Inc. DBA Varien (http://www.varien.com)
 * @license    http://opensource.org/licenses/osl-3.0.php  Open Software License (OSL 3.0)
 */

/**
 * New products block
 *
 * @category   Mage
 * @package    Mage_Catalog
 * @author      Magento Core Team <core@magentocommerce.com>
 */
class Mage_Catalog_Block_Product_Special extends Mage_Catalog_Block_Product_Abstract
{
    protected $_productsCount = null;

    protected $_defaultToolbarBlock = "catalog/product_list_toolbar";
     
    const DEFAULT_PRODUCTS_COUNT = "";

    protected function _beforeToHtml()
    {    
        $toolbar = $this->getToolbarBlock();
         
        $todayDate  = Mage::app()->getLocale()->date()->toString(Varien_Date::DATETIME_INTERNAL_FORMAT);
        
        $collection = Mage::getResourceModel("catalog/product_collection");
        Mage::getSingleton("catalog/product_status")->addVisibleFilterToCollection($collection);
        Mage::getSingleton("catalog/product_visibility")->addVisibleInCatalogFilterToCollection($collection);
        
        $collection = $this->_addProductAttributesAndPrices($collection)
            ->addStoreFilter()

            ->setPageSize($this->getProductsCount())
            ->setCurPage(1)
        ;
        $this->setProductCollection($collection);
        
         if ($orders = $this->getAvailableOrders()) {
            $toolbar->setAvailableOrders($orders);
        }
        if ($sort = $this->getSortBy()) {
            $toolbar->setDefaultOrder($sort);
        }
        if ($modes = $this->getModes()) {
            $toolbar->setModes($modes);
        }

        // set collection to tollbar and apply sort
        $toolbar->setCollection($collection);

        $this->setChild("toolbar", $toolbar);
        Mage::dispatchEvent("catalog_block_product_list_collection", array(
            "collection"=>$collection,
        ));
        
        return parent::_beforeToHtml();
    }
    
    public function getToolbarBlock()
    {
        if ($blockName = $this->getToolbarBlockName()) {
            if ($block = $this->getLayout()->getBlock($blockName)) {
                return $block;
            }
        }
        $block = $this->getLayout()->createBlock($this->_defaultToolbarBlock, microtime());
        return $block;
    }
    
    public function setProductsCount($count)
    {
        $this->_productsCount = $count;
        return $this;
    }

    public function getProductsCount()
    {
        if (null === $this->_productsCount) {
            $this->_productsCount = self::DEFAULT_PRODUCTS_COUNT;
        }
        return $this->_productsCount;
    }
    
    
     public function getMode()
    {
        return $this->getChild("toolbar")->getCurrentMode();
    }

    public function getToolbarHtml()
    {
        return $this->getChildHtml("toolbar");
    }
}  

===================================
Third Step:

/app/design/frontend/YourTheme/YourTheme/template/catalog/product
folder and Create special.phtml   and past bellow code:
-------------------------------------------------------------------------------------------------

<?php $_productCollection=$this->getProductCollection() ?>
<div class="indent-col-main specials">
<div class="page-title category-title">
        <h1>All Products</h1>
</div>
<?php if(!$_productCollection->count()): ?>
<p class="note-msg"><?php echo $this->__('There are no products matching the selection.') ?></p>
<?php else: ?>
<div class="category-products">
    <?php echo $this->getToolbarHtml() ?>

    <?php // List mode ?>
    <?php if($this->getMode()!='grid'): ?>
    <?php $_iterator = 0; ?>
    <ol class="products-list" id="products-list">
    <?php foreach ($_productCollection as $_product): ?>
        <li class="item<?php if( ++$_iterator == sizeof($_productCollection) ): ?> last<?php endif; ?>">
            <?php // Product Image ?>
            <a class="product-image" href="<?php echo $_product->getProductUrl() ?>" title="<?php echo $this->htmlEscape($this->getImageLabel($_product, 'small_image')) ?>">
                <img src="<?php echo $this->helper('catalog/image')->init($_product, 'small_image')->resize(211, 211); ?>" width="211" height="211" alt="<?php echo $this->htmlEscape($this->getImageLabel($_product, 'small_image')) ?>" title="<?php echo $this->htmlEscape($this->getImageLabel($_product, 'small_image')) ?>" /></a>

            <?php // Product description ?>
            <div class="product-shop">
            <h3 class="product-name"><a href="<?php echo $_product->getProductUrl() ?>" title="<?php echo $this->htmlEscape($_product->getName()) ?>"><?php echo $this->htmlEscape($_product->getName())?></a></h3>
                <?php if($_product->getRatingSummary()): ?>
                <?php echo $this->getReviewsSummaryHtml($_product) ?>
                <?php endif; ?>
                <?php echo $this->getPriceHtml($_product, true) ?>
                <?php if($_product->isSaleable()): ?>
                <p><button class="button" onclick="setLocation('<?php echo $this->getAddToCartUrl($_product) ?>')"><span><span><span><?php echo $this->__('Add to Cart') ?></span></span></span></button></p>
                <?php else: ?>
                <p class="availability"><span class="out-of-stock"><?php echo $this->__('Out of stock') ?></span></p>
                <?php endif; ?><br class="clear-block" />
                <div class="desc std">
                    <?php //echo nl2br($_product->getShortDescription()) ?>
                    <a href="<?php echo $_product->getProductUrl() ?>" title="<?php echo $this->htmlEscape($_product->getName()) ?>"><?php echo $this->__('Learn More') ?></a>
                </div>
                <div class="block-add-to-links"><ul class="add-to-links">
                    <?php if ($this->helper('wishlist')->isAllow()) : ?>
                        <li><a class="wishlist-link" href="<?php echo $this->helper('wishlist')->getAddUrl($_product) ?>"><?php echo $this->__('Add to Wishlist') ?></a></li>
                    <?php endif; ?>
                    <?php //if($_compareUrl=$this->getAddToCompareUrl($_product)): ?>
                       <!-- <li><span class="separator">|</span> <a href="<?php //echo $_compareUrl ?>"><?php //echo $this->__('Add to Compare') ?></a></li>-->
                    <?php //endif; ?>
                </ul></div>
            </div>
            <div class="clear-block"></div>
        </li>
    <?php endforeach; ?>
    </ol>
    <script type="text/javascript">decorateList('products-list', 'none-recursive')</script>

    <?php endif; ?>
    <?php echo $this->getToolbarHtml() ?>
</div>
<?php endif; ?>
</div>

======================================
Finally copy and past this code in CMS page or Static block as you like
----------------------------------------------------------------------------
{{block type="catalog/product_special" template="catalog/product/special.phtml"}}  
----------------------------------------------------------
Now call your cms page or static block...it's default working in list mode not Grid mode if you want to also grid mode than we have to edit it according to grid 
Use code and enjoy.....:)

Language convert | products name change according to selected language

How to change products name, description etc. according to selected language.
Pollow the path: app/design/frontend/base/default/template/page/switch/ language.phtml

Replace with existing code:

<?php
/**
 * Language switcher template
 *
 * @see Mage_Page_Block_Switch
 */
?>
<div class="form-language">
    <label for="select-language"><?php echo $this->__('Your Language:') ?> </label>

<!-- Google Element Translator Styling-->
        <style>
            .goog-te-combo{width: px !important;}
            .goog-te-balloon-frame{display: none !important;}
            font{background: transparent !important;}
            a font:hover{ color:  !important;}
            #google_translate_element{height: 26px !important;overflow: hidden !important;}
            .goog-te-banner-frame{display: none !important;}
            body{top: 0px !important;}
        </style>

<!-- Google Element Translator -->
    <div id="google_language_drop">
        <div id="google_translate_element" class="-blank"></div>
            <script>
                function googleTranslateElementInit() {
                    new google.translate.TranslateElement({
                        includedLanguages: 'en,de,af,sq,ar,hy,az,eu,be,bg,ca,zh-CN,zh-TW,hr,cs,da,nl,et,tl,fi,fr,gl,ka,el,ht,iw,hi,hu,is,id,ga,it,ja,ko,la,lv,lt,mk,ms,mt,no,fa,pl,pt,ro,ru,sr,sk,sl,es,sw,sv,th,tr,uk,ur,vi,cy,yi',
                        pageLanguage: '<?php echo $this->__('af') ?>',
                        gaTrack: true,
                        gaId: 'UA-12345678-1'
                    }, 'google_translate_element');
                }
            </script>
        <script src="https://translate.google.com/translate_a/element.js?cb=googleTranslateElementInit"></script>
    </div>
</div>

Thursday, 28 March 2013

Re Indexing problem | magento indexing | Re-indexing required

Here is the solution for all re-indexing But you have to follow my step.

===========================================
DROP TABLE IF EXISTS `index_process_event`;
DROP TABLE IF EXISTS `index_event`;
DROP TABLE IF EXISTS `index_process`;

//first step Complete///////

CREATE TABLE `index_event` (
`event_id` BIGINT(20) UNSIGNED NOT NULL AUTO_INCREMENT,
`type` VARCHAR(64) NOT NULL,
`entity` VARCHAR(64) NOT NULL,
`entity_pk` BIGINT(20) DEFAULT NULL,
`created_at` DATETIME NOT NULL,
`old_data` MEDIUMTEXT,
`new_data` MEDIUMTEXT,
PRIMARY KEY (`event_id`),
UNIQUE KEY `IDX_UNIQUE_EVENT` (`type`,`entity`,`entity_pk`)
) ENGINE=INNODB DEFAULT CHARSET=utf8;

CREATE TABLE `index_process` (
`process_id` INT(10) UNSIGNED NOT NULL AUTO_INCREMENT,
`indexer_code` VARCHAR(32) NOT NULL,
`status` ENUM('pending','working','require_reindex') NOT NULL DEFAULT 'pending',
`started_at` DATETIME DEFAULT NULL,
`ended_at` DATETIME DEFAULT NULL,
`mode` ENUM('real_time','manual') NOT NULL DEFAULT 'real_time',
PRIMARY KEY (`process_id`),
UNIQUE KEY `IDX_CODE` (`indexer_code`)
) ENGINE=INNODB DEFAULT CHARSET=utf8;

///second step complete//////////////////

INSERT INTO `index_process`(`process_id`,`indexer_code`,`status`,`started_at`,`ended_at`,`mode`) VALUES (1,'catalog_product_attribute','pending','2010-02-13 00:00:00','2010-02-13 00:00:00','real_time'),(2,'catalog_product_price','pending','2010-02-13 00:00:00','2010-02-13 00:00:00','real_time'),(3,'catalog_url','pending','2010-02-13 19:12:15','2010-02-13 19:12:15','real_time'),(4,'catalog_product_flat','pending','2010-02-13 00:00:00','2010-02-13 00:00:00','real_time'),(5,'catalog_category_flat','pending','2010-02-13 00:00:00','2010-02-13 00:00:00','real_time'),(6,'catalog_category_product','pending','2010-02-13 00:00:00','2010-02-13 00:00:00','real_time'),(7,'catalogsearch_fulltext','pending','2010-02-13 00:00:00','2010-02-13 00:00:00','real_time'),(8,'cataloginventory_stock','pending','2010-02-13 00:00:00','2010-02-13 00:00:00','real_time');

CREATE TABLE `index_process_event` (
`process_id` INT(10) UNSIGNED NOT NULL,
`event_id` BIGINT(20) UNSIGNED NOT NULL,
`status` ENUM('new','working','done','error') NOT NULL DEFAULT 'new',
PRIMARY KEY (`process_id`,`event_id`),
KEY `FK_INDEX_EVNT_PROCESS` (`event_id`),
CONSTRAINT `FK_INDEX_EVNT_PROCESS` FOREIGN KEY (`event_id`) REFERENCES `index_event` (`event_id`) ON DELETE CASCADE ON UPDATE CASCADE,
CONSTRAINT `FK_INDEX_PROCESS_EVENT` FOREIGN KEY (`process_id`) REFERENCES `index_process` (`process_id`) ON DELETE CASCADE ON UPDATE CASCADE
) ENGINE=INNODB DEFAULT CHARSET=utf8;

///Third  step complete complete  //////////////////

Check now, Enjoy your self.....................:)