4

如果我通过以下方式加载客户:

$customer = Mage::getModel('customer/customer')
    ->load($customer_id);

有什么区别:

$customer -> getDefaultShippingAddress();

$customer -> getPrimaryShippingAddress();

提前致谢!

4

2 回答 2

7

他们返回相同的结果

见/app/code/core/Mage/Customer/Model/Customer.php

 /*
 * @return Mage_Customer_Model_Address
 */
public function getPrimaryBillingAddress()
{
    return $this->getPrimaryAddress('default_billing');
}

/**
 * Get customer default billing address
 *
 * @return Mage_Customer_Model_Address
 */
public function getDefaultBillingAddress()
{
    return $this->getPrimaryBillingAddress();
}
于 2012-10-14T15:48:15.553 回答
1

什么都没有,因为 getDefaultShippingAddress() 在内部调用 getPrimaryShippingAddress()。您可以在 /app/code/local/Mage/Customer/Model/Customer.php 中自己检查代码

/**
 * Get default customer shipping address
 *
 * @return Mage_Customer_Model_Address
 */
public function getPrimaryShippingAddress()
{
    return $this->getPrimaryAddress('default_shipping');
}

/**
 * Get default customer shipping address
 *
 * @return Mage_Customer_Model_Address
 */
public function getDefaultShippingAddress()
{
    return $this->getPrimaryShippingAddress();
}
于 2012-10-14T15:47:33.150 回答