Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Customer Session says I'm not logged in while I am #8332

Closed
kanduvisla opened this issue Jan 30, 2017 · 4 comments
Closed

Customer Session says I'm not logged in while I am #8332

kanduvisla opened this issue Jan 30, 2017 · 4 comments

Comments

@kanduvisla
Copy link
Contributor

kanduvisla commented Jan 30, 2017

When I include the customer session as a dependency in a plugin for the currency symbol module, it states I'm not logged in, while I am. the isLoggedIn()-method returns false, while getCustomerGroupId() returns the ID of the customer group.

Note that I'm getting this when assigned to a customer group with ID '12'. I don't know if it matters, but I've experienced that code that worked before now doesn't.

Preconditions

  1. Magento 2.1.3

Steps to reproduce

Create a plugin for \Magento\CurrencySymbol\Model\System\Currencysymbol::getCurrencySymbol:

di.xml:

<type name="Magento\CurrencySymbol\Model\System\Currencysymbol">
    <plugin name="mimomenda_remove_currency_symbol_for_inc_dealers"
            type="Vendor\Module\Plugin\Magento\CurrencySymbol\Model\System\Currencysymbol"/>
</type>

Currencysymbol.php:

/**
 * @var Session
 */
protected $customerSession;

/**
 * Currencysymbol constructor.
 * @param Session $customerSession
 */
public function __construct(
    Session $customerSession
) {
    $this->customerSession = $customerSession;
}

/**
 * @param \Magento\CurrencySymbol\Model\System\Currencysymbol $subject
 * @param $symbol
 * @return mixed
 */
public function afterGetCurrencySymbol(\Magento\CurrencySymbol\Model\System\Currencysymbol $subject, $symbol)
{
    // will return false:
    if ($this->customerSession->isLoggedIn()) {
        return 'X';
    }

    return $symbol;
}

Also check on another spot in the code if the customer is logged in. You'll notice that then isLoggedIn() will return the proper value.

I've looked at the isLoggedIn()-method, and noticed that it looks at getCustomerId(). The weird part is that in my plugin getCustomerId() will return NULL, but getCustomerGroupId() will return the correct group ID.

@kanduvisla
Copy link
Contributor Author

Hm, I'm currently experiencing the same effect in a piece of code that used to work before. Perhaps an interesting side-detail: my customer is logged in under customer group with ID '12'. I'll update the original ticket.

@kanduvisla
Copy link
Contributor Author

I think I already answered my own ticket in another ticket that's mine (oh irony). It seems that it's the checkIfDePersonalize()-method again ...

#6624

I try to confirm this and close this ticket if needed.

@veloraven
Copy link
Contributor

@kanduvisla thank you for your submission.
Is there any update on this issue?
Can it be closed now or should it be treated as an issue? If so please add expected result and actual result sections to the description.

@kanduvisla
Copy link
Contributor Author

@veloraven Yes, it was the same issue feature... Blocks that are cached will be stripped from customer session data. Which makes sense...

I'll close this ticket.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants