cancel
Showing results for 
Search instead for 
Did you mean: 

Get customer data outside magneto

Get customer data outside magneto

Hello All,<br />

 

I trying to get customer data outside magento dir using the code below<br />

<?php

require_once 'app/Mage.php';

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

if(Mage::getSingleton('customer/session')->isLoggedIn()){
    $user = Mage::getSingleton('customer/session')->getCustomer();
    echo $user->getId();
}else{
    echo 'session Not Found';
    exit;
}

but this is not working <br />

can anyone till me where the error, or how can I get customer data outside magento ?

2 REPLIES 2

Re: Get customer data outside magneto

Here's the way to get customer data outside magento:

 

<?php

         require_once '<<magento_root_directory>>/app/Mage.php';

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

                        if(Mage::getSingleton('customer/session')->isLoggedIn()){
                                $user = Mage::getSingleton('customer/session')->getCustomer();
                                echo $user->getId();
                        }else{
                                echo 'session Not Found';
                                exit;
                        }
?>

OR


Move File Inside Magento Root Directory.

 

Let me know if you face any query/concern regarding this.

Query solved? Accept as Solution.Thanks
Eric Baily

Re: Get customer data outside Magento

Any idea how to do this in Magento 2.1?