Magento - using toolbar breaks results for custom form-fed query
I’m hoping this is a simple fix for someone better versed in customizing Magento…
I have a custom search form (on home.phtml) and results page (cms loading customresults.phtml) which returns a filtered collection of products, based on POST data entered in the form.
The process: Form > POST values > multiple calcul开发者_如何学JAVAations based on POST > MySQL (core_read) query based on calculation results > product ID array (referred to below as $wow) based on query
Then:
$collection = Mage::getModel('catalog/product')->getCollection()->addAttributeToSelect('*')->addAttributeToFilter('entity_id', array('in'=>$wow))
Mage::getSingleton('catalog/product_visibility')->addVisibleInCatalogFilterToCollection($collection)
$magento_block = Mage::getSingleton('core/layout');
$productsHtml = $magento_block->createBlock('catalog/product_list');
$productsHtml ->setTemplate('catalog/product/list.phtml')->setCollection($collection);
echo $productsHtml ->toHTML();
Results page loads nicely with the correct products showing. Toolbar loads and looks normal.
THE PROBLEM: on changing any setting in the toolbar on the results page, the page reloads and we’re left with no search results.
I assume the reload is killing the POST values…
Is there a way to (A) circumvent the page reload for toolbar functionality? Or alternatively, is it possible to somehow (B) retain the posted data or (C) force data re-submission on reload?
Any tips would be sincerely appreciated.
Solved the problem by using GET method instead of POST.
Not the solution I wanted, but it’s an easy workaround. Just in case anyone else out there is having a similar issue.
精彩评论