Magento – Remove toolbar from product list via local.xml

blockslayout

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.

Best Answer

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 :)