Monday, 21 October 2013

Fly Add to cart javascript code


<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>Image Fly To Basket</title>
<script src="http://code.jquery.com/jquery-latest.js"> </script>
<script type="text/javascript">
$(document).ready(function(){
$("#add_to_basket1").click(function(){
var productY = "56";
var productX = "277.5";
var basketY = "91";
var basketX = "926.5";
var gotoY = "35";
var gotoX="649";
var newImageWidth= "23.66666666666667";
var newImageHeight= "44";
$("#imagepreivew1" + " img")
.clone()
.prependTo("#imagepreivew1")
.css({'position' : 'absolute'})
.animate({opacity: 0.4}, 100 )
.animate({opacity: 0.1, marginLeft: gotoX, marginTop: gotoY, width: newImageWidth, height: newImageHeight}, 1200, function() {
$(this).remove();
});
});
});
</script>
<script type="text/javascript">
$(document).ready(function(){
$("#add_to_basket2").click(function(){
var productY = "56";
var productX = "277.5";
var basketY = "91";
var basketX = "926.5";
var gotoY = "35";
var gotoX="649";
var newImageWidth= "23.66666666666667";
var newImageHeight= "44";
$("#imagepreivew2" + " img")
.clone()
.prependTo("#imagepreivew2")
.css({'position' : 'absolute'})
.animate({opacity: 0.4}, 100 )
.animate({opacity: 0.1, marginLeft: gotoX, marginTop: gotoY, width: newImageWidth, height: newImageHeight}, 1200, function() {
$(this).remove();
});
});
});
</script>
</head>
<body>
<div id="imagepreivew1"><img src="http://platinum.best-auction-software.com/public/uploaded_files/products/thumb150x150/5208e51bf1a9792.jpg" border="0" width="100" height="100" /></div>
<div id="add_to_basket1" style="background-color:#666666; color:#FFFFFF; font-weight:bold; width:90px; height:30px; vertical-align:middle; text-align:center;">Add to cart</div>
<div id="imagepreivew2"><img src="http://platinum.best-auction-software.com/public/uploaded_files/products/thumb150x150/5208e51bf1a9792.jpg" border="0" width="100" height="100" /></div>
<div id="add_to_basket2" style="background-color:#666666; color:#FFFFFF; font-weight:bold; width:90px; height:30px; vertical-align:middle; text-align:center;">Add to cart</div>
</body>
</html>


show attribute label and its value or Id in magento

<table>
<tr><td>label</td>
<td>value</td>
</tr>
<?php
$attribute = Mage::getModel('eav/config')->getAttribute('catalog_product', 'manufacturer');
foreach ($attribute->getSource()->getAllOptions(true, true) as $instance) {
?>
<tr>
<td><?php echo $instance['label']; ?></td>
<td><?php echo $instance['value']; ?></td>
</tr>
<?php
}
?>
</table>

How to show special price percentage||discount percentage in Magento


<?php
$_finalPrice = $this->helper('tax')->getPrice($_product, $_product->getFinalPrice());
$_regularPrice = $this->helper('tax')->getPrice($_product, $_product->getPrice());
if ($_regularPrice != $_finalPrice):
$getpercentage = number_format($_finalPrice / $_regularPrice * 100, 2);
$finalpercentage = 100 - $getpercentage;

echo 'SAVE '.number_format($finalpercentage, 0).'%' ;

endif;
?>

change list to any perticular category


----------for a perticular Category--------------------


<?php
//echo $this->getProductCollection()->getSelectSql();
$catagory_model = Mage::getModel('catalog/category')->load('59'); //where $category_id is the id of the category

$_products = Mage::getResourceModel('catalog/product_collection');

$_products->addCategoryFilter($catagory_model); //category filter

$_products->addAttributeToFilter('status',1); //only enabled product

$_products->addAttributeToSelect(array('name','url','small_image','special_price')); //add product attribute to be fetched

