Skip to content

Instantly share code, notes, and snippets.

@tegansnyder
Created February 19, 2013 18:34
Show Gist options
  • Save tegansnyder/4988585 to your computer and use it in GitHub Desktop.
Save tegansnyder/4988585 to your computer and use it in GitHub Desktop.
Short example of getting customer_id of a Magento customer via email address outside of Magento via direct SQL
<?php
require_once('/site/app/Mage.php');
umask(0);
Mage::app();
//setup the direct sql db conn resource
$db_conn = Mage::getSingleton('core/resource');
$r_conn = $db_conn->getConnection('core_read');
$email = 'tsnyder@tegdesign.com';
$sql = "SELECT entity_id FROM `customer_entity` WHERE email = '". $email . "' LIMIT 1";
$dat = $r_conn->fetchAll($sql);
$customer_id = $dat[0]['entity_id'];
echo $customer_id;
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment