0
這個代碼在magento 2中等價於什麼? Mage :: getModel('customer/customer') - > loadByEmail();magento 2等效於Mage :: getModel('customer/customer') - > loadByEmail();是?
?
這個代碼在magento 2中等價於什麼? Mage :: getModel('customer/customer') - > loadByEmail();magento 2等效於Mage :: getModel('customer/customer') - > loadByEmail();是?
?
請使用此代碼:
<?php
$objectManager = \Magento\Framework\App\ObjectManager::getInstance();
$customer = $objectManager->get('Magento\Customer\Model\Customer');
$customer->setWebsiteId('1');
$customer->loadByEmail('[email protected]');
?>
你也可以試試這個:下面的代碼
protected $customerCollection;
public function __construct(
...
\Magento\Customer\Model\Customer $customerCollection,
...
)
{
...
$this->customerCollection = $customerCollection;
...
}
使用你的函數: -
$customerObj = $this->customerCollection;
$customerObj->setWebsiteId($websiteId);
$customerObj->loadByEmail('[email protected]');