Is there a way to conditionally add a block in my magento layout based on whether the current customer is part of a group or not?
or would this be something better handled in the controller?
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
It would be nice to use something like
customer_logged_inandcustomer_logged_outbut sadly that doesn’t exist… yet.Let’s copy the same technique. To start with you’ll need to make a module with this in the config:
In the
CUSTOM_MODULE_Model_Observerclass add this method:Now in layout files you can use the customer groups.
Additionally, this method doesn’t let you directly specify blocks per page but you can work around that. Here is an example that creates a new location for product pages only, on all other pages the update should have no effect and fail gracefully.