调试Magento的方法几则
			
			
				时间:2016-11-15 02:41来源:未知 作者:最模板 点击:次
            	I. 在app目录外调试 在Magento安装目录下,建立php文件(假设为list.php),内容如下: Php代码 ?php //initializemagentoenvironmentfordefaultstore require_once app/Mage.php ; Mage::app( default ); //Writeyourcodes ? 然后
			
			
				| I. 在app目录外调试 
 在Magento安装目录下,建立php文件(假设为list.php),内容如下:
 
 
	
	
		
			<?php  
			     
			   require_once 'app/Mage.php';  
			   Mage::app('default');  
			     
			?>   
 然后http://server/magento/list.php
 下面的例子可以输出所有category模型对应表的path字段
 
 
	
	
		
			<?php  
			     
			   require_once 'app/Mage.php';  
			   Mage::app('default');  
			  
			     
			   $categories = Mage::getModel('catalog/category')->getCollection();  
			     
			   $categories = $categories->load();  
			   foreach($categories AS $category) {  
			      echo $category->getPath();  
			      echo "<br/>";  
			   }  
			?>   
 
 II. 使用colleciton->getSelectSql()输出运行的SQL语句
 
 
	
	
		
			<?php  
			  $collection = Mage::getModel('catalog/category')->getCollection();  
			  .....  
			  $collection->load();  
			  echo $colleciton->getSelectSql();  
			?>   
 III. 输出对象的类型
 
 Magento常常产生非常大的对象,调试时如果使用var_dump($obj)会导致系统崩溃,这是常常使用
 get_class($obj)
 
 输出对象的类型,然后再慢慢分析这个类的作用!
 $_category->getChildren()(责任编辑:最模板)
 | 
			
			 
			
			
			
			
			
			
			
			
				------分隔线----------------------------