13

I am used to using local.xml for my layout updates, however I cant seem to remove the toolbar from the product list block using either the remove or unsetChild methods.

Can anyone say if this is actually not possible or am i doing something wrong?

I have tried:

<action method="unsetChild">  
    <alias>toolbar</alias>
</action>

and

<action method="unsetChild">  
    <alias>product_list_toolbar</alias>
</action>

and also the <remove name="" /> methods too but nothing works.

11

And you won't be able to remove it without overriding something. Here is how the getToolbarBlock() method looks like:

public function getToolbarBlock()
{
    if ($blockName = $this->getToolbarBlockName()) {
        if ($block = $this->getLayout()->getBlock($blockName)) {
            return $block;
        }
    }
    $block = $this->getLayout()->createBlock($this->_defaultToolbarBlock, microtime());
    return $block;
} 

This means that if a block with a certain name (value returned bygetToolbarBlockName) exists in the layout then that block will be returned. otherwise a new block is created with type catalog/product_list_toolbar and that is returned by the method.

[EDIT] I just had a crazy idea. Why not change the toolbar block type? That way it won't be rendered as a toolbar. I haven't tried it but I think it's worth it.
Something like:

<reference name="product_list">
    <block type="core/template" name="product_list_toolbar" />
</reference>

I mean adding a block with the same name but a different type. If it doesn't work please don't donwvote; it is just in idea :)

  • 1
    Its code like this that really annoys me with Magento. So now i need to go override classes or templates where some nice layout xml would have sufficed – Marty Wallace May 10 '13 at 21:27
  • I've updated the answer with an idea crazy enough to work. – Marius May 10 '13 at 21:33
  • @MartyWallace - at least there is layout XML in the first place. I think that layout XML falls into the "give a mouse a cookie" category once people know how to use it. – benmarks May 11 '13 at 14:20
  • 1
    Different type can cause problems, as we need the setCollection function to set paging – Alex Jun 18 '13 at 17:33
  • 1
    really frustrating, an even less intrusive hack would be to hide it using jquery with jQuery( document ).ready(function(){jQuery('.limiter').hide();}); – Danny Z Jun 16 '15 at 22:13
8

In your local.xml file add the following:

<catalog_category_default>
    <!-- Remove Toolbar by setting a blank template -->
    <reference name="product_list_toolbar">
        <action method="setTemplate"><template /></action>
    </reference>
</catalog_category_default>
  • For a custom layout update on a category page, this is the best answer. – Joseph at SwiftOtter Jul 5 '17 at 16:31
2

It seems you can't remove this or unset this via XML due to some weird way the devs built the thing. However you can create a blank template and point the toolbars to this blank template instead.

<catalog_category_default>
    <reference name="product_list_toolbar">
        <action method="setTemplate">
            <template>theme/package/blank.phtml</template>
        </action>
    </reference>
</catalog_category_default>
<catalog_category_layered>
    <reference name="product_list_toolbar">
        <action method="setTemplate">
            <template>theme/package/blank.phtml</template>
        </action>
    </reference>
</catalog_category_layered>
<catalogsearch_result_index>
    <reference name="product_list_toolbar">
        <action method="setTemplate">
            <template>theme/package/blank.phtml</template>
        </action>
    </reference>
</catalogsearch_result_index>

That will remove it from Normal categories, Anchored categories and the search page.

Not the answer you're looking for? Browse other questions tagged or ask your own question.