//$collection->getSelect()->order('rand()'); //uncomment to get products in random order     
$_products->addAttributeToSort('special_from_date', 'asc');
$_products->addStoreFilter();

//echo count($_products);
?>
<?php if (!empty($_products)): ?>



------------------For all product or another conditionm----------------------


<?php if (($_products = $this->getProductCollection()) && $_products->getSize()): ?>

Thursday, 3 October 2013

To export orders with shipping address in magento

Put this script to your magento root and run as: www.youdomain.com/scriptfilename.php


<?
    //
    // Magento CSV Report Script -  Unprocessed Sales Orders
    //
   
    // DATABASE CONNECTION
   
   
    $hostname_MySQLCon="host of database";
    $database_MySQLCon = "database name";
    $username_MySQLCon = "database username";
    $password_MySQLCon = "database password";

    $MySQLCon = mysql_pconnect($hostname_MySQLCon, $username_MySQLCon, $password_MySQLCon);
    $MySQLDb = mysql_select_db($database_MySQLCon, $MySQLCon);
   
    // FUNCTION AREA
   
    function get_DB_Row($query){
        $result = @mysql_query($query);
        $numresults = @mysql_num_rows($result);
       
        for ($i = 0; $i < $numresults; $i++) 
        {
            $row = @mysql_fetch_array($result);
        }
       
        return $row;
    }
   
    // Using this temporary function until I find correct way to pull country names from the database according to two digit code
    // Put in your own until a database polled solution is uncovered
   
   
   
    // INITILISATION AREA
   
    $sitename = "mysite";                  // update this to customise your filename
    $datestring = date('j-m-y');
    $filename = $sitename."-".$datestring;
    $output = "";
   
    $fieldlist = array("orderid","firstname","lastname","address","city","region","country",
    "postcode","telephone","email","itemcode","itemname","quantity","shipping_instructions");
   
    $checklist = array("country", "quantity");
   
    // FIELDLIST INSTRUCTIONS 
    // The order of the CSV fields are set here as well as the field titles
    // The field titles must correspond to a number of SQL Variables being set with the AS operator below
    // If you change the default titles be sure to also update the SQL command accordingly
    // Please note that 'country' and 'quantity' values must be processed but should still be put in your prefered sequence
   
    $numfields = sizeof($fieldlist);
   
    // *********************   NOW START BUILDING THE CSV
   
    // Create the column headers
   
    for($k =0; $k < $numfields;  $k++) { 
        $output .= $fieldlist[$k];
        if ($k < ($numfields-1)) $output .= ", ";
    }
    $output .= "\n";
   
   

    $orderquery = "SELECT * FROM sales_order";      // Query to find unprocessed orders
    $orderresult = mysql_query($orderquery);
    $numorders = @mysql_num_rows($orderresult);
   
    for($i =0; $i < $numorders; $i++) {
        $order = @mysql_fetch_array($orderresult);    // Place each order into an array for proccessing
        $orderid = $order['entity_id'];               // Grab the orderid for use in the main SQL command
       
        // The following SQL command will find all the individual items associated with this order
       
        $itemquery =     "SELECT sales_flat_order_item.order_id AS orderid,
                        sales_flat_order_item.product_type,
                        sales_flat_order_item.quote_item_id,
                        sales_flat_order_item.parent_item_id AS parentid,
                        sales_flat_order_item.sku AS itemcode,
                        sales_flat_order_item.name AS itemname,
                        sales_flat_order_item.qty_ordered AS qty_ordered,
                        sales_flat_order_item.qty_shipped AS qty_shipped,
                        sales_flat_quote_address.email AS email,
                        sales_flat_quote_address.prefix AS title,
                        sales_flat_quote_address.firstname AS firstname,
                        sales_flat_quote_address.lastname AS lastname,
                        sales_flat_quote_address.street AS address,
                        sales_flat_quote_address.city AS city,
                        sales_flat_quote_address.region AS region,
                        sales_flat_quote_address.country_id AS country,
                        sales_flat_quote_address.postcode AS postcode,
                        sales_flat_quote_address.telephone AS telephone,
                        sales_flat_quote_address.shipping_description AS shipping_instructions
                        FROM sales_flat_order_item 
                        INNER JOIN sales_flat_quote_item
                        ON sales_flat_order_item.quote_item_id = sales_flat_quote_item.item_id
                        INNER JOIN sales_flat_quote_address
                        ON sales_flat_quote_item.quote_id = sales_flat_quote_address.quote_id
                        WHERE sales_flat_order_item.order_id = $orderid
                        AND sales_flat_quote_address.address_type = 'shipping' 
                        AND sales_flat_order_item.product_type <> 'configurable'
                        AND sales_flat_order_item.qty_shipped < sales_flat_order_item.qty_ordered";
                       
        $itemresult = mysql_query($itemquery);        // Run the query
        $numitems = @mysql_num_rows($itemresult);   // Check the number of items in the order
       
        for($j =0; $j < $numitems; $j++) {
            $item = @mysql_fetch_array($itemresult); // Place the item in an array for processing
           
            // Output the order item values in the same sequence set in the fieldlist to match headers
           
            for($m =0; $m < sizeof($fieldlist); $m++) { 
               
                $fieldvalue = $fieldlist[$m];
               
                if(in_array($fieldvalue, $checklist)) {                    // check if on special processing list
               
                    if($fieldvalue == "country") $output .= getCountryName($item[$fieldvalue]);
                   
                    if($fieldvalue == "quantity") {
                        $parentid = $item['parentid'];
                        if($parentid == 'NULL') {                          // simple product sold on its own (no parent)
                            $qty_ordered = $item["qty_ordered"];
                            $qty_shipped = $item["qty_shipped"];
                        } else {                                         // simple product was part of bundle or configurable group
                                                                        // If so, use the parent quanities to calculate
                            $parentitem = get_DB_row("SELECT * FROM sales_flat_order_item WHERE item_id = $parentid");
                            $qty_ordered = $parentitem["qty_ordered"];
                            $qty_shipped = $parentitem["qty_shipped"];
                        }
                        $output .= ($qty_ordered - $qty_shipped);
                    }
                   
                } else {
                    $output .= $item[$fieldvalue];
                }
               
                if ($m < ($numfields-1)) $output .= ", ";
            }
           
            $output .= "\n";
        }
       
       
    }
   
    // Send the CSV file to the browser for download
   
    header("Content-type: text/x-csv");
    header("Content-Disposition: attachment; filename=$filename.csv");
    echo $output;
    exit;
   
