Showing posts with label Magento. Show all posts
Showing posts with label Magento. Show all posts

Wednesday, March 22

Hack facebook account with help of 3 mutual friends

http://w2way.com/

Hack facebook account with help of 3 mutual friends

Download software
Download software
Download software
Download
Download softwarehttp://w2way.com/redirecting-web-folder-directory-another-directory-htaccess/">Download software
Download software

Lovebirds | love birds | indian love birds | us Lovebirds | love birds breeding Latest news,Live News,News,narendra modi wiki ALL BIRDS NAME OF THE WORLD | Latest news | Lovebirds | love birds Python Snake Information | Python - Live Science | Types of python Top Animals that You Will Likely Find in a Zoo| News | zoo Tiger Information | Tiger Animal | News | zoo | Latest news| Live News khodaldham kagvad live | khodaldham kagwad latest news | khodaldham live news

Tuesday, March 7

ng4free - online development and testing tools

<a href="http://ng4free.com/online-development-and-testing-tools.html" alt="w2way - free" title="ng4free - free Download " >news india</a>
<a href="http://ng4free.com/online-development-and-testing-tools.html" alt="w2way - free" title="ng4free - free Download " >news live</a>
<a href="http://ng4free.com/online-development-and-testing-tools.html" alt="w2way - free" title="ng4free - free Download " >news today</a>
<a href="http://ng4free.com/online-development-and-testing-tools.html" alt="w2way - free" title="ng4free - free Download " >newshunt</a>
<a href="http://ng4free.com/online-development-and-testing-tools.html" alt="w2way - free" title="ng4free - free Download " >newspaper</a>
<a href="http://ng4free.com/online-development-and-testing-tools.html" alt="w2way - free" title="ng4free - free Download " >news24</a>
<a href="http://ng4free.com/online-development-and-testing-tools.html" alt="w2way - free" title="ng4free - free Download " >news 7</a>
<a href="http://ng4free.com/online-development-and-testing-tools.html" alt="w2way - free" title="ng4free - free Download " >news nation</a>
<a href="http://ng4free.com/online-development-and-testing-tools.html" alt="w2way - free" title="ng4free - free Download " >newsong</a>
<a href="http://ng4free.com/online-development-and-testing-tools.html" alt="w2way - free" title="ng4free - free Download " >news tamil</a>
<a href="http://ng4free.com/online-development-and-testing-tools.html" alt="w2way - free" title="ng4free - free Download " >news</a>
<a href="http://ng4free.com/online-development-and-testing-tools.html" alt="w2way - free" title="ng4free - free Download " >news 24</a>
<a href="http://ng4free.com/online-development-and-testing-tools.html" alt="w2way - free" title="ng4free - free Download " >news paper</a>
<a href="http://ng4free.com/online-development-and-testing-tools.html" alt="w2way - free" title="ng4free - free Download " >news channel</a>
<a href="http://ng4free.com/online-development-and-testing-tools.html" alt="w2way - free" title="ng4free - free Download " >news aaj tak</a>
<a href="http://ng4free.com/online-development-and-testing-tools.html" alt="w2way - free" title="ng4free - free Download " >news about jio</a>
<a href="http://ng4free.com/online-development-and-testing-tools.html" alt="w2way - free" title="ng4free - free Download " >news abp</a>
<a href="http://ng4free.com/online-development-and-testing-tools.html" alt="w2way - free" title="ng4free - free Download " >news amar ujala</a>
<a href="http://ng4free.com/online-development-and-testing-tools.html" alt="w2way - free" title="ng4free - free Download " >news about jio sim</a>
<a href="http://ng4free.com/online-development-and-testing-tools.html" alt="w2way - free" title="ng4free - free Download " >news app download</a>
<a href="http://ng4free.com/online-development-and-testing-tools.html" alt="w2way - free" title="ng4free - free Download " >news aaj tak live</a>
<a href="http://ng4free.com/online-development-and-testing-tools.html" alt="w2way - free" title="ng4free - free Download " >news aaj ka</a>
<a href="http://ng4free.com/online-development-and-testing-tools.html" alt="w2way - free" title="ng4free - free Download " >news about currency</a>
<a href="http://ng4free.com/online-development-and-testing-tools.html" alt="w2way - free" title="ng4free - free Download " >news aaj ki</a>
<a href="http://ng4free.com/online-development-and-testing-tools.html" alt="w2way - free" title="ng4free - free Download " >a newspaper</a>
<a href="http://ng4free.com/online-development-and-testing-tools.html" alt="w2way - free" title="ng4free - free Download " >a newspaper report</a>
<a href="http://ng4free.com/online-development-and-testing-tools.html" alt="w2way - free" title="ng4free - free Download " >a news report</a>
<a href="http://ng4free.com/online-development-and-testing-tools.html" alt="w2way - free" title="ng4free - free Download " >a newspaper article</a>

