Home

Tuesday, September 26, 2017

How load PHP & Mysql data using Ajax in DataTables Server-side Processing ?

// HTML Code
<div class="alphabet">Search:
    <span class="clear active alphasearch open" id="all">All</span>
    <span>
        <span class="alphasearch" id="A">A</span>
    </span>
    <span>
        <span class="alphasearch" id="B">B</span>
    </span>
    <span>
        <span class="alphasearch" id="C">C</span>
    </span>
    <span>
        <span class="alphasearch" id="D">D</span>
    </span>
    <span>
        <span class="alphasearch" id="E">E</span>
    </span>
    <span>
        <span class="alphasearch" id="F">F</span>
    </span>
    <span>
        <span class="alphasearch" id="G">G</span>
    </span>
    <span>
        <span class="alphasearch" id="H">H</span>
    </span>
    <span>
        <span class="alphasearch" id="I">I</span>
    </span>
    <span>
        <span class="alphasearch" id="J">J</span>
    </span>
    <span>
        <span class="alphasearch" id="K">K</span>
    </span>
    <span>
        <span class="alphasearch" id="L">L</span>
    </span>
    <span>
        <span class="alphasearch" id="M">M</span>
    </span>
    <span>
        <span class="alphasearch" id="N">N</span>
    </span>
    <span>
        <span class="alphasearch" id="O">O</span>
    </span>
    <span>
        <span class="alphasearch" id="P">P</span>
    </span>
    <span>
        <span class="alphasearch" id="Q">Q</span>
    </span>
    <span>
        <span class="alphasearch" id="R">R</span>
    </span>
    <span>
        <span class="alphasearch" id="S">S</span>
    </span>
    <span>
        <span class="alphasearch" id="T">T</span>
    </span>
    <span>
        <span class="alphasearch" id="U">U</span>
    </span>
    <span>
        <span class="alphasearch" id="V">V</span>
    </span>
    <span>
        <span class="alphasearch" id="W">W</span>
    </span>
    <span>
        <span class="alphasearch" id="X">X</span>
    </span>
    <span>
        <span class="alphasearch" id="Y">Y</span>
    </span>
    <span>
        <span class="alphasearch" id="Z">Z</span>
    </span>
</div>

<div class="portlet-body">
    <table class="table table-striped table-bordered table-hover table-checkable order-column" id="enquirylist">
        <thead>
            <tr>
                <th>Quote Received</th>
                <th>Service Date</th>
                <th>First Name</th>
                <th>Last Name</th>
                <th>Phone</th>
                <th>State</th>
                <th>Move Type</th>
            </tr>
        </thead>
    </table>
</div>


<?php
// This code add in controller file
public function ajaxData() {     
    // Load here model
    $this->load->model('enquiry_model');
    if (isset($_POST)) {
    $this->enquiry_model->getAjaxData();
    }
}
?>

<?php
// This code add in model file

/* Get Ajax Data */
function getAjaxData() {
/* IF Query comes from DataTables do the following */
    if (!empty($_POST)) {
        /* echo "<pre>";
        print_r($_POST); */
        define("enquiry", "enquiry");
        define("move_type", "move_type");
        /* Useful $_POST Variables coming from the plugin */
        $draw = $_POST["draw"]; //counter used by DataTables to ensure that the Ajax returns from server-side processing requests are drawn in sequence by DataTables
        $orderByColumnIndex = $_POST['order'][0]['column']; // index of the sorting column (0 index based - i.e. 0 is the first record)

        $orderBy = $_POST['columns'][$orderByColumnIndex]['data']; //Get name of the sorting column from its index
        /* if($orderBy == 'edit_link')
          {
          $orderBy = 'enquiry_id';
          } */
        $orderType = $_POST['order'][0]['dir']; // ASC or DESC
        $start = $_POST["start"]; //Paging first record indicator.
        $length = $_POST['length']; //Number of records that the table can display in the current draw
        /* END of POST variables */

        $sql = "SELECT * FROM " . enquiry . " as e INNER JOIN " . move_type . " as m ON e.en_movetype=m.movetype_id";
        $query = $this->db->query($sql);
        $recordsTotal = $query->num_rows();

        /* SEARCH CASE : Using Alphabest Wise */

        /* */
        /* SEARCH CASE : Filtered data */
        if (!empty($_POST['search']['value'])) {



            if (!empty($_POST['alphabet']) && $_POST['alphabet'] != 'all') {
               /* WHERE Clause for searching */
                for ($i = 0; $i < count($_POST['columns']); $i++) {

                    /*if($_POST['columns'][$i]['data'] !="en_fname")
                    {*/
                        $column = $_POST['columns'][$i]['data']; //we get the name of each column using its index from POST request
                        $where[] = "$column like '%" . $_POST['search']['value'] . "%'";
                   /* }*/
                }
                $where = "WHERE ( " . implode(" OR ", $where). " )"; // id like '%searchValue%' or name like '%searchValue%' ....
                $where .= " AND ( en_fname like '" . $_POST['alphabet'] . "%' )";
                /* End WHERE */
            }else
            {
               /* WHERE Clause for searching */
                for ($i = 0; $i < count($_POST['columns']); $i++) {

                    /* if($_POST['columns'][$i]['data'] !="edit_link")
                      { */
                    $column = $_POST['columns'][$i]['data']; //we get the name of each column using its index from POST request
                    $where[] = "$column like '%" . $_POST['search']['value'] . "%'";
                    /* } */
                }
                $where = "WHERE " . implode(" OR ", $where); // id like '%searchValue%' or name like '%searchValue%' ....
                /* End WHERE */
            }

           // echo $where;die;
            $sql = sprintf("SELECT *,DATE_FORMAT(e.en_date, '%%d/%%m/%%Y %%h:%%s %%p') as en_date,DATE_FORMAT(e.en_servicedate, '%%d/%%m/%%Y') as en_servicedate FROM " . enquiry . " as e INNER JOIN " . move_type . " as m ON e.en_movetype=m.movetype_id %s", $where); //Search query without limit clause (No pagination)
            $query = $this->db->query($sql);
            $recordsFiltered = $query->num_rows(); //count(getData($sql));//Count of search result

            /* SQL Query for search with limit and orderBy clauses */
            $sql = sprintf("SELECT *,DATE_FORMAT(e.en_date, '%%d/%%m/%%Y %%h:%%s %%p') as en_date,DATE_FORMAT(e.en_servicedate, '%%d/%%m/%%Y') as en_servicedate FROM " . enquiry . " as e INNER JOIN " . move_type . " as m ON e.en_movetype=m.movetype_id %s ORDER BY %s %s limit %d , %d ", $where, $orderBy, $orderType, $start, $length);
            $query = $this->db->query($sql);
            $query = $query->result_array();

            $data = array();
            foreach ($query as $row) {
                $row['en_date'] = '<a href="/enquiriesdetails/' . $row['enquiry_id'] . '">' . $row['en_date'] . '</a>';
                $data[] = $row;
            }
        } else if (!empty($_POST['alphabet']) && $_POST['alphabet'] != 'all') {
            $where[] = "en_fname like '" . $_POST['alphabet'] . "%'";
            $where = "WHERE " . implode(" OR ", $where); // id like '%searchValue%' or name like '%searchValue%' ....
            //$sql = sprintf("SELECT *,CONCAT_WS('', 'en_fname', 'en_lname', NULL) = 'en_fname' FROM %s %s", enquiry , $where);//Search query without limit clause (No pagination)
            $sql = sprintf("SELECT *,DATE_FORMAT(e.en_date, '%%d/%%m/%%Y %%h:%%s %%p') as en_date,DATE_FORMAT(e.en_servicedate, '%%d/%%m/%%Y') as en_servicedate FROM " . enquiry . " as e INNER JOIN " . move_type . " as m ON e.en_movetype=m.movetype_id %s", $where); //Search query without limit clause (No pagination)
            $query = $this->db->query($sql);
            $recordsFiltered = $query->num_rows(); //count(getData($sql));//Count of search result

            /* SQL Query for search with limit and orderBy clauses */
            $sql = sprintf("SELECT *,DATE_FORMAT(e.en_date, '%%d/%%m/%%Y %%h:%%s %%p') as en_date,DATE_FORMAT(e.en_servicedate, '%%d/%%m/%%Y') as en_servicedate FROM " . enquiry . " as e INNER JOIN " . move_type . " as m ON e.en_movetype=m.movetype_id %s ORDER BY %s %s limit %d , %d ", $where, $orderBy, $orderType, $start, $length);
            $query = $this->db->query($sql);
            $query = $query->result_array();

            $data = array();
            foreach ($query as $row) {
                $row['en_date'] = '<a href="' . base_url('/enquiries/view/' . $row['en_unique_id']) . '">' . $row['en_date'] . '</a>';
                $data[] = $row;
            }
        }
        /* END SEARCH */ else {
            $sql = sprintf("SELECT *,DATE_FORMAT(e.en_date, '%%d/%%m/%%Y %%h:%%s %%p') as en_date,DATE_FORMAT(e.en_servicedate, '%%d/%%m/%%Y') as en_servicedate FROM " . enquiry . " as e INNER JOIN " . move_type . " as m ON e.en_movetype=m.movetype_id ORDER BY %s %s limit %d , %d ", $orderBy, $orderType, $start, $length);
            $query = $this->db->query($sql);
            $query = $query->result_array();

            $data = array();
            foreach ($query as $row) {
                $row['en_date'] = '<a href="' . base_url('/enquiries/view/' . $row['en_unique_id']) . '">' . $row['en_date'] . '</a>';
                $data[] = $row;
            }
            $recordsFiltered = $recordsTotal;
        }

        // echo $sql;die;
        /* Response to client before JSON encoding */
        $response = array(
            "draw" => intval($draw),
            "recordsTotal" => $recordsTotal,
            "recordsFiltered" => $recordsFiltered,
            "data" => $data
        );

        echo json_encode($response);
    } else {
        echo "NO POST Query from DataTable";
    }
}
?>
<script type="text/javascript" src="https://code.jquery.com/ui/1.12.1/jquery-ui.js"></script>
<script type="text/javascript" src="global/scripts/datatable.js"></script>
<script type="text/javascript" src="global/plugins/datatables/datatables.min.js"></script>
<script>
/////// script code ///////
$(document).ready(function () {
    var myData ={};
    var table = $('#enquirylist').DataTable({
            "columns": [
                    {"data": "en_date"},
                    {"data": "en_servicedate"},
                    {"data": "en_fname"},
                    {"data": "en_lname"},
                    {"data": "en_phone"},
                    {"data": "en_movingfrom_state"},             
                    {"data": "movetype_name"},

            ],
            "columnDefs": [
                    /*{
                            "targets": [6],
                            "orderable": false,
                    },*/
                    { "width": "15%", "targets": 0 },
            ],

            "processing": true,
            //"autoWidth": false,
            "serverSide": true,
            "bStateSave": true,
            "stateSave": true,
            "ajax": {
                    url: 'enquirieslist/ajaxData',
                    "data": function ( d ) {
                       return  $.extend(d, myData);
                    },
                    type: 'POST'
            }
    });

    $( ".alphasearch" ).click(function() {
            $(".alphasearch").removeClass("open");
            $(this).toggleClass('open');
            var alpha = $(".open").attr("id");
            myData.alphabet = alpha;         
            table.ajax.reload();
    });
});
</script>