?>

Thursday, 12 September 2013

YouTube important Point:

Full URL : http://www.youtube.com/watch?v=6o65X97CpZU

Videi Key : http://youtu.be/6o65X97CpZU


Image URL : http://img.youtube.com/vi/6o65X97CpZU/0.jpg



http://img.youtube.com/vi/<insert-youtube-video-id-here>/1.jpg
http://img.youtube.com/vi/<insert-youtube-video-id-here>/2.jpg
http://img.youtube.com/vi/<insert-youtube-video-id-here>/3.jpg

show custom attribute in checkout process and order email


you have to add the code in these pages:


/pedal/app/design/adminhtml/default/default/template/sales/order/view/items/renderer/default.phtml

/pedal/app/design/frontend/base/default/template/checkout/onepage/review/item.phtml


/pedal/app/design/frontend/base/default/template/checkout/cart/item/default.phtml

/pedal/app/design/frontend/base/default/template/sales/order/items/renderer/default.phtml


 For Items table (for new order emails):
/app/design/frontend/default/default/template/email/order/items/order/default.phtml

For Items table (for shipment emails):
/app/design/frontend/default/default/template/email/order/items/shipment/default.phtml

For Items table (for invoice emails):
/app/design/frontend/base/default/template/email/order/items/invoice/default.phtml

For Items table (for creditmemo emails):
/app/design/frontend/base/default/template/email/order/items/creditmemo/default.phtml