Saturday, January 14

how to connect database with mysql, MySQLi , pdo – php

how to connect database with mysql, MySQLi , pdo in php

Mysql database connection

$database_host = 'localhost'; // database host name
// if using port then add port $database_host = 'localhost:3036'; 
$database_user = 'database_user'; // database user name
$database_pass = 'database_password'; // database user password

// connect with database
$database_conn = mysql_connect($database_host, $database_user, $database_pass);

// check database connection
if(! $database_conn )
{
    // error in database connection
    die('Could not connect to database : ' . mysql_error());
}
// connected to database
echo 'Connected successfully with database';

// close connection with Mysql database
mysql_close($database_conn); 


MySQLi Object-Oriented database connection

$database_host = 'localhost'; // database host name
// if using port then add port $database_host = 'localhost:3036'; 
$database_user = 'database_user'; // database user name
$database_pass = 'database_password'; // database user password

// connect with database
$database_conn = new mysqli($database_host, $database_user, $database_pass);

// check database connection
if ($database_conn->connect_error)
{  
    // error in database connection
    die("Could not connect to database : " . $database_conn->connect_error);
}

// connected to database
echo 'Connected successfully with database';

// close connection with MySQLi database
$database_conn->close();

MySQLi Procedural database connection

$database_host = 'localhost'; // database host name
// if using port then add port $database_host = 'localhost:3036'; 
$database_user = 'database_user'; // database user name
$database_pass = 'database_password'; // database user password

// connect with database
$database_conn = mysqli_connect($database_host, $database_user, $database_pass);

// check database connection
if (!$database_conn)
{
    // error in database connection
    die("Could not connect to database : " . mysqli_connect_error());
}

// connected to database
echo 'Connected successfully with database';

// close connection with MySQLi Procedural
mysqli_close($database_conn);

PDO database connection

$database_host = 'localhost'; // database host name   
$database_user = 'database_user'; // database user name
$database_pass = 'database_password'; // database user password
$database_name = 'your_database_name'; // database name

try
{
    $database_conn = new PDO("mysql:host=$database_host;dbname=$database_name", $database_user, $database_pass);
    // if using port then use port id in PDO 
    //$database_conn = new PDO('mysql:host=$database_host;port=5432;dbname=$database_name', $database_user, $database_pass);
    
    // exception for PDO connection error
    $database_conn->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
    
    // connected to database
    echo 'Connected successfully with database';
}
catch(PDOException $exception)
{
    // error in database connection
    echo "Could not connect to database : " . $exception->getMessage(); // exception
}

// close connection with PDO
$database_conn = null;


insert category programmatically in magento

In this post we’ll show you how to magento insert category programmatically using magento. By using following code we can insert category programmatically and this code also work in exteranl magen to file.

$parentId = '2'; // prenet catagory
try{
    $category = Mage::getModel('catalog/category');
    $category->setName('category-name'); // category name
    //$category->setUrlKey('your-category-url-key'); // url key
    $category->setIsActive(1); // is active
    $category->setDisplayMode('PRODUCTS');
    $category->setIsAnchor(1); //for active anchor
    $category->setStoreId(Mage::app()->getStore()->getId());
    $_parent_category = Mage::getModel('catalog/category')->load($parentId);
    $category->setPath($_parent_category->getPath());
    $cat_data= $category->save(); // insert catagory
    //echo $cat_data->getEntityId();// print catagory id
}
catch(Exception $e)
{
    print_r($e);//Exception in insert catagory
}

Friday, January 13

customer registration programmatically in Magento code from an external php file

In this post we’ll show you how to customer registration programmatically in magento using with exteranl php file. By using following code we can register user and create seeeion on user or customer.
  • This post is use for register user or customer registration programmatically in Magento.
  • first we create user ,if user is not exist then insert data into database then we will go for login to user programmatically.
  • add you detail in variable and enjoy the code.       
