1

I need to check my all categories have proper meta tags (title, description, keywords). Which table stored category meta tags (title, description, keywords) value.

2 Answers 2

3

You can try this ...

require_once('./app/Mage.php');
umask(0);
Mage::app()->setCurrentStore(Mage_Core_Model_App::ADMIN_STORE_ID);

$attributes = array('name', 'meta_title', 'meta_description', 'meta_keywords');
$collection = Mage::getModel('catalog/category')->getCollection()
    ->addAttributeToSelect($attributes);

$out = array();
foreach ($collection as $category) {
    $out[$category->getId()] = array(
        $category->getData('name'),
        $category->getData('meta_title'),
        $category->getData('meta_description'),
        $category->getData('meta_keywords')
    );
}

var_dump($out);

Edit: for CSV-Export:

$fp = fopen('file.csv', 'w');
foreach ($out as $fields) {
    fputcsv($fp, $fields);
}
fclose($fp);
9
  • Fatal error: Call to a member function getModelInstance() on a non-object in /home/xyz/public_html/app/Mage.php on line 463............. how can i solve this....
    – user51361
    Commented Jun 15, 2017 at 9:50
  • Sounds like missing Mage::app() ... updated answer.
    – sv3n
    Commented Jun 15, 2017 at 9:54
  • working good, how can i export by csv
    – user51361
    Commented Jun 15, 2017 at 9:57
  • Updated answer.
    – sv3n
    Commented Jun 15, 2017 at 10:02
  • is my code right codesend.com/view/4ec0b58a35521779ecd7cb2d54659a44
    – user51361
    Commented Jun 15, 2017 at 10:11
1

This data is all in either catalog_category_entity_text or catalog_category_entity_varchar tables. The following sql will get all the category names (and paths just in case you have duplicate category names) where the description is NULL. You will have to find the relevant entity_id values for the other data you want. (The values I have given below are specifically for my database - yours may be different). I hope this gets you started

select ccev.value as name,ccet.value as description,cce.path from catalog_category_entity cce 
join catalog_category_entity_text ccet on cce.entity_id = ccet.entity_id
join catalog_category_entity_varchar ccev on cce.entity_id =ccev.entity_id
where ccet.attribute_id='44'
and ccev.attribute_id='41'
and ccet.value is NULL
6
  • Actually above query display only main category, All my main category have meta tags, still showing null value, how can I solve this and, how can I view my child category and grandchild category details also.
    – user51361
    Commented Jun 15, 2017 at 9:24
  • It's returning all categories for me :/ @sv3n 's approach is probably better ;)
    – jscar
    Commented Jun 15, 2017 at 9:45
  • could you pls send me your result screen shots, for clarifying my doubt.
    – user51361
    Commented Jun 15, 2017 at 9:52
  • my result : snag.gy/TByR81.jpg
    – user51361
    Commented Jun 15, 2017 at 9:56
  • my result snag.gy/Pp2VAQ.jpg showing a similar path structure. What are you expecting to see?
    – jscar
    Commented Jun 15, 2017 at 10:00

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.