I need to Change SEO keywords for categories. How can i Bulk Change Category Page Title, Meta Description/Keywords.
2 Answers
i have custom script (not tested)
<?php
ini_set("memory_limit","-1");
ini_set('max_execution_time', 300);
error_reporting(E_ALL | E_STRICT);
ini_set('display_errors', 1);
require_once('app/Mage.php');
Mage::app();
//************************ Import CSV File ************************
// Sample CSV Format
//category_id meta_title meta_description meta_keywords
//1986 Test 123 test test, test123
//1904 Test 123 test test, test123
$file='category.csv';// Name of CSV file
$rows = array_map('str_getcsv', file($file));
$header = array_shift($rows);
$category_ids=array();
$csv=array(); //csv array with key as Category Id
$a=array();
$i=0;
foreach ($rows as $row) {
$csv[] = array_combine($header, $row);
}
/*
************************ Array Format ************************
echo '<pre>';
print_r($csv);
Array
(
[1986] => Array
(
[category_id] => 1986
[meta_title] => Test 123
[meta_description] => test
[meta_keywords] => test, test123
)
[1904] => Array
(
[category_id] => 1904
[meta_title] => Test 123
[meta_description] => test
[meta_keywords] => test, test123
)
)*/
$category_ids=array_keys($csv); // All the Category Id which we want to update
//************************ Load Categories which we want to Update ************************
$category = Mage::getModel('catalog/category');
$tree = $category->getTreeModel();
$tree->load();
$categories = $tree->getCollection()->addAttributeToFilter('entity_id', array('in'=>$category_ids));
$count=0; //Count
foreach($categories as $category)
{
echo $id=$category->getId().' - <a href="'.str_replace('seoupdate','index',$category->getUrl()).'">'.$category->getName().'</a><br>'; // Print name of categories ;just for our info
if($csv[$id]['meta_title'] != '')
$category->setMetaTitle($csv[$id]['meta_title']);
if($csv[$id]['meta_description'] != '')
$category->setMetaDescription($csv[$id]['meta_description']);
if($csv[$id]['meta_keywords'] != '')
$category->setMetaKeywords($csv[$id]['meta_keywords']);
$category->save();
$count++;
}
echo $count.' Categories Updated';
Unlike products by default there's no import/export for categories in Magento. Mage Works created categories import/export functionality on demand for their customer and later on made it available to public Extension Link
You can export your categories in csv file, make changes and upload it back up. I assume it let's you update meta data but you can make sure it does all what you require before installing it.