To find customer's first login - magento

Magento 1.6.
Within the login processing code, is it possible to find out when the user/customer has logged in for the very first time?

If your Magento is configured not to use double-opt-in (email confirmation) for customer registrations, then you can use what #PauGNU already posted:
$created_at = $customer->getCreatedAt();
But when it comes to double-opt-in, Magento creates the customer account immediately, i.e. setting created_at to the current system time, but does not activate it (so that customer cannot login before confirming) and only sends a confirmation mail.
This means an unkown delay (minutes, days, weeks, whatever) between created_at and the very first login, so created_at wouldn't be of use anymore.
Actually, Magento has a place, where customer login times are being tracked by default: the table field log_customer.login_at, accessible by Mage_Log_Model_Customer, for example.
But, if you plan to use it:
by default the class has no method to get the very first login. You'd need to develop that yourself.
if "Log Cleaning" is active (to keep the database smaller), you'll gonna lose the saved login times.
In that case, I'd prefer identifying the most proper event, hooking into it and saving only the very first login time per customer to a separate table.

Given that the first login is always when the customer registers itself in the web, you only need to check out the field «created_at» on the customer_entity table.
If you load a customer, it's really easy to get that data:
$created_at = $customer->getCreatedAt();

Related

Want to build an attendance management system using MEAN stack

I want to build an attendance management system using MEAN stack. The application should work like this -
There will be an admin who will control CRUD operations on User and as well as look into the Attendance of each user and have a detailed list of average attendance of the user per month and per year.
There will be a user page and when the user logs in i want to store the date and time in the client side and then send it to the database. So that based on the time and date the admin can see when the user has logged in and mark the user as present for that particular day.
I want to know how to store the date and time in the client side and then pass it onto the database for calculations. Also wanted to know that is it necessary to authenticate in the front end as well?
May be I am late, but I can try to answer your query.
You can store date and time as an object and pass it via request parameters to the backend to store it in the database.
You can take a look a the following on how to get date and time in Javascript How do I get the time of day in javascript/Node.js?

Magento error in admin - Payment method does not exist

I had been using a custom payment module that I had built from scratch to accept payments from a particular gateway company. However, the company has recently uploaded a better magento extension that i have now uploaded.
However, since I also cleared the old files for clarity the order details page no longer opens generating an error that the payment method does not exist.
I am guessing that for each order, Magento would store the payment method in the database. If I can get hold of that attribute and change all old values to the new value id - this error would be taken care of.
I have looked in the sales_flat_order and many other tables but cannot figure out where this value is stored. Can anyone point the actual table and attribute.
This is stored in the method column of the sales_flat_quote_payment and sales_flat_order_payment tables.

How to show only permitted user_type fields on frontend

How would one go about creating a function/plugin for the following?
I have two user_types, FREE and PAID.
Both users have certain fields they can fill in. The PAID user has more fields they can fill in.
If a PAID user reverts back to a FREE user, how can only the FREE fields show on the frontend without showing the already PAID fields?
There must be a way to filter the fields per user_type? I'm very much a noob at writing code.
If anyone could explain and guide me, that would be great.
Cheers,
I have done something like this some time ago for something different. It was about showing content only to users with a specific user level.
You could register new user roles and check whether the current user (of the site, probably logged in) has the appropiate user role to view specific content.
I used is_user_in_role on the frontend and that works fine for me.
Concerning the PAID fields: Let the users fill them with content but add a notice like "Pay to show these fields publicly" on the frontend when he visits his own profile (or whatever you are building). This sometimes works very well for getting more paid users (make sure, you really have a benefit from those fields).

Creating an order processing system from magento?

I want to create a small order processing website, but in time I want the application to be able to extend to an e-commerce solution as well. So I decided to go with magento.
But I am not sure, if magento can be stripped down to only an order processing system. By order processing I want:
Guests should be able select products
Should be able to add products to cart
But at last, instead of processing the order by payment system, the order should be forwarded to email of administrators, who will contact them individually.
How to configure Magento this way??
Here is a full tutorial with all the files you will need, ready to download:
http://www.excellencemagentoblog.com/magento-onestep-checkout-remove-payment-method-step
This does mark orders with the code 'free', however, you words are our servants and not our masters and you could change the word free to 'telesale' (or whatever):
...the basic idea of removing any step from checkout is to see a set a
default value for that step, so that magento order processing runs
smoothly. So when removing the payment method step, i have set the
payment method “Zero Subtotal Checkout” with code “free” as the
default payment method.
If I got you well, you just want to avoid the CC processing,
In this case you can disable in Magento all payment systems except the 'Money/Check' one.
Guests should be able select products
Should be able to add products to cart
But at last, instead of processing the order by payment system, the order should be forwarded to email of administrators, who will
contact them individually.
Magento offers you catalog/cart system by default ( mail is mandatory during order )
Magento offers you cart system by default
You can disable all payment system except 'Money/Check' one. (this will let user confirm their order without any check on the payment).
Then you can contact all user checking the new orders in the backend ( user/guest email will be displayed along with the order display ) ...
Settings
Add email notification for any new orders:
Log in into admin area
Go to System->Configuration
In Sales section, click on Sales Emails
Select the first section Orders.
Enter your admin e-mail in the field “Send Order Email Copy To”.
Now You will receive a new mail every new order.
Manage Payment Methods:
Log in into admin area
Go to System->Configuration
In Sales section, click on Payment Methods
Disable all except Check / Money Orders
Now your customer could order without any payment detail.
I think Magento should suit you, in case the 'Money/Check' payment system is not good for you, you will need to create a new module and add a new payment system.
I hope this helps you answer your doubt
So, as I can understand, you want to finish customers work on the cart step. For example, by clicking Create an Order except Checkout.
Yes, you can use cart2quote or something like this.
The main idea is to save quote with quote items (from the session) after clicking Create an Order button. For example, you can get Quote and serialize it, get Quote items and also serealize them. When it is needed to show them to admin (in email or in admin section) - deserialize all info and display it. This will not be very easy, but is possible. May be it is better to customize some ready solution.

How to get the reference to a model object instance in Magento

I am creating a module dealing with a registration process which requires a certain amount of registration fee from its user. the basic flow is 1)user inputs personal information in the first page, and posts the form to the second page 2) user reviews the information in the second page which contains a PayPal button. 3) after confirmation, user clicks the PayPal button and is redirected the PayPal payment page 4) user is redirected to a success page if transaction is finished or to a cancel page if transaction not finished. I created a table called 'registration' that holds the general info for a registration such as id, register name and etc. In the 'PostAction' function (related to the second page), I set the model attributes by using info from the posted form, but do not call the save() method which I think should be done in the SuccesAction (related to success page). My question is how to get the reference to the model object in the SuccessAction so I can use the save() method to insert it into the database. Also, any suggestion or idea to improve the module is welcomed.
The registration object/model is disposed as soon as the 'postAction' page completes. You cannot get it back unless it has been saved somewhere. That somewhere could be a session variable, but those can expire when you least expect it (see Finagle's Law) so saving to the database is better. Either a separate table or by marking the registration with a status to show it is not yet complete - the 'successAction' would complete the process by setting that marker then saving again.
As an example consider how orders pass through checkout. Until the customer gets to the last step and submits the order, it is only a quote and has been saved in the sales_flat_quote table so far. After that point it is saved in sales_flat_order instead.

Resources