cancel
Showing results for 
Search instead for 
Did you mean: 

1.9.2.0 Product list toolbar - modification

1.9.2.0 Product list toolbar - modification

Dear all,
I would like to show/hide toolbar depending on the XML layout update:

<reference name="content">
    <block type="catalog/product_list" name="some_name" template="catalog/product/list.phtml">
        <block type="catalog/product_list_toolbar" name="some_name_tool" template="catalog/product/list/toolbar.phtml">
            <action method="setToolbarEnabled"><enabled>true</enabled></action>
        </block>
        <action method="setCategoryId"><category_id>24</category_id></action>
        <action method="setColumnCount"><count>4</count></action>
    </block>

I've created following field and methods in Mage_Catalog_Block_Product_List_Toolbar class:

 

 

     /**
     * @var bool $_toolbarEnabled
     */
    protected $_toolbarEnabled = true;

    public function setToolbarEnabled($enabled) {
		if($enabled === 'false') 
			$this->_toolbarEnabled = false;
		else
			$this->_toolbarEnabled = true;
		return $this;
	}
	
	public function getToolbarEnabled() {
		return $this->_toolbarEnabled ? 1 : 0;
	}

Of course I've also updated toolbar.phtml to get the _toolbarEnabled variable into account;

The strange thing - when I add some debug info to setToolbarEnable method (eg. echo variable before return $this), it tells me that variable has been switched to false. But, the toolbar is still visible. 
I've used spl_object_hash() method to determine if the toolbar instance showing debug info and the one visible are the same, but they are not. What I'm doing wrong? Please help...