`
kirenenko04
  • 浏览: 146147 次
  • 性别: Icon_minigender_2
  • 来自: 上海
社区版块
存档分类
最新评论

export category list

 
阅读更多
class Mage_Shell_ExportCategory extends Mage_Shell_Abstract
{

    /**
     * Run script
     *
     */
    public function run()
    {
	    ini_set("memory_limit","1000M");
	    umask(0);
	    $category = Mage::getModel ('catalog/category');
	    $tree = $category->getTreeModel();
	    $tree->load();
	    $ids = $tree->getCollection()->getAllIds();
	    $timestamp = time();
	    $file_path = BP.DS.'media'.DS.'export'.DS.'cate_' . $timestamp . '.csv';
	    $fp = fopen($file_path, 'w');
	    
	    if ($ids) {
		    $string='';
		    $heading = fputcsv($fp,array("store","categories","cat_id","is_active","meta_title","meta_keywords","meta_description","include_in_menu","is_anchor","description"));
		    foreach ($ids as $id) {
			    if($id>0)//start if removeroot category and default category .
			    {
				    $cate_cre = Mage::getModel('catalog/category');
				    $cate_cre->load($id);
				    $treeurl='';
				    $cate_cre1=Mage::getModel('catalog/category')->load($id);
				    $treeurl=$cate_cre->getName();
				    if($cate_cre1->getParentId()>0)
				    {
				    	for($i=0; ;$i++) {
				    		if($cate_cre1->getParentId()>0) {
				    			$abc=Mage::getModel('catalog/category')->load($cate_cre1->getParentId());
				    			$pCat=$abc->getName();
				    			if($abc->getId()>1){
				    				$treeurl=$pCat.'/'.$treeurl;
				   		 		}
				    			$cate_cre1=$abc;
			    			} else{
				    			break;
				    		}
				    	}
				    }
				    $store = "default";
				    $array_cate =array($store,$treeurl,$id,$cate_cre->getIsActive(),$cate_cre->getMetaTitle(),$cate_cre->getMetaKeywords(),$cate_cre->getMetaDescription(),$cate_cre->getIncludeInMenu(),$cate_cre->getIsAnchor(),$cate_cre->getDescription());
				    var_dump($array_cate);
				    
				    fputcsv($fp,$array_cate);
				    
			    }//endof if removeroot category and default category .
		    }
			fclose($fp);  
	    }
    }
}

$shell = new Mage_Shell_ExportCategory();
$shell->run();

 

分享到:
评论

相关推荐

    LotusDomino学习笔记.doc

    46. Show single category view, the next stage 107 47. Checkboxes in a list box 108 48. Formatting a Notes view in HTML table for WEB 109 49. Jump to the end of a view (web agent) 111 50. Disabling ...

    LotusDomino学习笔记(400页涵盖代理和公式使用)

    46. Show single category view, the next stage 107 47. Checkboxes in a list box 108 48. Formatting a Notes view in HTML table for WEB 109 49. Jump to the end of a view (web agent) 111 50. Disabling ...

    Lotus Domino WEB 开发技术积累-DOC(313页)

    46. Show single category view, the next stage 107 47. Checkboxes in a list box 108 48. Formatting a Notes view in HTML table for WEB 109 49. Jump to the end of a view (web agent) 111 50. Disabling ...

    Lotus Domino WEB详细 学习笔记

    46. Show single category view, the next stage 107 47. Checkboxes in a list box 108 48. Formatting a Notes view in HTML table for WEB 109 49. Jump to the end of a view (web agent) 111 50. ...

    WPTools.v6.29.1.Pro

    + improved XML import/export (unit WPIOXML1.PAS) - some smaller bugs fixed 3.11.2011 - WPTools 6.21.2 - fix problem with TWPToolButton - improved HTML writer to write parameters in "" - improved ...

    VB编程资源大全(英文源码 数据库)

    By supplying a DSN entry, it will attempt to connect to that database and list all the tables in it. When you click on a table, it lists all <END><br>38,3a.zip An Inventory System, you can add, ...

    WordPress 2.7 Cookbook.pdf

    Importing and exporting content with the Import and Export tool 14 Getting ready 14 How to do it 14 Importing content 15 Exporting content 17 How it works 18 This material is copyright and is ...

    r40_tinav2.1_最终验证通过_使用CB-S来验证SPI2.0成功_20171114_0945没有外层目录.7z

    export "SUNXI_MODE=ota_test" fi make ${PLATFORM}_config make -j16 #make spl #make fes if [ ${PLATFORM} = "sun8iw11p1" ]; then make distclean make ${PLATFORM}_nor_config make -j16 #make ...

    EurekaLog_7.5.0.0_Enterprise

    13)..Added: "User" and "Session" columns to processes list, processes list is also sorted by session first 14)..Added: Support for showing current user processes only 15)..Added: Expanding environment...

Global site tag (gtag.js) - Google Analytics