Magento: 고객 정보 얻기 Get Customer's Full Name, First Name, Last Name and Email Addres

3767 단어
1. 로그인한 고객 정보 얻기
// Check if any customer is logged in or not
if (Mage::getSingleton('customer/session')->isLoggedIn()) {
 
    // Load the customer's data
    $customer = Mage::getSingleton('customer/session')->getCustomer();
 
    $customer->getPrefix();
    $customer->getName(); // Full Name
    $customer->getFirstname(); // First Name
    $customer->getMiddlename(); // Middle Name
    $customer->getLastname(); // Last Name
    $customer->getSuffix();
 
    // All other customer data
    $customer->getWebsiteId(); // ID
    $customer->getEntityId(); // ID
    $customer->getEntityTypeId(); // ID
    $customer->getAttributeSetId(); // ID
    $customer->getEmail();
    $customer->getGroupId(); // ID
    $customer->getStoreId(); // ID
    $customer->getCreatedAt(); // yyyy-mm-ddThh:mm:ss+01:00
    $customer->getUpdatedAt(); // yyyy-mm-dd hh:mm:ss
    $customer->getIsActive(); // 1
    $customer->getDisableAutoGroupChange();
    $customer->getTaxvat();
    $customer->getPasswordHash();
    $customer->getCreatedIn(); // Admin
    $customer->getGender(); // ID
    $customer->getDefaultBilling(); // ID
    $customer->getDefaultShipping(); // ID
    $customer->getDob(); // yyyy-mm-dd hh:mm:ss
    $customer->getTaxClassId(); // ID
}

 
2. 데이터베이스 조회
<?php
include 'app/Mage.php';
Mage::app();

$query = "iKeepStudying.com";

$model = Mage::getSingleton('customer/customer');

$result = $model->getCollection()
        ->addAttributeToSelect('*')
        ->addAttributeToFilter('firstname', array('like' => "%$query%"));

foreach($result as $r) 
{       
        $customer = $model->load($r->getId());
        echo '<b>'.$customer->getFirstname().' '.$customer->getLastname().'</b><br/>';
}

 
혹은
$model = Mage::getModel('customer/customer');

$customers = $model->getCollection()
				->addAttributeToSelect('*')
            	->addFieldToFilter('email','[email protected]'); // search

foreach($customers as $customer) 
{       
        $customer = $model->load($customer->getId());
        echo '<b>'.$customer->getFirstname().' '.$customer->getLastname().'</b><br/>';
}

 
혹은
$model = Mage::getResourceModel('customer/customer_collection');

$customers = $model->addAttributeToSelect('*')
            	->addFieldToFilter('email','[email protected]'); // search

foreach($customers as $customer) 
{       
        $customer = Mage::getModel('customer/customer')->load($customer->getId());
        echo '<b>'.$customer->getFirstname().' '.$customer->getLastname().'</b><br/>';
}

 
 
다음 함수에 사용됩니다.
Mage::getResourceModel()
Mage::getModel()
Mage::getSingleton()

 
그들의 차이점: Magento: Mage::get Resource Model, Mage::get Model과 Mage::get Singleton ()의 차이
 
다음으로: Magento: 고객 정보 얻기 Get Customer's Full Name, First Name, Last Name and Email Address
 
 
 
 

좋은 웹페이지 즐겨찾기