Linked Questions

8
votes
7answers
16k views

How can i check whether user is logged in or not in magento 2.0 [duplicate]

How can I check whether user is logged in or not in Magento 2.0 I using phtml file I want to check user logged in or not. <span class="selllink switcher top-links"> <span class="" data-...
6
votes
2answers
10k views

How to check if customer is logged in and get customer Id in magento 2 [duplicate]

How can i check if the customer has logged in to the magento and get the customer details like id, first name, last name, etc., I have tried this in 2 ways 1). Using the session in a block as below ...
4
votes
2answers
2k views

Magento 2: The direct use of ObjectManager is discouraged [duplicate]

when I am check using object manager it gives me warning that The direct use of ObjectManager is discouraged. Inject necessary dependencies via constructor". How to solve this problem and I also want ...
0
votes
2answers
398 views

Changing link being cached [duplicate]

I have modified a themes account_links.phtml file. Client has requested that it just says "Login" and if logged in it should just show "My Account". This is the code I came up with: $objectManager =...
1
vote
2answers
810 views

Checking if customer is logged in only working on account pages [duplicate]

So, I followed the steps in the 2nd answer (by Miroslav Petroff) on this question: How can i check whether user is logged in or not in magento 2.0 The if statement only works correctly when viewing ...
0
votes
2answers
385 views

To check the user in logged in or not in Magento 2 [duplicate]

I have used the following code to check the user is logged or not. It always show me "Login Failed" after the user is logged to the site also. $objectManager = \Magento\Framework\App\ObjectManager::...
3
votes
3answers
62 views

Magento 2 - Check if user is loggen in header.html [duplicate]

I'm trying to create a piece of code to check if the customer is loggen in or not. I read not to use the objectmanager for that, but I don't know where to put which code. What I need: if customer is ...
0
votes
0answers
65 views

Check user logged in or not? [duplicate]

I want to check that user is logged in or not in order to hide add to cart button for guest users. I have created a module in which I have override addtocart.phtml file and added the below code: <?...
0
votes
1answer
35 views

Customer logged in issue Magento 2.3 [duplicate]

After a customer is logged in, when I check if the customer is logged in or not, it returns true only on the customer account page and returns false on every other page like home page, product page, ...
137
votes
7answers
101k views

To use or not to use the ObjectManager directly?

Ok, so yesterday we had a big talk with other people from the Magento community regarding the direct use of the ObjectManager in classes/templates. I'm already aware of the reasons why we shouldn't ...
15
votes
6answers
14k views

How to get current customer group id in magento2

I want to get current customer group id in phtml file. When I am not logged in still it is return general type customer group. How can get proper output?
8
votes
1answer
6k views

magento2 check if customer is logged in or not in knockout template

How do I check if customer is logged in or not in knockout template? my template <!-- ko if: customer().firstname --> <!-- /ko --> my js define( [ 'ko', 'jquery', ...
3
votes
2answers
2k views

After logging in, the user name is not displaying in header section

After logging in, the user name is not displaying between 'Wilkommen' and 'Anmelden' . Which files are responsible for rendering out this part of the header ? How to get the user name of the ...
1
vote
4answers
2k views

Magento 2 check if customer is logged in in admin area

I have the following code to see if a user is logged in. It sort of works as in it works within the customer area (user logged in) but doesn't work outside of the customer area even though the ...
2
votes
3answers
2k views

How to get current customer id in helper class of module in magento2

I want to get current customer id in Helper class of module in magento2. How to get using helper in Magento 2. Can anyone help me?

15 30 50 per page