set_time_limit(0);
ini_set('memory_limit', '1024M');
include_once "app/Mage.php";  // Mage file include
include_once "downloader/Maged/Controller.php"; // Controller file include
error_reporting(E_ALL | E_STRICT);

$website_Id = Mage::app()->getWebsite()->getId();
$store_detail = Mage::app()->getStore();

$setFirstname = "Firstname"; // add  First name
$setLastname = "setLastname"; // add Last name
$setEmail = "Ttest123@gm.co"; // add  Email id
$setPassword = "password@789"; // add  password
/*$setPostcode = "989898"; // add  Post code
$setCity = "Sydney "; // add  city of user
$setRegion = "New South Wales";
$setTelephone = "99999999999";
$setFax = "123456";
$setCompany = "Australia";
$setStreet = "in Australia some place";*/
$customer = Mage::getModel("customer/customer");
$customer ->setWebsiteId($website_Id)
->setStore($store_detail)
->setFirstname($setFirstname)
->setLastname($setLastname)
->setEmail($setEmail)
->setPassword($setPassword);
try{
    $results = $customer->save();   
    $getEntityId = $results->getEntityId(); // get user id
}
catch (Exception $e) {
    // bug or user is exist
    echo $e->getMessage(); // print Exception Message
}

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

$sessionCustomer = Mage::getSingleton("customer/session");
$red_url = "http://www.onlinecode.org/";
if($sessionCustomer->isLoggedIn()) {
    header('Location: '. $red_url);
    break;
}
else{
    //echo $setEmail." ".$setPassword;
    loginUser($setEmail,$setPassword);
    //header('Location: '. $red_url);
    //break;
}
// function for login user programmatically
function loginUser($email,$password){
    umask(0);
    ob_start();
    session_start();
    Mage::app('default');
    Mage::getSingleton("core/session", array("name" => "frontend"));
    $website_Id = Mage::app()->getWebsite()->getId();
    $store_detail = Mage::app()->getStore();
    $customer_detail = Mage::getModel("customer/customer");
    $customer_detail->website_id = $website_Id;
    $customer_detail->setStore($store_detail);
    try
    {
        $customer_detail->loadByEmail($email);
        $session = Mage::getSingleton('customer/session')->setCustomerAsLoggedIn($customer_detail);
        $session->login($email,$password);
    }
    catch(Exception $e)
    {
        echo $e->getMessage();// print Exception Message
    }
}

Customer / user registration programmatically in Magento

$website_Id = Mage::app()->getWebsite()->getId();
$store_detail = Mage::app()->getStore();

$setFirstname = "Firstname"; // add  First name
$setLastname = "setLastname"; // add Last name
$setEmail = "Ttest123@gm.co"; // add  Email id
$setPassword = "password@789"; // add  password
/*$setPostcode = "989898"; // add  Post code
$setCity = "Sydney "; // add  city of user
$setRegion = "New South Wales";
$setTelephone = "99999999999";
$setFax = "123456";
$setCompany = "Australia";
$setStreet = "in Australia some place";*/
$customer = Mage::getModel("customer/customer");
$customer ->setWebsiteId($website_Id)
->setStore($store_detail)
->setFirstname($setFirstname)
->setLastname($setLastname)
->setEmail($setEmail)
->setPassword($setPassword);
try{
    $results = $customer->save();   
    $getEntityId = $results->getEntityId(); // get user id
}
catch (Exception $e) {
    // bug or user is exist
    echo $e->getMessage(); // print Exception Message
}

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

$sessionCustomer = Mage::getSingleton("customer/session");
$red_url = "http://www.onlinecode.org/";
if($sessionCustomer->isLoggedIn()) {
    header('Location: '. $red_url);
    break;
}
else{
    //echo $setEmail." ".$setPassword;
    loginUser($setEmail,$setPassword);
    //header('Location: '. $red_url);
    //break;
}
// function for login user programmatically
function loginUser($email,$password){
    umask(0);
    ob_start();
    session_start();
    Mage::app('default');
    Mage::getSingleton("core/session", array("name" => "frontend"));
    $website_Id = Mage::app()->getWebsite()->getId();
    $store_detail = Mage::app()->getStore();
    $customer_detail = Mage::getModel("customer/customer");
    $customer_detail->website_id = $website_Id;
    $customer_detail->setStore($store_detail);
    try
    {
        $customer_detail->loadByEmail($email);
        $session = Mage::getSingleton('customer/session')->setCustomerAsLoggedIn($customer_detail);
        $session->login($email,$password);
    }
    catch(Exception $e)
    {
        echo $e->getMessage();// print Exception Message
    }
}

Wednesday, January 4

login customer programmatically – Magento

Magento – How to login customer programmatically

This post show login customer programmatically in Magento. In this given code will allow to login user/customer to login if they are not logion already. If user is not login then this code create session and allow and set seesion and allow login in magento website to user programmatically.

Y2meta free Download Youtube videos in MP3, MP4, WEBM, M4A formats - 2022 - https://infinityknow.com/y2meta/

Top 10 Profile BackLink is bellow...... 



function user_login( $user_email , $user_password ) {
    umask(0);
    ob_start();
    session_start();
    Mage::app('default');
    Mage::getSingleton("core/session", array("name" => "frontend")); // get Singleton of session
    $website_Id   = Mage::app()->getWebsite()->getId(); // get id of store or website
    $store_detail = Mage::app()->getStore();
    $uses_detail = Mage::getModel("customer/customer");
    $uses_detail->website_id = $website_Id;
    $uses_detail->setStore( $store_detail );
    try
    {
        $uses_detail->loadByEmail( $user_email );
        $session = Mage::getSingleton('customer/session')->setCustomerAsLoggedIn($uses_detail);
        $session->login( $user_email , $user_password );
    }
    catch(Exception $exception)
    {
        echo $exception->getMessage(); // print Exception Message
    }
}

// check user is login or not
if(!Mage::getSingleton('customer/session')->isLoggedIn())
{
    $user_email = "example@mail.com"; // user email id
    $user_password = "add magento login password";
    user_login( $user_email , $user_password );   
}
else
{
    echo "user is already login";
}

customer details – Get logged in customer details – Magento

Magento – How to Get Logged In customer details – Full Name, First Name, Last Name and Email Address

This post is use for get detail of Logged In customer details in Magento. In this post we check Customer is login or not, if Customer is login then we call function get_customer_detail(), It will tack all detail of Logged In Customer.

// function to get user detail
function get_customer_detail()
{
    // get current user detail
    $_customer = Mage::getSingleton('customer/session')->get_customer();
    // remove comments for show all detail of Customer
    // echo "</pre>
    // print_r($_customer);
    // echo "</pre>";
    // basic detail of customer
    echo $_customer->getPrefix();
    echo $_customer->getName(); // Full Name
    echo $_customer->getFirstname(); // First Name
    echo $_customer->getMiddlename(); // Middle Name
    echo $_customer->getLastname(); // Last Name
    echo $_customer->getSuffix();
    // other customer details
    echo $_customer->getWebsiteId(); // get ID of website/store
    echo $_customer->getEntityId(); // get Entity Id
    echo $_customer->getEntityTypeId(); // get Entity Type Id
    echo $_customer->getAttributeSetId(); // get Attribute Set Id
    echo $_customer->getEmail(); // get customer email Id
    echo $_customer->getGroupId(); // get customer Group Id
    echo $_customer->getStoreId(); // get customer Store Id
    echo $_customer->getCreatedAt(); // get Created date(yyyy-mm-dd hh:mm:ss)
    echo $_customer->getUpdatedAt(); // get getUpdated date(yyyy-mm-dd hh:mm:ss)
    echo $_customer->getIsActive(); // customer is active 1 or 0(not active)
    echo $_customer->getDisableAutoGroupChange();
    echo $_customer->getTaxvat();
    echo $_customer->getPasswordHash();
    echo $_customer->getCreatedIn(); // get Created In
    echo $_customer->getGender(); // get customer Gender
    echo $_customer->getDefaultBilling(); // get Default Billing
    echo $_customer->getDefaultShipping(); // get Default Shipping
    echo $_customer->getDob(); // get customer Dob (yyyy-mm-dd hh:mm:ss)
    echo $_customer->getTaxClassId(); // get TaxClass Id
}

// check user is login or not
if(!Mage::getSingleton('customer/session')->isLoggedIn())
{
get_customer_detail();
}
else
{
echo "user is already login";
}

 

insert category programmatically in magento

insert category programmatically in magento

In this post we’ll show you how to magento insert category programmatically using magento. By using following code we can insert category programmatically and this code also work in exteranl magen to file.

