Как я могу получить данные клиента от Observer после успешного входа в систему?
-
16-10-2019 - |
Вопрос
Я сделал пользовательский модуль, в котором у меня есть файл наблюдателя. Мне нужно отобразить всю информацию о зарегистрированном пользователе.
Решение
Используйте мероприятие customer_login
:
<customer_login>
<observers>
<yourobservername>
<type>model</type>
<class>yourmodule/path_to_class</class>
<method>customerLogin</method>
</yourobservername>
</observers>
</customer_login>
Ваш класс наблюдателя будет выглядеть так:
class YourCompany_YourModule_Model_Observer
{
public function customerLogin($observer)
{
$customer = $observer->getCustomer();
}
}
Другие советы
Попробуй это
if($customer = Mage::getSingleton('customer/session')->isLoggedIn()) {
$customer = Mage::getSingleton('customer/session')->getCustomer();
$customerData = Mage::getModel('customer/customer')->load($customer->getId())->getData();
//for firstname
$customerFirstName = $customerData['firstname'];
}
Не связан с magento.stackexchange