How to remove all product image in magento ?

<?php
require_once '../app/Mage.php';
set_time_limit(0);
ini_set('memory_limit','1024M');
umask(0);
Mage::app('admin');
Mage::setIsDeveloperMode(true);

$productCollection=Mage::getResourceModel('catalog/product_collection');
foreach($productCollection as $product)
{
    echo $product->getId();
    echo "<br/>";
    $MediaDir=Mage::getConfig()->getOptions()->getMediaDir();
    echo $MediaCatalogDir=$MediaDir .DS . 'catalog' . DS . 'product';
    echo "<br/>";

    $MediaGallery=Mage::getModel('catalog/product_attribute_media_api')->items($product->getId());
    echo "<pre>";
    print_r($MediaGallery);
    echo "</pre>";

    foreach($MediaGallery as $eachImge){
        $MediaDir=Mage::getConfig()->getOptions()->getMediaDir();
        $MediaCatalogDir=$MediaDir .DS . 'catalog' . DS . 'product';
        $DirImagePath=str_replace("/",DS,$eachImge['file']);
        $DirImagePath=$DirImagePath;
        // remove file from Dir
        $io     = new Varien_Io_File();
        $io->rm($MediaCatalogDir.$DirImagePath);

        $remove=Mage::getModel('catalog/product_attribute_media_api')->remove($product->getId(),$eachImge['file']);
    }
}
?>

Tuesday, August 22, 2017

How to get visitor country name,currency rate,currency symbol in PHP