-----------code---------------------------------------

<?php $_product= Mage::getSingleton('catalog/product')->load($_item->getProductId()) ?>
<?php echo $_product->getResource()->getAttribute('info')->getFrontend()->getValue($_product); ?>

Saturday, 31 August 2013

Methods for removing jquery conflict in magento or other cms


<script>
$.noConflict();
jQuery(document).ready(function($) {});
</script>

<script type="text/javascript">
  $.noConflict(); //Use no conflict here instead of js file
  // Code that uses other library's $ can follow here.
</script>

<script type="text/javascript" >
    jQuery.noConflict();
</script >

Above are those methods which helps to solve jquery conflicts in different-2 situation.

Or If its all does not work:

Please check the front-end with rename the library file of jquery.
May be its already include with other conflict script.

Tuesday, 27 August 2013

How to overwrite magento controller in local pool


For Example you have to overwrite Mage/Contacts/controller/IndexController.php

Step 1: First you have to make a xml in app/etc/modules/
with name CompanyName_NameSpace.xml

<?xml version="1.0"?>
<config>
  <modules>
    <CompanyName_NameSpace>
      <active>true</active>
      <codePool>local</codePool>
      <version>0.1.0</version>
    </CompanyName_NameSpace>
  </modules>
</config>



Step2: You have to create the folders if not exist in
local/CompanyName/NameSpace/etc/
local/CompanyName/NameSpace/controllers/

In etc folder you have to create a config.xml file
<?xml version="1.0" encoding="utf-8"?>
<config>
    <frontend>
        <routers><!--Depending on the controllers area "frontend" or "admin" -->
            <contacts><!-- base module to rewrite -->
                <args>
                    <modules>
                         <CompanyName_NameSpace before="Mage_Contacts">Shweta_Newscontacts</CompanyName_NameSpace>
                    </modules>
                </args>
            </contacts>
        </routers>
    </frontend>
</config>




In controllers folder copy the Mage/Contacts/controller/IndexController.php file and include the lines:

include_once('Mage/Contacts/controllers/IndexController.php');
and
change the class name as:
class CompanyName_NameSpace_IndexController extends Mage_Core_Controller_Front_Action


Now apply changes in the file you wanted.
Now also, Magento take local pool file instead of core pool.

To show a perticular root category's sub categories with thumbnail images in magento


<div class="product">

<?php
$children = Mage::getModel('catalog/category')->getCategories(3);
$j=1;
?>

<ul>

<?php
foreach ($children as $category):
$category=Mage::getModel('catalog/category')->load($category->getId());
?>
<li>
<div class="new_product">
<div class="pro_detail">
<p><?php echo $category->getName() ?> </p>
</div>
<div class="pro_img"> <a href="<?php echo $category->getUrl() ?>"> <img src="<?php echo Mage::getBaseUrl('media').'catalog/category/'.$category->getThumbnail()  ?>" width="54" height="66" /> </a>
</div>



</div>
</li>
<?php if($j%4=='0') {?>
</ul>
<ul>
<?php } $j++;  endforeach;  ?>
</ul>


</ul>
</div>

Monday, 19 August 2013

how to find shipping amount| How to display shipping and handing separately


Add This lines to any where in template file.

This is for getting the full array shipping:

<?php $carriers = Mage::getStoreConfig('carriers', Mage::app()->getStore()->getId());
foreach ($carriers as $carrierCode => $carrierConfig) {

print_R($carrierConfig);

}
?>


This is for getting the flat rate shipping and handling:


  <?php $carriers = Mage::getStoreConfig('carriers', Mage::app()->getStore()->getId());
foreach ($carriers as $carrierCode => $carrierConfig) {
if($carrierConfig[model]=='shipping/carrier_flatrate') {
print_R($carrierConfig[price]);
echo "<br/>";
print_R($carrierConfig[handling_fee]);
}
}
?>

Wednesday, 7 August 2013

