I am have been working on a payment method where I need Current Quote

So I used

\Magento\Checkout\Model\SessionFactory $checkoutSession

and then get Quote from the Checkout session using


one of my fellow developer who was reviewing my code has told me to use Session instead of SessionFactory

I know some differences but I am not sure why he changed it and what you guys prefer to use

I have checked This Question but haven't got a satisfactory answer

Thank you

1 Answer 1


You don't need to use a factory for the class \Magento\Checkout\Model\Session because factories are used when we want to get a completely new object without any data inside it and then fill it with data based on something (usually an ID).

In this case, each customer will have at most one active quote stored in the session and you are retrieving this active quote from the session.

You are not loading any object directly for avoiding any shared object instance.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.