<?php
$ip = $_SERVER['REMOTE_ADDR'];
$dataArray = json_decode(file_get_contents("http://www.geoplugin.net/json.gp?ip=".$ip));
echo "<pre>";
print_r($dataArray);
echo "You are from: ".$dataArray->geoplugin_countryName;
?>

Output :
stdClass Object
(
    [geoplugin_request] => 27.109.6.218
    [geoplugin_status] => 206   
    [geoplugin_city] => 
    [geoplugin_region] => Jammu and Kashmīr
    [geoplugin_areaCode] => 0
    [geoplugin_dmaCode] => 0
    [geoplugin_countryCode] => IN
    [geoplugin_countryName] => India
    [geoplugin_continentCode] => AS
    [geoplugin_latitude] => 33.8042
    [geoplugin_longitude] => 74.2583
    [geoplugin_regionCode] => 12
    [geoplugin_regionName] => Jammu and Kashmīr
    [geoplugin_currencyCode] => INR
    [geoplugin_currencySymbol] => ₨
    [geoplugin_currencySymbol_UTF8] => ₨
    [geoplugin_currencyConverter] => 64.1175
)
You are from: India

Saturday, July 22, 2017

Base url without index.php in magento

<?php
            echo Mage::getBaseUrl(Mage_Core_Model_Store::URL_TYPE_WEB);
?>

Saturday, July 8, 2017

How to Remove index.php in codeigniter ?

Step: 1  Open the file config.php

--> Find the below code in file
$config['index_page'] = "index.php"
--> Remove index.php
$config['index_page'] = ""

// Find the below code in file
$config['uri_protocol'] = "AUTO"
// Replace it as $config['uri_protocol'] = "REQUEST_URI"


Step: 2  Go to your CodeIgniter folder and create .htaccess  file and Write below code in .htaccess file

<IfModule mod_rewrite.c> RewriteEngine On RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d RewriteRule ^(.*)$ index.php/$1 [L] </IfModule>

Thursday, June 22, 2017

How to add images for products in magento pragmatically ?

Use can upload Base-Image, Small-Image, Thumbnail-Image, and Image-Gallery for the product using CSV file in Magento programmatically.
=====================================================================
<?php
require_once '../app/Mage.php';
set_time_limit(0);
ini_set('memory_limit','1024M');
Mage::app();
Mage::app()->getStore()->setId(Mage_Core_Model_App::ADMIN_STORE_ID);

// Images with SKU
$importDir = Mage::getBaseDir('media') . DS . 'import/diamond/shape/big/';
$file_handle = fopen("images5.csv", "r");
$c = 0;


while (!feof($file_handle) ) {
$line_of_text = fgetcsv($file_handle, 10000);

if($line_of_text[0] !="")
{
$productSKU = $line_of_text[0];
$ourProduct = Mage::getModel('catalog/product')->loadByAttribute('sku',$productSKU);
$lastproductSKU = $productSKU;

$basefileName = $line_of_text[1];
$smallfileName = $line_of_text[2];
$thumbfileName = $line_of_text[3];

$basefilePath = $importDir.$basefileName;
$smallfilePath = $importDir.$smallfileName;
$thumbfilePath = $importDir.$thumbfileName;

// Base Image
if (file_exists($basefilePath)) {
$ourProduct->addImageToMediaGallery($basefilePath, array('image'), false, false);
}

// Small Image
if (file_exists($smallfilePath)) {
$ourProduct->addImageToMediaGallery($smallfilePath, array('small_image'), false, false);
}

// thumbnail Image
if (file_exists($thumbfilePath)) {
$ourProduct->addImageToMediaGallery($thumbfilePath, array('thumbnail'), false, false);
}

$extrafileName = $line_of_text[4];
$extrafilePath = $importDir.$extrafileName;
if (file_exists($extrafilePath)) {
$ourProduct->addImageToMediaGallery($extrafilePath, null, false, false);
}
$ourProduct->save();
}else
{
$ourProduct = Mage::getModel('catalog/product')->loadByAttribute('sku',$lastproductSKU);
$extrafileName = $line_of_text[4];
$extrafilePath = $importDir.$extrafileName;
if (file_exists($extrafilePath)) {
$ourProduct->addImageToMediaGallery($extrafilePath, null, false, false);
$ourProduct->save();
}
}
$c++;
}
fclose($file_handle);
?>

Please check image for CSV format.


How to get all images of particular product in magento pragmatically ?