How to Get Current Url/media,skin,js,home url In magento


To get Current Url
<?php
$currentUrl = $this->helper('core/url')->getCurrentUrl();
?>



Get Magento Url including index.php if not rewrited.

e.g. http://www.example.com/index.php/
Mage::getBaseUrl(Mage_Core_Model_Store::URL_TYPE_LINK);


Get Magento Media Url

e.g. http://www.example.com/media/
Mage::getBaseUrl(Mage_Core_Model_Store::URL_TYPE_MEDIA);


Get Magento Skin Url

e.g. http://www.example.com/skin/
Mage::getBaseUrl(Mage_Core_Model_Store::URL_TYPE_SKIN);


Get Magento Store Url

e.g. http://www.example.com/
Mage::getBaseUrl(Mage_Core_Model_Store::URL_TYPE_WEB);



Get Magento Js Url

e.g. http://www.example.com/js/
Mage::getBaseUrl(Mage_Core_Model_Store::URL_TYPE_JS);



Get Home URL
$magento_home_url = Mage::helper('core/url')->getHomeUrl();


Get not secure Skin URL:
$image = $this->getSkinUrl('images/magento-image.jpg');



Get secure Skin URL
$image = $this->getSkinUrl('images/magento-image.jpg', array('_secure'=>true));


Magento Syntaxes to use in CMS Content.


Get SKIN URL
{{skin url='images/magento-image.jpg '}}
Get Media URL
{{media url='/magento-image.jpg'}}
Get Store URL
{{store url='magento-page.html'}}
Get Base URL
{{base url='magento-page.html'}}


Get full Skin Url inside code

e.g. http://www.example.com/skin/frontend/default/default/
Mage::app()->getLayout()->getBlock('head')->getSkinUrl();

How to exclude/Remove state from shipping in magento


Go to /app/code/core/Mage/Directory/Helper/data.php
Overwrite the default function with this

public function getRegionJson()
{
$exclude_regions = array ('AL','NJ','NY','CT','AS','AK','AA'); //this is the code of excluded state

Varien_Profiler::start('TEST: '.__METHOD__);
if (!$this->_regionJson) {
$cacheKey = 'DIRECTORY_REGIONS_JSON_STORE'.Mage::app()->getStore()->getId();
if (Mage::app()->useCache('config')) {
$json = Mage::app()->loadCache($cacheKey);
}
if (empty($json)) {
$countryIds = array();
foreach ($this->getCountryCollection() as $country) {
$countryIds[] = $country->getCountryId();
}
$collection = Mage::getModel('directory/region')->getResourceCollection()
->addCountryFilter($countryIds)
->load();
$regions = array();
foreach ($collection as $region) {

$rg = $region->getCode();

//if ($rg!=’AL’){
if(!in_array($rg, $exclude_regions)) {

if (!$region->getRegionId()) {
continue;
}
$regions[$region->getCountryId()][$region->getRegionId()] = array(
'code' => $region->getCode(),
//’name’ => $region->getName()
'name' => $this->__($region->getName())
);
}

}
$json = Mage::helper('core')->jsonEncode($regions);

if (Mage::app()->useCache('config')) {
Mage::app()->saveCache($json, $cacheKey, array('config'));
}
}
$this->_regionJson = $json;
}

Varien_Profiler::stop('TEST: '.__METHOD__);
return $this->_regionJson;
}

Monday, 15 July 2013

forget password email problem in magento

Go to app/design/frontend/default/[your_custom_theme_folder]/layout/customer.xml

Copy this at the last before: </layout>

<customer_account_resetpassword translate="label">
        <label>Reset a Password</label>
        <remove name="right"/>
        <remove name="left"/>

        <reference name="head">
            <action method="setTitle" translate="title" module="customer">
                <title>Reset a Password</title>
            </action>
        </reference>
        <reference name="root">
            <action method="setTemplate">
                <template>page/1column.phtml</template>
            </action>
            <action method="setHeaderTitle" translate="title" module="customer">
                <title>Reset a Password</title>
            </action>
        </reference>
        <reference name="content">
            <block type="customer/account_resetpassword" name="resetPassword" template="customer/form/resetforgottenpassword.phtml"/>
        </reference>
    </customer_account_resetpassword>

