php - Magento 避免有条件的谷歌抓取

标签 php magento seo google-crawlers

<分区>

基于某些产品属性,我们如何告诉 Google,不要在 Magento 1.X 中索引产品详细信息页面

最佳答案

你可以尝试一个监听“controller_action_layout_generate_blocks_after”的观察者方法,并从中获得灵感

Mage_ConfigurableSwatches_Model_Observer::convertLayerBlock

然后您可以在观察者方法中执行以下操作:

$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');
    }
}

关于php - Magento 避免有条件的谷歌抓取,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/47468763/

相关文章:

http - 我应该使用哪种类型的重定向到连接页面?

seo - mathjax 方程如何影响 seo?插入我的方程式的图像会更好吗?

php - Doctrine2+Symfony2 : How can I store entities and mappings in separate bundles?

magento 将捆绑商品直接从追加销售添加到购物车 - 预定义选项

php - Magento 中的“news_from_date”

magento - 如何检查购物车中是否已添加Magento产品?

.htaccess - 当您需要多个处理页面时,将 SEO URL 与 PHP 结合使用

php - group by laravel eloquent 子查询结果之和

php - 使用 IP 地址浏览网站时 PHP session 是否可能过期?

php - 这个正则表达式在 PHP 中意味着什么?