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); ?>