Thursday, 11 July 2013

Get Google feed in Magento

make a php file in your Magento root folder and this code and run that file.

Then You can find your text fine in var/export/google_base_feed.txt



<?php
    define('SAVE_FEED_LOCATION','export/google_base_feed.txt');//you can set a new folder and file if you want, don't forget to chmod the folder to 777

    // make sure we don't time out
    set_time_limit(0);   

    require_once 'app/Mage.php';
        Mage::app('default');
       
    try{
        $handle = fopen(SAVE_FEED_LOCATION, 'w');

       
        $heading = array('id','title','description','link','image_link','price','brand','product_type');
        $feed_line=implode("\t", $heading)."\r\n";
        fwrite($handle, $feed_line);
       
        //---------------------- GET THE PRODUCTS   
        $products = Mage::getModel('catalog/product')->getCollection();
        $products->addAttributeToFilter('status', 1);//enabled
        $products->addAttributeToFilter('visibility', 4);//catalog, search
        $products->addAttributeToSelect('*');
        $prodIds=$products->getAllIds();
       
        //echo 'Product filter: '.memory_get_usage(false).'<br>';
        //flush();
       
        $product = Mage::getModel('catalog/product');
       
        foreach($prodIds as $productId) {
            //echo '. ';
            //flush();
            //echo 'Loop start: '.memory_get_usage(false).'<br>';
            //flush();
   
            //$product = Mage::getModel('catalog/product');
            $product->load($productId);
           
            $product_data = array();   
            $product_data['sku']=$product->getSku();   
            $product_data['title']=$product->getName();
            $product_data['description']=$product->getDescription();
            $product_data['link']=$product->getProductUrl();
            $product_data['image_link']=Mage::getBaseUrl(Mage_Core_Model_Store::URL_TYPE_MEDIA).'catalog/product'.$product->getImage();
            $product_data['price']=$product->getPrice();
            $product_data['brand']=$product->getResource()->getAttribute('manufacturer')->getFrontend()->getValue($product);   
            $product_data['product_type']='';       
         
            //echo 'Product load: '.memory_get_usage(false).'<br>';
            //flush();       
         
            //get the product categories                   
                    foreach($product->getCategoryIds() as $_categoryId){
            $category = Mage::getModel('catalog/category')->load($_categoryId);
            $product_data['product_type'].=$category->getName().', ';
            }
            $product_data['product_type']=rtrim($product_data['product_type'],', ');       

            //echo 'Category load: '.(memory_get_usage(false)).'<br>';           
           
            //sanitize data   
            foreach($product_data as $k=>$val){
            $bad=array('"',"\r\n","\n","\r","\t");
            $good=array(""," "," "," ","");
            $product_data[$k] = '"'.str_replace($bad,$good,$val).'"';
            }
           

            $feed_line = implode("\t", $product_data)."\r\n";
            fwrite($handle, $feed_line);
            fflush($handle);
           
            //echo 'Loop end: '.memory_get_usage(false).'<br>';
            //flush();
        }

        //---------------------- WRITE THE FEED   
        fclose($handle);
       
    }
    catch(Exception $e){
        die($e->getMessage());
    }
?>

To show root category's subcategories with thumbnail image in Magento


<div class="product_boxx">
<div id="list_x">
<div class="new_pro">
<ul>
<?php

$children = Mage::getModel('catalog/category')->getCategories(2);
$i=1;
foreach ($children as $category):
$category=Mage::getModel('catalog/category')->load($category->getId());
?>


<li>
<div class="new_promain">
<div class="pro_img"> <a href="<?php echo $category->getUrl() ?>"> <img src="<?php echo Mage::getBaseUrl('media').'catalog/category/'.$category->getThumbnail()  ?>" width="100" height="100" /> </a></div>

