Magento Themes and Magento Extensions

Creating Custom log file in magento

Posted on December 23rd, 2011 | Posted by admin

Magento has a built in support to write log messages. Sometimes we may Need to include our own log file for debugging our own modules. Because the size of default system.log file is too large and also it is difficult to find a specific entry in such a large file.

we can Create our own custom log file as follows

Step 1: Navigate to Admin System > Configuration > Developer > Log Settings->Enabled. If the logsetting is not enabled change it to enabled.

Step 2: Now we can write our log entries in our custom modules as follows

Mage::log(‘My Custom log Message entry’,null,’mylog.log’);

A new file with the name mylog.log will be created in var/log directory.

Open the file to see your custom log entry.

Template Path Hints for Admin Panel Magento

Posted on December 23rd, 2011 | Posted by admin
Magento has a built in feature called template path hints to identify the path of frontend template files and its block classes. But Sometimes you need to locate the path of adminhtml template files. Recently while searching the magento forum i got this solution. So to enable template hints for the adminhtml. Follow the below step
Step 1: Change the file app/code/core/Mage/Core/etc/system.xml as follows:

Magento debugging tips

Posted on December 11th, 2011 | Posted by admin

1. One of the most difficult task in magento is to locate a particular file in recursive folders. Magento provides a setting in the admin panel to find the template files.

To locate any template file location. Enable the template path hints.

Magento debugging tips

How to change Weight Attribute decimals Magento

Posted on December 11th, 2011 | Posted by admin

There is no simple way to change the decimal numbers in the Weight Attribute in Magento.

And is not a specific solution either.

What can we do?

For example, we can force to all numeric attributes to show with 2 decimals.

Open the attributes.phtml located in:

app/design/frontend/YOUR THEME/template/catalog/product/view/

I changed this:

<?php echo $_helper->productAttribute($_product, strip_tags($_data['value']), $_data['code']) ?

To this:

$_MyValue = $_data['value'];
if (is_numeric($_MyValue))
$_MyValue = round($_MyValue, 2); //round to 0.00
<?php echo $_helper->productAttribute($_product, strip_tags($my_data_value), $_data['code']) ?>

Log Clean Script for Magento

Posted on December 11th, 2011 | Posted by admin

Magento Keeps track of all logging information in its database. It logs everything that happens in the site i.e visitors information,customers logged in details,URLs visited etc. It has a log cleaning with Cron job setup by default to clear the old entries, but i found in magento forums that the default log cleaning is not working and also the database size increased because of these log entries. I went through the log module to see how the log cleaning and i found an important model class that does the job.

The Log module works based on the configuration in the admin, it keeps track of the log entries for the specified no of days in the admin. The Log entries older than the specified no of days will be deleted by this script.

Note: Please test this script in development environment and then move to production site.

Step 1: Navigation to System > Configuration > System > Log Cleaning in Magento Admin panel. Now decide for how many days you need to keep track of the log information. Say for example i want to keep track of the log entries for the last one month so I entered 30 days in Save Log, Days field.

Page 2 of 4«1234»