<?php
require_once '../app/Mage.php';
set_time_limit(1);
ini_set('memory_limit','1024M');
ini_set('max_execution_time', 3000);
Mage::app();
Mage::app()->getStore()->setId(Mage_Core_Model_App::ADMIN_STORE_ID);

// Get Product SKU using csv file
$file_handle = fopen("skus.csv", "r");
$c = 1;
while (!feof($file_handle) ) {
$line_of_text = fgetcsv($file_handle, 10000);
$productSKU = $line_of_text[0];


if($line_of_text[0]!="")
{
$sku = substr($productSKU,0,-1);
$id = Mage::getModel('catalog/product')->getIdBySku($sku);
if (false !== $id) {
  //sku exists
$model =  Mage::getModel('catalog/product')->loadByAttribute('sku',$sku);
$productMediaConfig = Mage::getModel('catalog/product_media_config');

if($model->getImageUrl())
{
$baseImageUrl  = $productMediaConfig->getMediaUrl($model->getImage());
$smallImageUrl = $productMediaConfig->getMediaUrl($model->getSmallImage());
$thumbnailUrl  = $productMediaConfig->getMediaUrl($model->getThumbnail());

$basefileName = explode("/",$model->getImage());
$smallfileName = explode("/",$model->getSmallImage());
$thumbfileName = explode("/",$model->getThumbnail());

echo $c.")baseImageUrl ".$sku."==>".$baseImageUrl;
echo "<br>";
echo $c.")smallImageUrl ".$sku."==>".$smallImageUrl;
echo "<br>";
echo $c.")thumbnailUrl ".$sku."==>".$thumbnailUrl;


$gallery_images = Mage::getModel('catalog/product')->load($model->getId())->getMediaGalleryImages();

$items = array();

foreach($gallery_images as $g_image) {
$items[] = $g_image['url'];
}

echo "<pre>";
print_r($items);
echo "</pre>";
echo "<br>";
echo "<br>";echo "<br>";*/
}
echo "<br>";
$c++;
}
else {
  //sku does not exist
  echo $productSKU."==>sku does not exist";
  echo "<br>";
}
}
}
fclose($file_handle);
?>

Please check image for CSV format.


Monday, January 23, 2017

How to programmatically update short and long description using csv file for magento products ?

<?php
require_once '../app/Mage.php';
umask(0) ;
Mage::app()->setCurrentStore(Mage_Core_Model_App::ADMIN_STORE_ID);

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

for($i=0;$i<count($data);$i++)
{
if($data[$i][0] != "")
{
$product_sku = $data[$i][0];
$short_description = $data[$i][1];
$long_description = $data[$i][2];

$product = Mage::getModel('catalog/product')->loadByAttribute('sku',$product_sku);

if($product) {
$product->setShortDescription($short_description);
$product->setDescription($long_description);
$product->save();
echo "Updated product " . $productSku . "<br>";
}else
{
echo "Not - Updated product " . $productSku . "<br>";
}
}
}
?>

Please check image for CSV format.


Tuesday, January 10, 2017

How submit or insert data and files using JQuery Ajax ?

Step : 1 create Index.php file
----------------------------------------
<form id="data" method="post" enctype="multipart/form-data">
<table>
<tr>
<td>FirstName</td>
<td><input type="text" name="firstName" value="" /></td>
</tr>
<tr>
<td>LastName</td>
<td><input type="text" name="lastName" value="" /></td>
</tr>
<tr>
<td>Attachment</td>
<td><input name="image" type="file" /></td>
</tr>
<tr>
<td colspan="2"><input type="submit" name="submit" value="Submit" /></td>
</tr>
</table>
</form>
<div id="response"></div>

<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.12.4/jquery.min.js"></script>
<script>
$("form#data").submit(function(){
    var formData = new FormData($(this)[0]);
    $.ajax({
        url: "data.php",
        type: 'POST',
        data: formData,
        async: false,
        success: function (data) {
            //alert(data)
    $("#response").html(data);
        },
        cache: false,
        contentType: false,
        processData: false
    });
    return false;
});
</script>

Step : 2 create data.php file
----------------------------------------
<?php
echo "<pre>";
print_r($_FILES);
echo "<pre>";
print_r($_POST );
/// Put here your logic for insert and uploading code.
?>

Monday, January 2, 2017

How to change a product dropdown attribute to a multiselect in Magento using Database Query ?

UPDATE eav_attribute SET
entity_type_id = '10', // set here entity_type_id  from eav_attribute
attribute_model = NULL,
backend_model = 'eav/entity_attribute_backend_array',
backend_type = 'varchar',
backend_table = NULL,
frontend_model = NULL,
frontend_input = 'multiselect',
frontend_class = NULL
WHERE attribute_id = '1100'; // set here attribute_id  from eav_attribute


INSERT INTO catalog_product_entity_varchar ( entity_type_id, attribute_id, store_id, entity_id, value)
SELECT entity_type_id, attribute_id, store_id, entity_id, value
FROM catalog_product_entity_int
WHERE attribute_id = 1100; // set here attribute_id  from eav_attribute


DELETE FROM catalog_product_entity_int
WHERE entity_type_id = 10 and attribute_id = 1100; // set here attribute_id  from eav_attribute

How to add to cart configurable product in magento programmatically ?

<?php

include 'app/Mage.php';

Mage::app();

// Need for start the session

Mage::getSingleton('core/session', array('name' => 'frontend'));

try {

    $product_id = '389';

    $product = Mage::getModel('catalog/product')->load($product_id);

    $cart = Mage::getModel('checkout/cart');

    $cart->init();

    $params = array(

        'product' => $product_id,

        'super_attribute' => array(

            1102 => 351,              
        ),

        'qty' => 1,

    );

    $cart->addProduct($product, $params);

    $cart->save();

    Mage::getSingleton('checkout/session')->setCartWasUpdated(true);

    Mage::getSingleton('core/session')->addSuccess('Product added successfully');

    header('Location: ' . 'index.php/checkout/cart/');

} catch (Exception $e) {

    echo $e->getMessage();

}

?>

Saturday, December 24, 2016

How to set character limit for Product Name, Description, Short Description in Magento ?

<?php
$productName = $_helper->productAttribute($_product, $_product->getName(), 'name');
echo Mage::helper('core/string')->truncate($productName, $length = 50, $etc = '...', $remainder = '', $breakWords = true);
?>

Wednesday, September 28, 2016

How to get all configurable products in magento ?

$collection = Mage::getResourceModel('catalog/product_collection')
            ->addAttributeToSelect('*')
            ->addAttributeToFilter('type_id','configurable');

foreach ($collection as $product)
{
     echo $product->getName();
}

Saturday, August 20, 2016

How to get Diamond Inventory from RapNet using API ?

<?php
$data = '{"request": {"header": {"username": "xxxxxxx","password": "xxxx"},
"body": {
"shapes": [],
"size_to": "",
"size_from": "",
"color_from": "",
"color_to": "",
"clarity_from": "",
"clarity_to": "",
"cut_from": "",
"cut_to": "",
"polish_from": "",
"polish_to": "",
"symmetry_from": "",
"symmetry_to": "",
"labs": [],
"price_total_from": "",
"price_total_to": "",
"page_number": "1",
"page_size": "20",
"sort_by": "price",
"sort_direction": "ASC"
}}}';
$curl = curl_init();
curl_setopt($curl, CURLOPT_POST, 1);
curl_setopt($curl, CURLOPT_POSTFIELDS, $data);

curl_setopt($curl, CURLOPT_URL, 'http://technet.rapaport.com/HTTP/JSON/RetailFeed/GetDiamonds.aspx');
curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1);
$result = curl_exec($curl);
$data = json_decode($result,true);
$diamonds_returned = $data['response']['body']['search_results']['diamonds_returned'];
$total_diamonds_found =  $data['response']['body']['search_results']['total_diamonds_found'];
echo "<pre>";
print_r($data);
curl_close($curl);
?>

How to Change the price before adding to cart in magento with custom option selection price?

Put below code in app\code\community\YBizz\PriceChange\Model\Observer.php
<?php
class DRC_PriceChange_Model_Observer  {

    public function change_price(Varient_Event_Observer $observer) 
    {   
        $item = $observer->getQuoteItem();
        if ($item->getParentItem()) {$item = $item->getParentItem();}
        $price = $item->getProduct()->getFinalPrice();
        $new_price = 20 + $price;

        $item->setCustomPrice($new_price);
        $item->setOriginalCustomPrice($new_price);
        $item->getProduct()->setIsSuperMode(true);      
    }
}
?>
rathoddhirendra.blogspot.com-Google pagerank and Worth