<div class="pro_detail">
<p><?php echo $category->getName() ?> </p>
</div>


</div>
</li>


<?php if($i%6=='0') {?>
</ul>
<ul>
<?php } $i++; endforeach; ?>
</ul>
</div>
</div>
</div>

How to call Related product in static Block in Magento

{{block type="catalog/product_list_related" name="catalog.product.related" before="-" template="catalog/product/list/related.phtml"}}

Thursday, 20 June 2013

To show review form and customer review on product detail page in magento

To call the all customer review:



{{block type="review/product_view_list" name="product.info.product_additional_data" as="product_additional_data" template="review/product/view/list.phtml"}}

To call the Review Form:


{{block type="review/form" name="product.review.form" as="review_form"}}

Thursday, 13 June 2013

Add captcha in contacts us page in magento

Replace this file to your /test/app/design/frontend/base/default/template/contacts/form.phtml

 
<script type="text/javascript">
function ram_mk()
{


a=document.getElementById('tot').value;
b=document.getElementById('catcha').value;
if(a!=b)
{
document.getElementById('mk_x').style.display='';
return false;
}
}

function akk()
{
ab=Math.floor((Math.random()*10)+1);
ab1=Math.floor((Math.random()*8)+1);
var tot=ab+ab1;
document.getElementById('captcha_1').innerHTML=ab;
document.getElementById('captcha_2').innerHTML=ab1;
document.getElementById('tot').value=tot;
document.getElementById('ab').value=ab;
document.getElementById('ab1').value=ab1;

}
window.onload = akk;
</script>
<?php
/**
 * Magento
 *
 * NOTICE OF LICENSE
 *
 * This source file is subject to the Academic Free License (AFL 3.0)
 * that is bundled with this package in the file LICENSE_AFL.txt.
 * It is also available through the world-wide-web at this URL:
 * http://opensource.org/licenses/afl-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    design
 * @package     base_default
 * @copyright   Copyright (c) 2012 Magento Inc. (http://www.magentocommerce.com)
 * @license     http://opensource.org/licenses/afl-3.0.php  Academic Free License (AFL 3.0)
 */
?>
<div class="middle_a">
<?php if($_REQUEST['msg']!='') { ?>
<ul class="messages"><li class="success-msg"><ul><li><span><?php echo $_REQUEST['msg']; ?></span></li></ul></li></ul>
<?php } ?>
<div class="contact_page">
    <h3><?php echo Mage::helper('contacts')->__('got questions?') ?></h3>
<?php echo $this->getLayout()->createBlock('cms/block')->setBlockId('contact-us')->toHtml() ?>
<div class="contact_form">
<form action="http://yourdomain.com/email.php" method="post">
<input type="hidden" name="url_x" value="<?php echo $currentUrl = Mage::helper('core/url')->getCurrentUrl() ?>" />

   <table width="100%" border="0" cellspacing="0" cellpadding="10">
<tr>
       
        <td><input name='name' type='text' class="text-df" onblur="if(this.value=='') this.value='Your Name'" onfocus="if(this.value=='Your Name') this.value=''" value="Your Name" required="required"/></td>
    </tr>
     <tr>
       
        <td><input name='email' type='email' class="text-df" onblur="if(this.value=='') this.value='Email Address'" onfocus="if(this.value=='Email Address') this.value=''" value="Email Address" required="required"/></td>
    </tr>
    <tr>
        <td><textarea name="Message" class="box-df1" required="required" onblur="if(this.value=='') this.value='Message'" onfocus="if(this.value=='Message') this.value=''" value="Message" >Message</textarea>
         </td>
    </tr>
     <tr>
       
        <td><input name="catcha" id="catcha" type='text' class="text-df" onblur="if(this.value=='') this.value='Enter Sum'" onfocus="if(this.value=='Enter Sum') this.value=''" value="Enter Sum" /></td>
    </tr>
    <tr style="display:none; color:#CC0000;" id="mk_x">
    <td align="center">Captcha not match</td>
    </tr>
   
    <tr>
       
        <td>
        <table width="100%">
        <tr>
        <td id="captcha-x">
        <span id="captcha_1">8</span> + <span id="captcha_2">5</span> = ?
       
        <input type="hidden" name="tot" id="tot" value="15"  size="2"/>
        <input type="hidden" name="ab" id="ab" value="15"  size="2"/>
        <input type="hidden" name="ab1" id="ab1" value="15"  size="2"/>
        </td>
        <td align="right">
        <input type='submit' name="submit" value="Send" class="send"  onclick="return ram_mk();" />
        </td>
        </tr>
        </table>
       
        </td>
    </tr>
