Learning Magento can range from frustrating to infuriating for the first time user. Here’s a few tips to ease the burden of assimilating an entirely new system.
Turn on Logging
While the Magento Community Edition doesn’t have much default logging, it does have a solid logging system in place. Anywhere you can execute PHP in Magento you can do something like
Mage::Log($variable);
Magento will output the contents$variable
to a log. Arrays and Objects are auto-expanded and pretty printed, allowing you quickly zoom in on the portion of the data structure you’re interested in. I’ve found using this in combination with Mac OS X’s Console.app to be a much smoother experience than dumping objects to the browser, particularly given how often Magento objects store references to a good portion of the system (resulting is large object data dumps).
Logging is turned off by default, to change that
- In the Magento Admin, go to System->Configuration
- In the left column, click on Developer (under Advanced)
- If it’s not expanded, Click on Log Settings
- Select Yes from the “Enabled” drop down
- Click on Save Config
Unfortunately, Magento won’t create your log files for you. If they don’t exist you’ll need to create them yourself. By default, log files are stored at
var/log/system.log
var/log/exception.log
If the log folder doesn’t exist, create it along withsystem.log
andexception.log
. Make sure Apache has write access to both the directory and the files. Check with your system administrator on the best way to do this.
Calls made usingMage::Log
will be dropped in system.log. Exceptions will be logged to exception.log
Turn on Developer Mode
If you look in the Magento bootstrap file (index.php) you’ll see lines similar to the following
#Mage::setIsDeveloperMode(true);
#ini_set('display_errors', 1);
Uncomment these. In a production system, you’d never want to have your errors display to the browser, but while developing having an errors and warnings thrown immediately in your face is invaluable.
Setting the IsDeveloperMode flag is a big time saver. By default, when Magento discovers an exception, it will log the exception to a report and then forward the user to a page that will display that report. This can be infuriating when you’re developing, particularly because Magento redirects in such a way that you can’t backup to the page you were just on. Setting the developer mode flag results in the Exception output being sent directly to the browser with<pre>
formatting.
Like this article? Then you’ll loveCommerce Bug, the must have debugging extension for anyone using Magento. Whether you’re just starting out or you’re a seasoned pro, Commerce Bug will save you and your team hours everyday.Grab a copyand start workingwithMagento instead of against it.
Originally published July 2, 2009
分享到:
相关推荐
Magento Development Cookbook 教你怎么开发magento的主题和模块,非常实用,给又需要的人!
magento开发参考资料,对magento开发很有帮助
Chapter 1, Installing Magento 2 on Apache and NGINX, is a totally different ballgame compared to Magento 1. Where Magento 1 could be installed through FTP or SSH, Magento 2 is installable only via the...
Chapter 1: Getting Started with Magento 7 Introduction 7 Preparing the development environment 8 Installing Magento with sample data 11 Adding version control
magento2 developers cookbook, magento 开发手册,magento教程
Migrate your development environment to a live store Configure your Magento 2 web store the right way, so that your taxes are handled properly Create pages with arbitrary content Create and manage ...
[Packt Publishing] Getting Started with Magento Extension Development (E-Book) ☆ 图书概要:☆ Understand Magento extensions, and build your own from scratch! Overview Get a detailed insight into ...
magento数据结构分析 magento数据字典
sample data for magento software
magento的SMTP插件magento的SMTP插件magento的SMTP插件
magik shoes magento 模板, magento 1.7 模板
深入理解Magento 由精东博客下载下来制作成pdf
Magento插件开发手册 Magento Extension Developers Guide
Athlete Magento主题,兼容Magento 1.9.x, 1.8.x, 1.7.x ,特点:完全自适应(响应式布局),自定义子主题,无限颜色,完全自定义,一键安装演示,小工具化横幅系统,颜色选择,MEGA菜单,多商店支持,自定义产品...
Magento Magento商城 Magento目录结构
主要包括的内容有:magento的常用设置、Magento模板制作教程、Magento商城_目录结构说明、Magento中文教程实用文档、常用的xml的文件的作用以及自定义模块的应用
快速在服务器上复制为另一个站,版本用的是magento,php语言
Magento 的配置系统就像是 Magento 的心脏,支撑着 Magento 的运行。这套 配置系统掌管着几乎所有“module/model/class /template/etc”。它把整个 Magento 系统抽象出来,用一个配置文件来描述。这里的“配置文件”...
语言:English 快速启动GoTop Media 使用GoTop开发Magento✓自定义Magento开发✓我们建设Magento网站已有10多年的历史。 :right_arrow:联系我们