I need to search for some products' custom options (set in Manage Products|Edit Product|Custom Options), the only way I've found is manually filtering the results returned by Magento's search function. The question is: How do I store the info I need, so I can remove products not matching my criteria --once Magento returns its results?
Thanks!
You can use the Mage::registry
approach which stores data per request. To store it:
if(!Mage::registry('custom_search_critera')){ //check not already set
Mage::register('custom_search_critera', $values);
}
To retrieve from another object or function:
$values = Mage::registry('custom_search_critera');
Cheers, JD
In the session of course :) This is the first thing that comes to me and I guess it is the best approach.
For data that you need to persist, use Magento sessions:
Mage::getSingleton('core/session')->setXXX( 'SomeData' ); Mage::getSingleton('core/session')->getXXX();
(where XXX is some identifier, eg setSomeVeryImportantInfo)
I've also found 'customer/session'
and 'admin/session'
.