Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

loadByEmail and load method issue in Magento in Customer Model

Tags:

php

magento

i getting error while i am try to use get Entity Id (getEntityId()) Method in customer/customer model object.

Please check my bellow's code.

I want to use bellow's code. But its showing error.

$customer = Mage::getModel("customer/customer"); 
$customer->setWebsiteId(Mage::app()->getWebsite()->getId());
$customer->loadByEmail('[email protected]'); //load customer by email id

While bellow's code is working fine. with getEntityId()

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

So Please give solution for loadByEmail() method.

like image 991
Dixit Patel Avatar asked Jul 15 '14 13:07

Dixit Patel


1 Answers

The store website code is wrong, it should be Mage::app()->getStore()->getWebsiteId()

Here modified code is

$customer = Mage::getModel("customer/customer"); 
 $customer->setWebsiteId(Mage::app()->getStore()->getWebsiteId());
 $customer->loadByEmail('[email protected]')
like image 180
Amit Bera Avatar answered Oct 21 '22 00:10

Amit Bera