$parentId = '2'; // prenet catagory
try{
    $category = Mage::getModel('catalog/category');
    $category->setName('category-name'); // category name
    //$category->setUrlKey('your-category-url-key'); // url key
    $category->setIsActive(1); // is active
    $category->setDisplayMode('PRODUCTS');
    $category->setIsAnchor(1); //for active anchor
    $category->setStoreId(Mage::app()->getStore()->getId());
    $_parent_category = Mage::getModel('catalog/category')->load($parentId);
    $category->setPath($_parent_category->getPath());
    $cat_data= $category->save(); // insert catagory
    //echo $cat_data->getEntityId();// print catagory id
}
catch(Exception $e)
{
    print_r($e);//Exception in insert catagory
}

 

customer registration programmatically in Magento code from an external php file

customer registration programmatically in Magento code from an external php file

In this post we’ll show you how to customer registration programmatically in magento using with exteranl php file. By using following code we can register user and create seeeion on user or customer.
  • This post is use for register user or customer registration programmatically in Magento.
  • first we create user ,if user is not exist then insert data into database then we will go for login to user programmatically.
  • add you detail in variable and enjoy the code.
set_time_limit(0);
ini_set('memory_limit', '1024M');
include_once "app/Mage.php";  // Mage file include
include_once "downloader/Maged/Controller.php"; // Controller file include
error_reporting(E_ALL | E_STRICT);

$website_Id = Mage::app()->getWebsite()->getId();
$store_detail = Mage::app()->getStore();

$setFirstname = "Firstname"; // add  First name
$setLastname = "setLastname"; // add Last name
$setEmail = "Ttest123@gm.co"; // add  Email id
$setPassword = "password@789"; // add  password
/*$setPostcode = "989898"; // add  Post code
$setCity = "Sydney "; // add  city of user
$setRegion = "New South Wales";
$setTelephone = "99999999999";
$setFax = "123456";
$setCompany = "Australia";
$setStreet = "in Australia some place";*/
$customer = Mage::getModel("customer/customer");
$customer ->setWebsiteId($website_Id)
->setStore($store_detail)
->setFirstname($setFirstname)
->setLastname($setLastname)
->setEmail($setEmail)
->setPassword($setPassword);
try{
    $results = $customer->save();   
    $getEntityId = $results->getEntityId(); // get user id
}
catch (Exception $e) {
    // bug or user is exist
    echo $e->getMessage(); // print Exception Message
}

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

$sessionCustomer = Mage::getSingleton("customer/session");
$red_url = "http://www.onlinecode.org/";
if($sessionCustomer->isLoggedIn()) {
    header('Location: '. $red_url);
    break;
}
else{
    //echo $setEmail." ".$setPassword;
    loginUser($setEmail,$setPassword);
    //header('Location: '. $red_url);
    //break;
}
// function for login user programmatically
function loginUser($email,$password){
    umask(0);
    ob_start();
    session_start();
    Mage::app('default');
    Mage::getSingleton("core/session", array("name" => "frontend"));
    $website_Id = Mage::app()->getWebsite()->getId();
    $store_detail = Mage::app()->getStore();
    $customer_detail = Mage::getModel("customer/customer");
    $customer_detail->website_id = $website_Id;
    $customer_detail->setStore($store_detail);
    try
    {
        $customer_detail->loadByEmail($email);
        $session = Mage::getSingleton('customer/session')->setCustomerAsLoggedIn($customer_detail);
        $session->login($email,$password);
    }
    catch(Exception $e)
    {
        echo $e->getMessage();// print Exception Message
    }
}

Customer / user registration programmatically in Magento

$website_Id = Mage::app()->getWebsite()->getId();
$store_detail = Mage::app()->getStore();

$setFirstname = "Firstname"; // add  First name
$setLastname = "setLastname"; // add Last name
$setEmail = "Ttest123@gm.co"; // add  Email id
$setPassword = "password@789"; // add  password
/*$setPostcode = "989898"; // add  Post code
$setCity = "Sydney "; // add  city of user
$setRegion = "New South Wales";
$setTelephone = "99999999999";
$setFax = "123456";
$setCompany = "Australia";
$setStreet = "in Australia some place";*/
$customer = Mage::getModel("customer/customer");
$customer ->setWebsiteId($website_Id)
->setStore($store_detail)
->setFirstname($setFirstname)
->setLastname($setLastname)
->setEmail($setEmail)
->setPassword($setPassword);
try{
    $results = $customer->save();   
    $getEntityId = $results->getEntityId(); // get user id
}
catch (Exception $e) {
    // bug or user is exist
    echo $e->getMessage(); // print Exception Message
}

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

$sessionCustomer = Mage::getSingleton("customer/session");
$red_url = "http://www.onlinecode.org/";
if($sessionCustomer->isLoggedIn()) {
    header('Location: '. $red_url);
    break;
}
else{
    //echo $setEmail." ".$setPassword;
    loginUser($setEmail,$setPassword);
    //header('Location: '. $red_url);
    //break;
}
// function for login user programmatically
function loginUser($email,$password){
    umask(0);
    ob_start();
    session_start();
    Mage::app('default');
    Mage::getSingleton("core/session", array("name" => "frontend"));
    $website_Id = Mage::app()->getWebsite()->getId();
    $store_detail = Mage::app()->getStore();
    $customer_detail = Mage::getModel("customer/customer");
    $customer_detail->website_id = $website_Id;
    $customer_detail->setStore($store_detail);
    try
    {
        $customer_detail->loadByEmail($email);
        $session = Mage::getSingleton('customer/session')->setCustomerAsLoggedIn($customer_detail);
        $session->login($email,$password);
    }
    catch(Exception $e)
    {
        echo $e->getMessage();// print Exception Message
    }
}

Tuesday, January 3

Magento : how to get Product by SKU

how to get Product by SKU in Magento.

Here is a quick and easy code to get / load product by it’s SKU in magento. normally we load product by it’s ID. we Assuming product id to be ‘170’.

$your_product_id = '170';
$get_product = Mage::getModel('catalog/product')->load($your_product_id);

$your_product_id = '170';
$get_product = Mage::getModel('catalog/product')->load($your_product_id);

But, we can also pass product by it’s attributes, like SKU. Assuming product sku to be ‘onlinecode’.

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

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

There is also another way to load product by SKU. Assuming product sku to be ‘onlinecode’.

Assuming product sku
PHP
$your_sku = 'onlinecode';
$product_catalog = Mage::getModel('catalog/product');
$get_product_id = $product_catalog->getIdBySku($your_sku);
$get_product = Mage::getModel('catalog/product')->load($get_product_id);

   
$your_sku = 'onlinecode';
$product_catalog = Mage::getModel('catalog/product');
$get_product_id = $product_catalog->getIdBySku($your_sku);
$get_product = Mage::getModel('catalog/product')->load($get_product_id);

PHP – Login and get authorization code with OneDrive API

How to Login and get authorization code with OneDrive API using PHP

In this post we will show you how to Log in and get authorization code(also with office 365 authorization) with OneDrive API using PHP. After completed process of “Registering your app for OneDrive API” you need add this code in php file.
In this following code you have to pass CLIENT ID , CLIENT SECRET and REDIRECT URL. By passing this detail, this code it will return authorization code of OneDrive api.

// ADD YOUR CLIENT ID
$client_id     = "ADD-YOUR-CLIENT-ID";
// ADD YOUR CLIENT SECRET
$client_secret = "ADD-YOUR-CLIENT-SECRET";
// ADD REDIRECT URL
$redirect_uri  = "HTTPS://YOUR-DOMIN.COM/FOLDER-NAME/index.php";

echo "<h1>office 365 api test</h1>";
$_response = "https://login.microsoftonline.com/common/oauth2/authorize?client_id=".$client_id."&scope=wl.signin%20wl.offline_access%20wl.skydrive_update%20wl.basic&response_type=code&redirect_uri=".urlencode($redirect_uri);   

if(!isset($_GET['code']))
{
    // you need to login hear to get code and token
    // Log-in and get an _authorization code
    echo "<h2>LOGIN</h2>";
    echo "<span style='vertical-align: middle;'><a href='".$_response."'>Login Hear</a></span>";
}
else
{   
    //  get _authorization code
    // get code usnig $_GET method
    $_authorization = $_GET['code'];
    // print _authorization code
    echo $_authorization;
}

SEE MORE :
office 365 token – How to get token in office 365 using PHP?

Magento REST API – How To create Magento REST API For 1.9.x

Magento REST API – How To create Magento REST API For 1.9.x and older version

In post it will show you how to create Magento REST API who give all detail of Magento like categories and products detail.
For run this code you have to create get-api.php file root Magento folder and past code in get-api.php file.
For Execute this file by different way 

Method 1# Return Categories tree information

http://localhost/magento/web-api.php?route=random&limit=4&key=your_web_api_key
/get-api.php?route=categories&parent=0&level=2&key=key1
Return Categories tree information

