I have a function to get the customer group ID and in my phtml file if it equals the customer group id I show content. The issue is that when I test it in a production environment the content doesn't seem to show but on a development environment it does. I thought pages were built by Customer Group


public function __construct(
    \Magento\Customer\Model\Session $customerSession
) {
    $this->_customerSession = $customerSession;

public function getGroupId()
        return $this->_customerSession->getCustomer()->getGroupId();

    return '';


     <?php if($block->getGroupId() == 1): ?>
        <p> content messaging </p>
    <?php endif; ?>

Your Answer

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

Browse other questions tagged or ask your own question.