I would like to place a static block for specific customer group on the header.phtml file. What is the customer group ID code to place with the block code below? For example the Customer Group ID is 4.

<?php echo $this->getLayout()->createBlock('cms/block')->setBlockId('test-banner-gen')->toHtml(); ?>

Thank you

  • Please check i have added answer hope it's work for you. – Kul Oct 25 '16 at 22:22

You can use below code to show static block for particular customer group if customer is logged In.

/* Check if customer is logged in */

        $isLoggedIn = Mage::getSingleton('customer/session')->isLoggedIn();
    /* If customer is logged in */

        /* Get the logged in customer's group ID */
            $customerGroupId = Mage::getSingleton('customer/session')->getCustomerGroupId();
        /* Check if the logged in customer's group ID matches with the ID you are after */

        if($customerGroupId == 4):
            echo $this->getLayout()->createBlock('cms/block')->setBlockId('test-banner-gen')->toHtml(); 
| improve this answer | |

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.