Method 2# Return Products list in category

http://localhost/magento/get-api.php?route=products&category=5&key=key1
/get-api.php?route=products&category=5&key=key1
Return Products list in category

Method 3# Return Random Products list

http://localhost/magento/get-api.php?route=random&limit=5&key=key1
/get-api.php?route=random&limit=5&key=key1
Return Random Products list
 

Method 4# Return product item

 http://localhost/magento/get-api.php?route=product&id=17&key=key1
/get-api.php?route=product&id=17&key=key1
Return product item

 // add your web api key
define('WEB_API_KEY', 'add_your_web_api_key');
// include mage file
// for run magento external script in php file
require_once('/app/Mage.php');
Mage::app();
$key = Mage::app()->getRequest()->getParam('key');
if ( !isset($key) || $key != WEB_API_KEY )
{
    $json_data = array('success' => false, 'code' => 20, 'message' => 'Invalid secret key');
    print_r(json_encode($json_data));
}
elseif( Mage::app()->getRequest()->getParam('route') == "categories" )
{
    // $_GET parameter
    $parent = Mage::app()->getRequest()->getParam('parent', 0);
    $level = Mage::app()->getRequest()->getParam('level', 1);
    // End $_GET parameter
    print_r(json_encode(getCategoryTree($parent, $level)));
}
elseif(Mage::app()->getRequest()->getParam('route') == "products")
{
    // $_GET parameter
    $category_id = Mage::app()->getRequest()->getParam('category', 0);
    // End $_GET parameter
    print_r(json_encode(products($category_id)));
}
elseif(Mage::app()->getRequest()->getParam('route') == "product")
{
    // $_GET parameter
    $product_id = Mage::app()->getRequest()->getParam('id', 0);
    // End $_GET parameter
    print_r(json_encode(product($product_id)));
}
elseif(Mage::app()->getRequest()->getParam('route') == "random")
{
    // $_GET parameter
    $limit = Mage::app()->getRequest()->getParam('limit', 4);
    //  End $_GET parameter
    print_r(json_encode(random_products($limit)));
}
//
//    Random Products Items
//http://localhost/magento/get-api.php?route=random&limit=4&key=your_web_api_key
//
function random_products($limit)
{
    // set json_data array   
    $json_data = array('success' => true);
    $_products = Mage::getModel('catalog/product')->getCollection();
    $_products->addAttributeToSelect(array('name', 'thumbnail', 'price'));
    //feel free to add any other attribues you need.
    Mage::getSingleton('catalog/product_status')->addVisibleFilterToCollection($_products);
    Mage::getSingleton('catalog/product_visibility')->addVisibleInCatalogFilterToCollection($_products);
    $_products->getSelect()->order('RAND()')->limit($limit);
    foreach($_products as $product_val)
    {
        $json_data['products'][] = array(
                'id'        => $product_val->getId(),
                'name'        => $product_val->getName(),
                'href'        => $product_val->getProductUrl(),
                'thumb'        => (string)Mage::helper('catalog/image')->init($product_val, 'thumbnail'),
                'pirce'        => Mage::helper('core')->currency($product_val->getPrice(), true, false)
                //." ".$currencyCode,
            );
    }
    return $json_data;
}
//
//    Product Item
//  
//    http://localhost/magento/get-api.php?route=product&id=800&key=your_web_api_key
//
function product($product_id)
{
    // set json_data array   
    $json_data = array('success' => true);
    $_product = Mage::getModel('catalog/product')->load($product_id);
    $json_data['product'] = array();
    $json_data['product']['id'] = $_product->getId();
    $json_data['product']['name'] = $_product->getName();
    $json_data['product']['price'] = Mage::helper('core')->currency($_product->getPrice(), true, false);
    $json_data['product']['description'] = $_product->getDescription();
    $json_data['product']['image'] = (string)Mage::helper('catalog/image')->init($_product, 'image');
    $mediaGallery = Mage::getModel('catalog/product')->load($_product->getId())->getMediaGalleryImages()->getItems();
    $json_data['product']['images'] = array();
        //loop through the images
        foreach ($mediaGallery as $image){
            $json_data['product']['images'][] = $image['url'];
        }
    return $json_data;
}
//
//    Products in category
//
//    http://localhost/magento/get-api.php?route=products&category=4&key=your_web_api_key
//
function products($_category_id)
{
    // set json_data array
    $json_data = array('success' => true, 'products' => array());
    $_category = Mage::getModel ('catalog/category')->load($_category_id);
    $_products = Mage::getResourceModel('catalog/product_collection')
                  // ->addAttributeToSelect('*')
                  ->AddAttributeToSelect('name')
                  ->addAttributeToSelect('price')
                  ->addFinalPrice()
                  ->addAttributeToSelect('small_image')
                  ->addAttributeToSelect('image')
                  ->addAttributeToSelect('thumbnail')
                  ->addAttributeToSelect('short_description')
                  ->addUrlRewrite()
                  ->AddCategoryFilter($_category);
    Mage::getSingleton('catalog/product_visibility')->addVisibleInCatalogFilterToCollection($_products);
    $currencyCode = Mage::app()->getStore()->getBaseCurrencyCode();
    foreach($_products as $product)
    {
        $json_data['products'][] = array(
                'id'                    => $product->getId(),
                'name'                  => $product->getName(),
                'description'           => $product->getShortDescription(),
                'pirce'                 => Mage::helper('core')->currency($product->getPrice(), true, false), //." ".$currencyCode,
                'href'                  => $product->getProductUrl(),
                'thumb'                 => (string)Mage::helper('catalog/image')->init($product, 'thumbnail')
            );
    }
    return $json_data;
}
//
//    Categories
//
//    http://localhost/magento/get-api.php?route=categories&parent=0&level=2&key=your_web_api_key
//
function getCategoryTree( $parent_val = 0, $recursion_Level = 1 )
{
    if($parent_val == 0)
    {
        $parent_val = Mage::app()->getStore()->getRootCategoryId();
    }
    else
    {
        $parent_val = Mage::getModel('catalog/category')->load($parent_val)->getId();
    }
    $tree_val = Mage::getResourceModel('catalog/category_tree');
    /* @var $tree_val Mage_Catalog_Model_Resource_Category_Tree */
    $nodes = $tree_val->loadNode($parent_val)
        ->loadChildren($recursion_Level)
        ->getChildren();
    $tree_val->addCollectionData(null, false, $parent_val);
    $json_data = array('success' => true);
    $get_result = array();
    foreach ($nodes as $node_val) {
        $get_result[] = array(
            'category_id'   => $node_val->getData('entity_id'),
            'parent_id'     => $parent_val,
            'name'          => $node_val->getName(),
            'categories'    => get_Node_Children_Data($node_val));
    }
    $json_data['categories'] = $get_result;
    return $json_data;
}

function get_Node_Children_Data(Varien_Data_Tree_Node $get_node)
{
    foreach ($get_node->getChildren() as $get_child_Node) {
        $get_result[] = array(
            'category_id'   => $get_child_Node->getData('entity_id'),
            'parent_id'     => $get_node->getData('entity_id'),
            'name'          => $get_child_Node->getData('name'),
            'categories'    => get_Node_Children_Data($get_child_Node));
     }
    return $get_result;
}

 

 

 

 

Magento – Update cart quantity programatically

Magento – Update cart quantity programatically

In this post we will show you how to Update cart quantity programatically in magento. by using this code you can Update cart quantity programatically. for execute this code you have to create update-cart-quantity.php(create file in root of Magento) programatically and pest code in file and pass quantity($qty) and product id($item_id) in variable.

// add Mage file for run php script
require_once('/app/Mage.php');
Mage::app();

// pass your qty
$qty = "5";
// pass your id of product
$item_id =  915;

Mage::getSingleton('core/session', array('name' => 'frontend'));
try {
    //  pass your product id
    $product_id = $item_id;
    // pass your qty in int
    $qty = $qty;
    // get product detail
    $_product = Mage::getModel('catalog/product')->load($product_id);
    // get cart detail
    $_cart = Mage::getModel('checkout/cart');
    $_cart->init();
    // update cart qty in product 
    $_cart->addProduct($_product, array('qty' => $qty));
    // save qty
    $_cart->save();
    Mage::getSingleton('checkout/session')->setCartWasUpdated(true);
    // set success message
    Mage::getSingleton('core/session')->addSuccess('Product added successfully');
    // page readdir to cart page
    header('Location: ' . 'index.php/checkout/cart/');
}
catch (Exception $exception)
{
    // print exception of code
    echo $exception->getMessage();

10 Best Chatting Apps In India

  The modern world is all about Internet. There was a time when people use to pay high telephone bills to stay in touch with their friends a...