Skip to content

Instantly share code, notes, and snippets.

@yireo
Created July 31, 2017 14:15
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save yireo/9b3d61763ecff96d7fbec16f9d942629 to your computer and use it in GitHub Desktop.
Save yireo/9b3d61763ecff96d7fbec16f9d942629 to your computer and use it in GitHub Desktop.
<?php
// Basic settings
$storeCodes = array('bork');
$attributes = array('name', 'description');
$categoryIds = array();
// Initialize Magento
require_once 'app/Mage.php';
Mage::app();
Mage::app()->setCurrentStore(Mage_Core_Model_App::ADMIN_STORE_ID);
// Load the category-collection
$categoryCollection = Mage::getModel('catalog/category')->getCollection();
if(!empty($categoryIds)) {
$categoryCollection->addAttributeToFilter('entity_id', array('in' => $categoryIds));
}
// Loop through the category-collection
$totalChars = 0;
foreach($categoryCollection as $category) {
$categoryTranslator = Mage::getModel('googletranslate/category');
$categoryTranslator->translate($category, $attributes, $storeCodes);
$totalChars = $totalChars = $categoryTranslator->getCharCount();
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment