Vinai / groupscatalog2

Magento extension to enable you to hide categories and products from customers depending on their customer group. This is a Magento 1.6 and newer compatible version of the Netzarbeiter Customer Groups Catalog extension.
139 stars 60 forks source link

Is not hiding the category on my custom menu #81

Closed cloddi closed 10 years ago

cloddi commented 10 years ago

I installed you extension and when i select to hide some category for some customer group is not hiding it from the navigation Bar. But when i click on it it says page not found (that's actually correct) but i'm not able to hide it from the Nav bar.

Any suggestion? Thanks cloddi

Vinai commented 10 years ago

Did you rebuild the groupscatalog category index cache? Did you refresh the block html cache after installation? Which version of Magento are you using? And finally, which version of the extension are you using?

cloddi commented 10 years ago

Yes I did all of the step. I use magento 1.8.1.0 The extension version is 0.3.4 (beta)

Vinai commented 10 years ago

Are you using a native Magento theme to render the menu or a custom theme or extension for that? The reason I'm asking is because custom themes and extensions sometimes use custom code to build the menu, which bypasses the mechanisms Magento has in place for menu customizations.

cloddi commented 10 years ago

yes I use a custom theme (bought it). Is there any way to implement the code?

Vinai commented 10 years ago

Sure, but it will need some debugging to figure out why it doesn't work out of the box.

Generally categories will be loaded as part of a collection, which is an instance of Mage_Catalog_Model_Resource_Category_Collection. In that case the filter to exclude hidden categories will be applied via the event catalog_category_collection_load_before. You can see the matching observer method catalogCategoryCollectionLoadBefore in the Observer.php file.

The alternative to the regular collection is that when the flat catalog category table feature is enabled, an instance of Mage_Catalog_Model_Resource_Category_Flat is used to load the categories. To cover that case the extension has a class rewrite in place, so Netzarbeiter_GroupsCatalog2_Model_Catalog_Resource_Category_Flat will be instantiated instead. In this replacement class the hidden categories are removed by overloading the method _loadNodes().

Now the thing to do is to find out how the theme loads the categories, and then see why the filter isn't applied. Once that is clear it will probably only require a one-line fix.

cloddi commented 10 years ago

thanks for the suggestion but unfortunately i'm not that good on coding and debugging. I tried i bit and well my custom menu phtml is located in* /app/design/frontend/default/vigoshop/template/catalog/navigation/category_nav.phtml*

adn it looks like that:

<?php $_categories = $this->getCurrentChildCategories() ?>
<?php $_count = is_array($_categories)?count($_categories):$_categories->count(); ?>
<?php if($_count): ?>
<div class="block block-category-nav">
    <div class="block-title">
        <strong><span><?php echo Mage::registry('current_category')->getName(); ?></span></strong>
    </div>
    <div class="block-content">
        <div class="akordeon category-list">
        <?php foreach ($_categories as $_category): ?>
            <?php if($_category->getIsActive()): ?>
            <?php
                $children = explode( ",", $_category->getChildren() );
            ?>
            <div class="akordeon-item <?php echo (!$children[0])?'has-no-children':'';?>">
                <div class="akordeon-item-head">
                    <div class="akordeon-item-head-container">
                        <div class="akordeon-heading">
                            <a href="<?php echo $this->getCategoryUrl($_category) ?>"<?php if ($this->isCategoryActive($_category)): ?> class="current"<?php endif; ?>><?php echo $this->htmlEscape($_category->getName()) ?></a>
                        </div>
                    </div>
                </div>
                <?php if($children[0]): ?>
                <div class="akordeon-item-body">
                    <div class="akordeon-item-content">
                        <ul>
                        <?php
                        foreach($children as $child){
                            $_subcat = Mage::getModel( 'catalog/category' )->load( $child );
                        ?>
                            <li>
                                <a href="<?php echo $this->getCategoryUrl($_subcat) ?>"<?php if ($this->isCategoryActive($_subcat)): ?> class="current"<?php endif; ?>><?php echo $this->htmlEscape($_subcat->getName()) ?></a>
                            </li>
                        <?php
                        }
                        ?>
                        </ul>
                    </div>
                </div>
                <?php endif; ?>
            </div>
            <?php endif; ?>
        <?php endforeach ?>
        </div>
    </div>
</div>
<script type="text/javascript">
    jQuery(document).ready(function(){
        jQuery('.akordeon.category-list').akordeon({ buttons: true, toggle: true });
    });
</script>
<?php endif; ?>

Any suggestion? Thanks a lot for your great help.

Vinai commented 10 years ago

I'm afraid I don't really have time to help debug custom code - I'm really sorry to let you down.
All I can do is provide you with a few more tips.

The next step would be to figure out the class name of the PHP class rendering the template.
That can be done using <?php echo get_class($this) ?>. It will then print the class name when the page is reloaded.

Then check the implementation of the method public function getCurrentChildCategories() within that class. Maybe the answer is in that method, maybe it delegates further.

cloddi commented 10 years ago

I Understand. Thank you anyway! Maybe leter i figure it out :+1: I just installed you VinaiKopp_StoreUrlRewrites it works very well. Thank you