Ad

Magento Avoide Conditional Google Crawling

- 1 answer

Based on some product attribute, how do we tell Google, not to indexing product details page in Magento 1.X

Ad

Answer

You can try an observer method which listens to "controller_action_layout_generate_blocks_after", and get inspired by

Mage_ConfigurableSwatches_Model_Observer::convertLayerBlock

And then you can do the below in the observer method:

$front = Mage::app()->getRequest()->getRouteName();
$controller = Mage::app()->getRequest()->getControllerName();
$action = Mage::app()->getRequest()->getActionName();

if ($front == 'catalog' && $controller == 'product' && $action == 'view') {
    $product = Mage::registry('current_product'); 
    if ($product && $product->getYourAttributeName() === "YourDesiredValue") {
        $observer->getLayout()->getBlock('head')->setRobots('NOINDEX,NOFOLLOW');
    }
}
Ad
source: stackoverflow.com
Ad