Magento has the setRobots
method to insert the values in the robots tag within the head block. So you can create a extension to change the head block via observer. In your config.xml add a event to change layout before Magento get layout xml done.
<frontend>
<events>
<controller_action_layout_generate_xml_before>
<observers>
<change_noindex>
<type>singleton</type>
<class>namespace_extension/observer</class>
<method>changeRobots</method>
</change_noindex>
</observers>
</controller_action_layout_generate_xml_before>
</events>
<frontend>
There are other events that you can use to do this, maybe even more elegant than that. But now you can handle the layout settings dynamically:
public function changeRobots($observer) {
if ($observer->getEvent()->getAction()->getFullActionName() === 'catalog_category_view') {
$uri = $observer->getEvent()->getAction()->getRequest()->getRequestUri();
if (stristr($uri, "?")) {
$layout = $observer->getEvent()->getLayout();
$product_info = $layout->getBlock('head');
$layout->getUpdate()->addUpdate('<reference name="head"><action method="setRobots"><value>NOINDEX,FOLLOW</value></action></reference>');
$layout->generateXml();
}
}
}