Posting in the Magento forums has been disabled pending the implementation of a new and improved forum solution which should better serve the community.

For new questions please post at magento.stackexchange.com, the community-run support site for the Magento community. We will be providing updates on the new forum solution soon. For questions or concerns please email community@magento.com.

Magento Forum

View Category only if logged in
 
tilzinger
Sr. Member
 
Total Posts:  126
Joined:  2007-12-27
 

My client needs to disable the viewing of all products in a specific category unless the user is logged in. There is a plug-in out there that completely disables the category, but that also means removing it from the navigation, and not telling the user they can’t see the contents because they are not logged in. I just wanted to share what I did if others are looking for a similar solution. It’s a down and dirty solution, but it works…

/template/catalog/category/view.html

<?php $disallowCategories 
= array(14); ?>
<?php 
if(in_array($this->getCurrentCategory()->getId(), $disallowCategories) and Mage::getSingleton'customer/session' )->isLoggedIn() == 0): ?>

    
<div class="category-description">
        <
p>Sorryyou need to be logged in to view <?php echo $this->getCurrentCategory()->getName(); ?>.</p>
        <
p><a href="/catalog/customer/account/login">Login or create an account</a></p>
    </
div>

<?php else: ?>

... rest of file's code...

<?php endif; ?>

Note that this will not stop the user from directly accessing the products if they know the URL, but in my client’s case, it isn’t a big deal if the user does this.

 
Magento Community Magento Community
Magento Community
Magento Community
Magento Community
Magento Community
Back to top