As the title says, I want to be able to display some information in the product page that only appears for admins logged in.

  • 1st question: How do I define an user (client) in frontend as admin?
  • 2nd question: How do I show that information (inside a div for example) only to the clients that I want, or in this case, are admins?

Is this possible?

  • It is not possible. FE and BE are separate codes and sessions. – Sanju Nov 8 '19 at 13:25
  • @Sanju looking for another alternative, do you think I can show a product attribute only for one type of customer group? that way I define a customer group for my admins and then only them can read the info I need them to read – Tiago Costa Nov 8 '19 at 14:05
  • Yes, that is possible. You can easily fetch a customer group in front. – Sanju Nov 8 '19 at 14:20
  • @Sanju Ok, thank you! :) – Tiago Costa Nov 8 '19 at 14:36

I made an helper that accordingly to the customerId on frontend, returns true or false if he's admin (all you gotta do is place the customerId that is an admin frontend's account).

public function isAdmin(){
        $customerId = $this->_customerSession->getId();

        if($customerId == 3){
            return true;
        } else return false;

        return false;
  • Might want to be mindful of FPC too with this approach – Rhys - SproutDesk Jan 13 at 16:33
  • @Rhys-SproutDesk you're not wrong.. how do you think I should proceed instead of doing this? – Tiago Costa Jan 13 at 18:15

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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