To find a customer by first login

Magento 1.6.

Can I find out inside the login processing code when the user / client logged in for the first time?

+4
source share
2 answers

If your Magento is not configured to use the double option (email confirmation) to register customers, you can use what is already posted on @PauGNU:

$created_at = $customer->getCreatedAt(); 

But when it comes to double selection, Magento immediately creates a client account, that is, sets created_at to the current system time, but does not activate it (so that the client cannot log in before confirmation) and sends a confirmation mail.

This means an unplanned delay (minutes, days, weeks, etc.) between created_at and the very first login, so created_at will no longer be used.

Actually, Magento has a place where the user login is tracked by default: the table field log_customer.login_at , available, for example, Mage_Log_Model_Customer .

But if you plan to use it:

  • By default, the class has no way to get the very first login. You will need to develop this yourself.
  • If Log Cleanup is active (to save the database less), you will lose the saved logon times.

In this case, I would prefer to identify the most suitable event, connect to it and save only the first login time for each client in a separate table.

+3
source

Given that the first login is always when the client is registered on the network, you only need to check the "created_at" field in the customer_entity table.

If you download a client, it is very easy to get this data:

 $created_at = $customer->getCreatedAt(); 
0
source

Source: https://habr.com/ru/post/1384883/


All Articles