2013-08-22 84 views
0

我必須重新生成所有類別的所有url-keys。 當我添加了一些主要類別,我使用從論壇的方式複製他們。 一切都進行得不錯,但,當我複製約20K類我看到:當名具有拋光字母其餘板缺: 舉例:類 名稱:Częścikaroseryjne 應該是:czesci-karoseryjne 副本後: CZMagento爲類別重新生成url-keys

類別的名稱:PROG zwalniajacy 應該是:前衛zwalniajacy 副本後:PR

我在拋光論壇找到解決它(與波蘭字母)的方式,但它僅適用於新增的類別。 現在,當我選擇任何類別,清除url-key並點擊保存 - 命名是好的,但.......有20k類別... 有人可以寫如何解決它?

回答

0

http://www.errorin.com/open-source/how-to-add-category-programmatically-in-magento-1-7-0-with-custom-field/

require_once 'app/Mage.php'; 
Mage::app('default'); // Default or your store view name. 

//get a new category object 
$category = Mage::getModel('catalog/category'); 
$category->setStoreId(0); // 0 = default/all store view. If you want to save data for a specific store view, replace 0 by Mage::app()->getStore()->getId(). 

//if update 
if ($id) { 
    $category->load($id); 
} 

$general['name'] = "My Category"; 
$general['path'] = "1/2/23"; // catalog path 
$general['description'] = "Great My Category"; 
$general['meta_title'] = "My Category"; //Page title 
$general['meta_keywords'] = "My , Category"; 
$general['meta_description'] = "Some description to be found by meta search robots. 2"; 
$general['landing_page'] = ""; //has to be created in advance, here comes id 
$general['display_mode'] = "PRODUCTS_AND_PAGE"; //static block and the products are shown on the page 
$general['is_active'] = 1; 
$general['is_anchor'] = 0; 
$general['page_layout'] = 'two_columns_left'; 

//$general['url_key'] = "cars";//url to be used for this category's page by magento. 
//$general['image'] = "cars.jpg"; 


$category->addData($general); 

try { 
    $category->save(); 
    echo "Success! Id: ".$category->getId(); 
} 
catch (Exception $e){ 
    echo $e->getMessage(); 
}