</table>

</div>




<!-- contact_page -->

</div>

<!-- middle_a -->
<script type="text/javascript">
//<![CDATA[
    var contactForm = new VarienForm('contactForm', true);
//]]>
</script>



and add this file with name email.php to your magento root folder:

<?php
$catcha = $_REQUEST['catcha'];
$tot =$_REQUEST['tot'];
$ab = $_REQUEST['ab'];
$ab1 = $_REQUEST['ab1'];

$total=$ab+$ab1;
if($tot=='@100as_pti')
{
print("<script>window.location='".$_REQUEST['url_x']."'</script>");
exit;

}

if($catcha!=$total)
 {
print("<script>window.location='".$_REQUEST['url_x']."'</script>");
exit;

}



if($catcha==$total)
{

$mesg = $_REQUEST['Message'];
if(stristr($mesg, 'http') === FALSE)
{
if(stristr($mesg, 'https') === FALSE)
{

$_session['success']="Your inquiry was submitted and will be responded to as soon as possible. Thank you for contacting us";
$replymsg="Your inquiry was submitted and will be responded to as soon as possible. Thank you for contacting us";
$mail_to="shweta@ptiwebtech.com";
$sub="Contact us ";

$message = "<br>Name :  ".$_REQUEST['name'];
$message .= "<br>E-mail : ".$_REQUEST['email'];
$message .= "<br>Message  :  ".$_REQUEST['Message'];



$headers = "MIME-Version: 1.0" . "\r\n";
$headers .= "Content-type:text/html;charset=iso-8859-1" . "\r\n";
$headers .="From: ".$_REQUEST['email'];

mail($mail_to,$sub,$message,$headers);
}

 }

}

 print("<script>window.location='".$_REQUEST['url_x']."?msg=$replymsg'</script>");
 ?>



NOTE: replace $mail_to="shweta@ptiwebtech.com"; to your email id.

Friday, 31 May 2013

You tube playlist call in magento/PHP

<?php
//Playlist: PLAD954BCB770DB285, remove PL from name
$playlist_id = "CKNjaTNxP2sJnqHzGXy45d203O73gPPc";
$url = "https://gdata.youtube.com/feeds/api/playlists/".$playlist_id."?v=2&alt=json";
$data = json_decode(file_get_contents($url),true);
$info = $data["feed"];
$video = $info["entry"];
$nVideo = count($video);

echo "Playlist Name: ".$info["title"]['$t'].'<br/>';
echo "Number of Videos (".$nVideo."):<br/>";
for($i=0;$i<$nVideo;$i++){
    echo "Name: ".$video[$i]['title']['$t'].'<br/>';
    echo "Link: ".$video[$i]['link'][0]['href'].'<br/>';
    echo "Image: <img src='".$video[$i]['media$group']['media$thumbnail'][1]['url']."' /><br />";
}
 ?>


after this you have to register your wbsite to this google account:

https://accounts.google.com/ServiceLogin?service=youtubepartnersyn&passive=true&nui=1&continue=http://code.google.com/apis/youtube/dashboard/gwt/index.html&followup=http://code.google.com/apis/youtube/dashboard/gwt/index.html