Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Magento Layered Navigation & SEO

I had a questions about Magento layered navigation & seo.

It appears our site is being indexed with urls that are relevant to attributes for example www.abc.com/exampleproduct?brand=69

This is creating tonnes of issues with duplicate content. Has anyone ever come accross something like this and is there any good solution for it. Inchoo wrote a blog about it here: http://inchoo.net/online-marketing/magento-seo-how-to-handle-problems-caused-by-layered-navigation/ but it did not really come to a solid solution.

Thanks in advance, cm.

like image 374
user962559 Avatar asked Nov 03 '22 15:11

user962559


1 Answers

You can copy your Head.php file (/app/code/core/Mage/Page/Block/Html/Head.php) to the local directory (/app/code/local/Mage/Page/Block/Html/Head.php)

Here is how to implement modification of the new file:

public function getRobots()
    {
        if (empty($this->_data['robots'])) {
            $this->_data['robots'] = Mage::getStoreConfig('design/head/default_robots');
        }

        //Added NOINDEX, FOLLOW for category page with filter(s)
        if(Mage::app()->getFrontController()->getAction()->getFullActionName() == 'catalog_category_view'){
            $appliedFilters = Mage::getSingleton('catalog/layer')->getState()->getFilters();

            //var_dump($appliedFilters);  //<-- uncomment and see filters as array in page source code in meta robots tag.

            if(is_array($appliedFilters) && count($appliedFilters) > 0){
                $this->_data['robots'] = "NOINDEX, FOLLOW";
            }
        }

        return $this->_data['robots'];
    }

P.S. Please also note that you should add some checks for objects exist.

Mage::app()->getFrontController()->getAction()->getFullActionName()
like image 122
Mageworx Avatar answered Nov 09 '22 14:11

Mageworx