本文整理汇总了PHP中Magento\Customer\Model\Customer::load方法的典型用法代码示例。如果您正苦于以下问题:PHP Customer::load方法的具体用法?PHP Customer::load怎么用?PHP Customer::load使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Magento\Customer\Model\Customer
的用法示例。
在下文中一共展示了Customer::load方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: beforeSubscribeCustomerById
public function beforeSubscribeCustomerById($subscriber, $customerId)
{
$subscriber->loadByCustomerId($customerId);
$storeId = $subscriber->getStoreId();
if ($this->_helper->isMageiaEnabled($storeId)) {
$customer = $this->_customer->load($customerId);
$mergeVars = $this->_helper->getMergeVars($customer);
$api = $this->_api;
/*
$isSubscribeOwnEmail = $this->_customerSession->isLoggedIn()
&& $this->_customerSession->getCustomerDataObject()->getEmail()
== $subscriber->getSubscriberEmail();
if ($this->_helper->isDoubleOptInEnabled($storeId)
&& !$isSubscribeOwnEmail
) {
$status = 'pending';
} else {
$status = 'subscribed';
}
*/
$email = ['email' => $customer->getEmail()];
if ($mergeVars) {
$email['variables'] = $mergeVars;
}
$data = ['emails' => json_encode([$email])];
$listId = $this->_helper->getDefaultList();
$return = $api->listCreateMember($listId, $data);
if (isset($return->result) && $return->result) {
$subscriber->setMageiaId($customer->getEmail());
$subscriber->save();
}
}
return [$customerId];
}
示例2: beforeSubscribeCustomerById
public function beforeSubscribeCustomerById($subscriber, $customerId)
{
$subscriber->loadByCustomerId($customerId);
$storeId = $subscriber->getStoreId();
if ($this->_helper->isMonkeyEnabled($storeId)) {
$customer = $this->_customer->load($customerId);
$mergeVars = $this->_helper->getMergeVars($customer);
$api = $this->_api;
$isSubscribeOwnEmail = $this->_customerSession->isLoggedIn() && $this->_customerSession->getCustomerDataObject()->getEmail() == $subscriber->getSubscriberEmail();
if ($this->_helper->isDoubleOptInEnabled($storeId) && !$isSubscribeOwnEmail) {
$status = 'pending';
} else {
$status = 'subscribed';
}
if ($mergeVars) {
$data = array('list_id' => $this->_helper->getDefaultList(), 'email_address' => $customer->getEmail(), 'email_type' => 'html', 'status' => $status, 'merge_fields' => $mergeVars);
} else {
$data = array('list_id' => $this->_helper->getDefaultList(), 'email_address' => $customer->getEmail(), 'email_type' => 'html', 'status' => $status);
}
$return = $api->listCreateMember($this->_helper->getDefaultList(), json_encode($data));
if (isset($return->id)) {
$subscriber->setMagemonkeyId($return->id);
}
}
return [$customerId];
}
示例3: setUp
/**
* Initialize quote and customer fixtures
*/
public function setUp()
{
$this->_quote = \Magento\TestFramework\Helper\Bootstrap::getObjectManager()->create('Magento\\Sales\\Model\\Quote');
$this->_quote->load('test01', 'reserved_order_id');
$this->_quote->setIsMultiShipping('0');
/** @var \Magento\Customer\Model\Customer $customer */
$this->_customer = \Magento\TestFramework\Helper\Bootstrap::getObjectManager()->create('Magento\\Customer\\Model\\Customer');
$this->_customer->load(1);
/** @var \Magento\Sales\Model\Order\Address $address */
$this->_address = \Magento\TestFramework\Helper\Bootstrap::getObjectManager()->create('Magento\\Sales\\Model\\Quote\\Address');
$this->_address->load(1);
$this->_address->setQuote($this->_quote);
}
示例4: afterSubscribeCustomerById
public function afterSubscribeCustomerById($subscriber)
{
$storeId = $subscriber->getStoreId();
if ($this->_helper->isMonkeyEnabled($storeId)) {
$customer = $this->_customer->load($subscriber->getCustomerId());
$mergeVars = $this->_helper->getMergeVars($customer);
$api = new \Ebizmarts\MageMonkey\Model\Api(array(), $this->_helper);
$isSubscribeOwnEmail = $this->_customerSession->isLoggedIn() && $this->_customerSession->getCustomerDataObject()->getEmail() == $subscriber->getSubscriberEmail();
if ($this->_helper->isDoubleOptInEnabled($storeId) && !$isSubscribeOwnEmail) {
$status = 'pending';
} else {
$status = 'subscribed';
}
$data = array('list_id' => $this->_helper->getDefaultList(), 'email_address' => $subscriber->getEmail(), 'email_type' => 'html', 'status' => $status);
$return = $api->listCreateMember($this->_helper->getDefaultList(), json_encode($data));
if (isset($return->id)) {
$subscriber->setMagemonkeyId($return->id)->save();
}
}
}
示例5: beforeSubscribeCustomerById
public function beforeSubscribeCustomerById($subscriber, $customerId)
{
$subscriber->loadByCustomerId($customerId);
$subscriber->setImportMode(true);
$storeId = $subscriber->getStoreId();
if ($this->_helper->isMonkeyEnabled($storeId)) {
$customer = $this->_customer->load($customerId);
$mergeVars = $this->_helper->getMergeVars($customer);
$api = $this->_api;
$isSubscribeOwnEmail = $this->_customerSession->isLoggedIn() && $this->_customerSession->getCustomerDataObject()->getEmail() == $subscriber->getSubscriberEmail();
if ($this->_helper->isDoubleOptInEnabled($storeId) && !$isSubscribeOwnEmail) {
$status = 'pending';
} else {
$status = 'subscribed';
}
if ($mergeVars) {
$data = ['list_id' => $this->_helper->getDefaultList(), 'email_address' => $customer->getEmail(), 'email_type' => 'html', 'status' => $status, 'merge_fields' => $mergeVars];
} else {
$data = ['list_id' => $this->_helper->getDefaultList(), 'email_address' => $customer->getEmail(), 'email_type' => 'html', 'status' => $status, 'merge_fields' => ['EMAIL' => $customer->getEmail()]];
}
try {
$emailHash = md5(strtolower($customer->getEmail()));
$return = $api->getMember($this->_helper->getDefaultList(), $emailHash);
if (!isset($return->id)) {
$return = $api->listCreateMember($this->_helper->getDefaultList(), json_encode($data));
if (isset($return->id)) {
$subscriber->setMagemonkeyId($return->id)->save();
}
}
$subscriber->setMagemonkeyId($emailHash)->save();
} catch (\Exception $e) {
$this->_helper->log($e->getMessage());
}
}
return [$customerId];
}
示例6: getCustomer
/**
* Retrieve customer model object
*
* @return \Magento\Customer\Model\Customer
*/
public function getCustomer()
{
/**
* @TODO: Remove the method after all external usages are refactored in MAGETWO-19930
* _customer and _customerFactory variables should be eliminated as well
*/
if (null === $this->_customer) {
$this->_customer = $this->_customerFactory->create();
$customerId = $this->getCustomerId();
if ($customerId) {
$this->_customer->load($customerId);
if (!$this->_customer->getId()) {
$this->_customer->setCustomerId(null);
}
}
}
return $this->_customer;
}