magento - Remove where filter from Zend DB Select -
how remove condition on zend_db_select? i've magento collection added condition using addattributetofilter method varien_data_collection_db. need remove condition. possible?
more info
i've magento widget loads collection based on attribute. widget this:
$collection->addattributetofilter($attributecode, array('notnull'->true));
the widget adds following filter, limit results products have name starting letter:
collection->addattributetofilter('name', array('like'-> $letter.'%'));
however, client's custom toolbar needs index of products first letter, [a][b][c][d]...[z], when click on link, product collection filtered products starting first letter. problem catalog/product_list_toolbar toolbar block uses same product collection parent catalog/product_list block. toolbar's product collection filtered letter.
workaround
here's hacky solution. added following code widget using php's reflection:
$lettercollection = clone $this->_productcollection; $letterselect = clone $lettercollection->getselect(); $reflectionclass = new reflectionclass($lettercollection); $reflectionproperty = $reflectionclass->getproperty('_select'); $reflectionproperty->setaccessible(true); $reflectionproperty->setvalue($lettercollection, $letterselect); $lettercollection->addattributetoselect('name'); $toolbar = $this->getchild('toolbar'); $toolbar->setlettercollection($lettercollection); $this->_productcollection->addfieldtofilter('name', array('like' => "$letter%"));
in extended toolbar (namespace_module_block_toolbar extends mage_catalog_block_product_list_toolbar), unfiltered collection:
$collection = $this->getlettercollection();// $this->getcollection() filtered collection
there should way remove filter magento collection.
just call reset
$select->reset(zend_db_select::where);
Comments
Post a Comment