本文整理汇总了PHP中Magento\Customer\Api\CustomerRepositoryInterface::get方法的典型用法代码示例。如果您正苦于以下问题:PHP CustomerRepositoryInterface::get方法的具体用法?PHP CustomerRepositoryInterface::get怎么用?PHP CustomerRepositoryInterface::get使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Magento\Customer\Api\CustomerRepositoryInterface
的用法示例。
在下文中一共展示了CustomerRepositoryInterface::get方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: run
/**
* {@inheritdoc}
*/
public function run()
{
$this->logger->log('Installing orders:');
foreach ($this->fixtures as $file) {
$fileName = $this->fixtureHelper->getPath($file);
$csvReader = $this->csvReaderFactory->create(['fileName' => $fileName, 'mode' => 'r']);
$isFirst = true;
foreach ($csvReader as $row) {
if ($isFirst) {
$customer = $this->customerRepository->get($row['customer_email']);
if (!$customer->getId()) {
continue;
}
/** @var \Magento\Sales\Model\Resource\Collection $orderCollection */
$orderCollection = $this->orderCollectionFactory->create();
$orderCollection->addFilter('customer_id', $customer->getId());
if ($orderCollection->count() > 0) {
break;
}
}
$isFirst = false;
$orderData = $this->converter->convertRow($row);
$this->orderProcessor->createOrder($orderData);
$this->logger->logInline('.');
}
}
}
示例2: install
/**
* {@inheritdoc}
*/
public function install(array $fixtures)
{
foreach ($fixtures as $file) {
$fileName = $this->fixtureManager->getFixture($file);
if (!file_exists($fileName)) {
continue;
}
$rows = $this->csvReader->getData($fileName);
$header = array_shift($rows);
$isFirst = true;
foreach ($rows as $row) {
$data = [];
foreach ($row as $key => $value) {
$data[$header[$key]] = $value;
}
$row = $data;
if ($isFirst) {
$customer = $this->customerRepository->get($row['customer_email']);
if (!$customer->getId()) {
continue;
}
/** @var \Magento\Sales\Model\ResourceModel\Collection $orderCollection */
$orderCollection = $this->orderCollectionFactory->create();
$orderCollection->addFilter('customer_id', $customer->getId());
if ($orderCollection->count() > 0) {
break;
}
}
$isFirst = false;
$orderData = $this->converter->convertRow($row);
$this->orderProcessor->createOrder($orderData);
}
}
}
示例3: execute
/**
* Customer locking implementation
*
* @param \Magento\Framework\Event\Observer $observer
* @return $this
*/
public function execute(\Magento\Framework\Event\Observer $observer)
{
$username = $observer->getEvent()->getData('username');
$customer = $this->customerRepository->get($username);
if ($customer && $customer->getId()) {
$this->accountManagementHelper->processCustomerLockoutData($customer->getId());
$this->customerRepository->save($customer);
}
return $this;
}
示例4: createOrder
/**
* @param array $orderData
* @return void
*/
public function createOrder($orderData)
{
$this->setPhraseRenderer();
if (!empty($orderData)) {
$orderCreateModel = $this->processQuote($orderData);
if (!empty($orderData['payment'])) {
$orderCreateModel->setPaymentData($orderData['payment']);
$orderCreateModel->getQuote()->getPayment()->addData($orderData['payment']);
}
$customer = $this->customerRepository->get($orderData['order']['account']['email'], $this->storeManager->getWebsite()->getId());
$orderCreateModel->getQuote()->setCustomer($customer);
$orderCreateModel->getSession()->setCustomerId($customer->getId());
$order = $orderCreateModel->importPostData($orderData['order'])->createOrder();
$orderItem = $this->getOrderItemForTransaction($order);
$this->invoiceOrder($orderItem);
$this->shipOrder($orderItem);
if ($orderData['refund'] === "yes") {
$this->refundOrder($orderItem);
}
$registryItems = ['rule_data', 'currently_saved_addresses', 'current_invoice', 'current_shipment'];
$this->unsetRegistryData($registryItems);
$this->currentSession->unsQuoteId();
$this->currentSession->unsStoreId();
$this->currentSession->unsCustomerId();
}
}
示例5: getCustomerIdByEmail
/**
* @param string $customerEmail
* @return int|null
*/
protected function getCustomerIdByEmail($customerEmail)
{
$customerData = $this->customerRepository->get($customerEmail);
if ($customerData) {
return $customerData->getId();
}
return null;
}
示例6: loginViaCustomerAttributeOrEmail
/**
* Process login by customer attribute or email
*
* @param string $username Username
* @return bool|\Magento\Customer\Api\Data\CustomerInterface
*/
private function loginViaCustomerAttributeOrEmail($username)
{
$customer = $this->findCustomerByLoginAttribute($username);
if (false === $customer) {
$customer = $this->customerRepository->get($username);
}
return $customer;
}
示例7: testDeleteById
/**
* @magentoAppArea adminhtml
* @magentoDataFixture Magento/Customer/_files/customer.php
* @magentoAppIsolation enabled
*/
public function testDeleteById()
{
$fixtureCustomerEmail = 'customer@example.com';
$fixtureCustomerId = 1;
$this->customerRepository->deleteById($fixtureCustomerId);
/** Ensure that customer was deleted */
$this->setExpectedException('Magento\\Framework\\Exception\\NoSuchEntityException', 'No such entity with email = customer@example.com, websiteId = 1');
$this->customerRepository->get($fixtureCustomerEmail);
}
示例8: getAccountInformation
/**
* @param string $email
* @return array
*/
protected function getAccountInformation($email)
{
$customer = $this->customerRepository->get($email);
$account = ['email' => $customer->getEmail(), 'group_id' => $customer->getGroupId()];
foreach ($customer->getAddresses() as $customerAddress) {
if ($customerAddress->isDefaultBilling()) {
$account['billing_address'] = $this->getAddresses($customerAddress);
}
if ($customerAddress->isDefaultShipping()) {
$account['shipping_address'] = $this->getAddresses($customerAddress);
}
}
return $account;
}
示例9: isEmailAvailable
/**
* {@inheritdoc}
*/
public function isEmailAvailable($customerEmail, $websiteId = null)
{
try {
if ($websiteId === null) {
$websiteId = $this->storeManager->getStore()->getWebsiteId();
}
$this->customerRepository->get($customerEmail, $websiteId);
return false;
} catch (NoSuchEntityException $e) {
return true;
}
}
示例10: iAmLoggedInAs
/**
* @Given I am logged in as :customerEmail
*/
public function iAmLoggedInAs($customerEmail)
{
$this->customer = $this->customerRepository->get($customerEmail);
}