本文整理汇总了PHP中Mage_Customer_Model_Customer::getId方法的典型用法代码示例。如果您正苦于以下问题:PHP Mage_Customer_Model_Customer::getId方法的具体用法?PHP Mage_Customer_Model_Customer::getId怎么用?PHP Mage_Customer_Model_Customer::getId使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Mage_Customer_Model_Customer
的用法示例。
在下文中一共展示了Mage_Customer_Model_Customer::getId方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: createFromCustomer
public static function createFromCustomer(Mage_Customer_Model_Customer $customer)
{
/** @var Mage_Log_Model_Customer $logCustomer */
$logCustomer = Mage::getModel('log/customer')->loadByCustomer($customer->getId());
switch ($customer->getGender()) {
case '1':
$gender = 1;
break;
case '2':
$gender = 2;
break;
default:
$gender = 0;
}
$aCustomer = new self();
$aCustomer->email = $customer->getEmail();
$aCustomer->type = 'e';
$aCustomer->gender = $gender;
$aCustomer->id = $customer->getId();
$aCustomer->first_name = $customer->getFirstname();
$aCustomer->last_name = $customer->getLastname();
if (($birthday = $customer->getDob()) !== null) {
$aCustomer->birthday = Aplazame_Sdk_Serializer_Date::fromDateTime(new DateTime($birthday));
}
if (($document_id = $customer->getTaxvat()) !== null) {
$aCustomer->document_id = $document_id;
}
$aCustomer->date_joined = Aplazame_Sdk_Serializer_Date::fromDateTime(new DateTime('@' . $customer->getCreatedAtTimestamp()));
if (($lastLogin = $logCustomer->getLoginAtTimestamp()) != null) {
$aCustomer->last_login = Aplazame_Sdk_Serializer_Date::fromDateTime(new DateTime('@' . $lastLogin));
}
return $aCustomer;
}
示例2: load
public function load($printQuery = false, $logQuery = false)
{
$this->_select = $this->_read->select();
$entityTable = $this->getEntity()->getEntityTable();
$paidTable = $this->getAttribute('grand_total')->getBackend()->getTable();
$idField = $this->getEntity()->getIdFieldName();
$this->getSelect()->from(array('sales' => $entityTable), array('store_id', 'lifetime' => 'sum(sales.base_grand_total)', 'avgsale' => 'avg(sales.base_grand_total)', 'num_orders' => 'count(sales.base_grand_total)'))->where('sales.entity_type_id=?', $this->getEntity()->getTypeId())->group('sales.store_id');
if ($this->_customer instanceof Mage_Customer_Model_Customer) {
$this->getSelect()->where('sales.customer_id=?', $this->_customer->getId());
}
$this->printLogQuery($printQuery, $logQuery);
try {
$values = $this->_read->fetchAll($this->getSelect()->__toString());
} catch (Exception $e) {
$this->printLogQuery(true, true, $this->getSelect()->__toString());
throw $e;
}
$stores = Mage::getResourceModel('core/store_collection')->setWithoutDefaultFilter()->load()->toOptionHash();
if (!empty($values)) {
foreach ($values as $v) {
$obj = new Varien_Object($v);
$storeName = isset($stores[$obj->getStoreId()]) ? $stores[$obj->getStoreId()] : null;
$this->_items[$v['store_id']] = $obj;
$this->_items[$v['store_id']]->setStoreName($storeName);
$this->_items[$v['store_id']]->setAvgNormalized($obj->getAvgsale() * $obj->getNumOrders());
foreach ($this->_totals as $key => $value) {
$this->_totals[$key] += $obj->getData($key);
}
}
if ($this->_totals['num_orders']) {
$this->_totals['avgsale'] = $this->_totals['lifetime'] / $this->_totals['num_orders'];
}
}
return $this;
}
示例3: setCustomerFilter
/**
* Set customer filter
*
* @param Mage_Customer_Model_Customer $customer
* @return Mage_Customer_Model_Resource_Address_Collection
*/
public function setCustomerFilter($customer)
{
if ($customer->getId()) {
$this->addAttributeToFilter('parent_id', $customer->getId());
} else {
$this->addAttributeToFilter('parent_id', '-1');
}
return $this;
}
示例4: loadByCustomer
/**
* Load subscriber by customer
*
* @param Mage_Customer_Model_Customer $customer
* @return array
*/
public function loadByCustomer(Mage_Customer_Model_Customer $customer)
{
$select = $this->_read->select()->from($this->getMainTable())->where('customer_id=:customer_id');
Mage::fireLog($customer->getId(), "loadByCustomer");
$result = $this->_read->fetchRow($select, array('customer_id' => $customer->getId()));
if ($result) {
return $result;
}
$select = $this->_read->select()->from($this->getMainTable())->where('subscriber_email=:subscriber_email');
$result = $this->_read->fetchRow($select, array('subscriber_email' => $customer->getEmail()));
if ($result) {
return $result;
}
return array();
}
示例5: assignCustomerWithAddressChange
public function assignCustomerWithAddressChange(Mage_Customer_Model_Customer $customer, Mage_Sales_Model_Quote_Address $billingAddress = null, Mage_Sales_Model_Quote_Address $shippingAddress = null)
{
if ($customer->getId()) {
$this->setCustomer($customer);
if (!is_null($billingAddress)) {
$this->setBillingAddress($billingAddress);
} else {
$defaultBillingAddress = $customer->getDefaultBillingAddress();
if ($defaultBillingAddress && $defaultBillingAddress->getId()) {
$billingAddress = Mage::getModel('request4quote/quote_address')->importCustomerAddress($defaultBillingAddress);
$this->setBillingAddress($billingAddress);
}
}
if (is_null($shippingAddress)) {
$defaultShippingAddress = $customer->getDefaultShippingAddress();
if ($defaultShippingAddress && $defaultShippingAddress->getId()) {
$shippingAddress = Mage::getModel('request4quote/quote_address')->importCustomerAddress($defaultShippingAddress);
} else {
$shippingAddress = Mage::getModel('request4quote/quote_address');
}
}
$this->setShippingAddress($shippingAddress);
}
return $this;
}
示例6: paytraceCustomer
/**
* EITHER CREATE OR UPDATE THE CUSTOMER
*
* TO CREATE
* http://help.paytrace.com/api-create-customer-profile
*
* TO UPDATE
* http://help.paytrace.com/api-update-customer-profile
*
* TO DELETE
* if $card is empty then we delete the card from paytrace
*
* @param Mage_Customer_Model_Customer $customer
*/
public function paytraceCustomer(Mage_Customer_Model_Customer $customer, Widgetized_Level3_Model_Card $card = null)
{
$defaults = array('UN' => $this->getConfigData('login'), 'PSWD' => $this->getConfigData('trans_key'), 'TERMS' => 'Y', 'METHOD' => 'CreateCustomer', 'CUSTID' => $customer->getId(), 'BNAME' => $customer->getFirstname() . ' ' . $customer->getLastname(), 'CC' => '', 'EXPMNTH' => '', 'EXPYR' => '');
$addressId = $customer->getDefaultBilling();
$billing = Mage::getModel('sales/order_address')->load($addressId);
if ($billing) {
$defaults['BADDRESS'] = $billing->getPostcode();
$defaults['BCITY'] = $billing->getCity();
$defaults['BSTATE'] = $billing->getRegion();
$defaults['BZIP'] = $billing->getPostcode();
$defaults['BCOUNTRY'] = $billing->getCountryId();
}
if ($card) {
$defaults['CC'] = $card->getNumber();
$defaults['EXPMNTH'] = $card->getMonth();
$defaults['EXPYR'] = $card->getYear();
}
try {
$result = $this->call(array_keys($defaults), $defaults);
} catch (Exception $ex) {
$message = $this->__($ex->getMessage());
if ($card) {
$card->setToken($message);
$card->save();
}
}
}
示例7: canShowTab
/**
* Check whether tab can be showed
*
* @return bool
*/
public function canShowTab()
{
if (!$this->_customer) {
return false;
}
return $this->_customer->getId() && $this->_authSession->isAllowed('Mage_Tag::tag');
}
示例8: withCustomer
/**
* @param \Mage_Customer_Model_Customer $customer
* @return $this
*/
public function withCustomer($customer)
{
$this->attributes['customer_id'] = $customer->getId();
$this->attributes['firstname'] = $customer->getFirstname();
$this->attributes['lastname'] = $customer->getLastname();
return $this;
}
示例9: getSubAccounts
public function getSubAccounts(Mage_Customer_Model_Customer $customer)
{
/** @var $collection Cminds_MultiUserAccounts_Model_Resource_SubAccount_Collection */
$collection = $this->getCollection();
$collection->addFieldToFilter('parent_customer_id', $customer->getId());
return $collection;
}
示例10: _sales
/**
* @param Mage_Customer_Model_Customer $customer
*/
protected function _sales(&$customer)
{
$orderTable = $this->_getCoreResource()->getTableName("sales_flat_order");
$_result = $this->_getAdapter()->select()->from($orderTable, array("first_purchase" => new Zend_Db_Expr("MIN(`created_at`)"), "last_purchase" => new Zend_Db_Expr("MAX(`created_at`)"), "purchases_number" => new Zend_Db_Expr("COUNT(`created_at`)"), "lifetime_sales" => new Zend_Db_Expr("SUM(`grand_total`)")))->where("customer_id = ?", $customer->getId());
$customer->addData($this->_getAdapter()->fetchRow($_result));
//setting new data to customer
}
示例11: _saveCustomerAfterOrder
/**
* Save customer
*
* @param Mage_Customer_Model_Customer $order
*/
protected function _saveCustomerAfterOrder($order)
{
if ($this->_customer) {
if (!$this->_customer->getId()) {
$this->_customer->save();
$order->setCustomerId($this->_customer->getId());
$this->getBillingAddress()->setCustomerId($this->_customer->getId());
$this->getShippingAddress()->setCustomerId($this->_customer->getId());
$this->_customer->sendNewAccountEmail();
} else {
$saveCusstomerAddress = false;
if ($this->getBillingAddress()->getSaveInAddressBook()) {
$billingAddress = $this->getBillingAddress()->exportCustomerAddress();
if ($this->getBillingAddress()->getCustomerAddressId()) {
$billingAddress->setId($this->getBillingAddress()->getCustomerAddressId());
}
$this->_customer->addAddress($billingAddress);
$saveCusstomerAddress = true;
}
if ($this->getShippingAddress()->getSaveInAddressBook()) {
$shippingAddress = $this->getShippingAddress()->exportCustomerAddress();
if ($this->getShippingAddress()->getCustomerAddressId()) {
$shippingAddress->setId($this->getShippingAddress()->getCustomerAddressId());
}
$this->_customer->addAddress($shippingAddress);
$saveCusstomerAddress = true;
}
if ($saveCusstomerAddress) {
$this->_customer->save();
}
}
}
}
示例12: setCustomer
/**
* Setter for $_customer
*
* @param Mage_Customer_Model_Customer $customer
* @return Enterprise_Checkout_Model_Cart
*/
public function setCustomer($customer)
{
if ($customer instanceof Varien_Object && $customer->getId()) {
$this->_customer = $customer;
$this->_quote = null;
}
return $this;
}
示例13: subscribe
public function subscribe(Mage_Customer_Model_Customer $parent, $email, $name, $msg = "")
{
$this->setReferralParentId($parent->getId())->setReferralEmail($email)->setReferralName($name);
if ($this->sendSubscription($parent, $email, $name, $msg)) {
return $this->save();
}
return false;
}
示例14: _moveAttributesData
/**
* @param Mage_Customer_Model_Customer $customer
*/
protected function _moveAttributesData($customer)
{
$attributes = array('po_limit' => $this->_poLimitId, 'po_credit' => $this->_poCreditId);
foreach ($attributes as $attributeCode => $attributeId) {
try {
$select = $this->_db->select()->from($customer->getResource()->getTable('customer_entity_int'), array('value'))->where('attribute_id = ?', $attributeId)->where('entity_id = ?', $customer->getId());
$value = $this->_db->fetchOne($select);
if ((int) $value > 0) {
$this->_db->insert($customer->getResource()->getTable('customer_entity_decimal'), array('entity_type_id' => $customer->getEntityTypeId(), 'attribute_id' => $attributeId, 'entity_id' => $customer->getId(), 'value' => (int) $value));
}
} catch (Exception $e) {
}
try {
$this->_db->delete($customer->getResource()->getTable('customer_entity_int'), 'entity_type_id = ' . $customer->getEntityTypeId() . ' AND attribute_id = ' . $attributeId . ' AND ' . 'entity_id = ' . $customer->getId());
} catch (Exception $e) {
}
}
}
示例15: getAllPasswordHashesForCustomer
public function getAllPasswordHashesForCustomer(Mage_Customer_Model_Customer $customer)
{
$passwordHashes = [];
$records = $this->getCollection()->addFilter('customer_id', $customer->getId());
foreach ($records as $record) {
array_push($passwordHashes, $record->getPasswordHash());
}
return $passwordHashes;
}