Skip to content

Instantly share code, notes, and snippets.

@markvds
Created February 25, 2015 09:17
Show Gist options
  • Save markvds/26f57919e5e13a4898b7 to your computer and use it in GitHub Desktop.
Save markvds/26f57919e5e13a4898b7 to your computer and use it in GitHub Desktop.
Magento shell script (place it in /shell) to output all filterable attributes. You can then copy/paste it into robots.txt to effectively stop bots from indexing your layered navigation. See also https://www.byte.nl/blog/zoekmachine-bots-en-serverbelasting/
<?php
require_once 'abstract.php';
class Mage_Shell_Filterable_Attributes extends Mage_Shell_Abstract
{
/**
* Run script
*
*/
public function run()
{
$attributes = Mage::getResourceModel('catalog/product_attribute_collection')
->addIsFilterableFilter();
foreach ($attributes as $attribute) {
echo 'Disallow: /*?' . $attribute->getAttributeCode() . "=*\n";
echo 'Disallow: /*&' . $attribute->getAttributeCode() . "=*\n";
}
}
}
$shell = new Mage_Shell_Filterable_Attributes();
$shell->run();
@hans2103
Copy link

Using the Google Webmaster Tools parameters I can tell Google what the meaning of each and every parameter is. But ... life if bigger then only Google. Bing, Yandex and other search engines are not aware of Google Webmaster Tools parameters. Therefor this script is useful.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment