Magento write custom log message

magentoTo be able to write custom log message, you have to enable logging from Magento Admin.

To enable logging, go to

Admin Panel -> System -> Configuration -> Developer -> Log Settings -> Enabled = Yes

Then in your code, you can write the following:

Mage::log("Your Log Message");

You can check it at var/log/system.log or, var/log/exception.log

If you want to create your own log file for your log message, then you can do it this way:

Mage::log("Your Log Message", null, "your_log_file.log");

Your log file will be created at var/log folder with your log message.

VN:F [1.9.22_1171]
Rating: +2 (from 2 votes)

Written by R Vadgama (RV)

R. Vadgama(RV) is a web developer who has a love for creativity and enjoys experimenting with various techniques in both developing and maintaining. Check out RV's web development tutorials and articles at raisereview.com. R Vadgama

Enable Template or Block Hints in Admin Panel

Anyone that has developed a theme in Magento knows how helpful template/block hints in admin panel are. They help quickly identify which files are being loaded for a specific page.

Magento’s admin panel uses the exact same design pattern as the frontend (layouts + blocks + templates). If you’ve ever done any modifications to the Magento admin panel, you’ve probably tried to turn on template/block hints for the admin panel. The only problem is, Magento doesn’t have built-in support for this. I did some digging around and found out how to enable block hints in Admin Panel. Read More…

VN:F [1.9.22_1171]
Rating: +2 (from 2 votes)

Written by R Vadgama (RV)

R. Vadgama(RV) is a web developer who has a love for creativity and enjoys experimenting with various techniques in both developing and maintaining. Check out RV's web development tutorials and articles at raisereview.com. R Vadgama

magento create store programmatically

Magento having functionality to create sub stores by type and multilingual sub store. you are in a right place below is a way magento create store programmatically also you need to create category programmatically before creating store If you need do it from frontend – add line Mage::registry(‘isSecureArea’); before this code.

//If you need do it from frontend - add line Mage::registry('isSecureArea'); before this code.

//#add Website
    /** @var $website Mage_Core_Model_Website */
    $website = Mage::getModel('core/website');
    $website->setCode('<your_website_code_here>')
        ->setName('<your_website_name>')
        ->save();

//#add StoreGroup
    /** @var $storeGroup Mage_Core_Model_Store_Group */
    $storeGroup = Mage::getModel('core/store_group');
    $storeGroup->setWebsiteId($website->getId())
        ->setName('<your_store_name>')
        ->setRootCategoryId('<needed_root_category_id>')
        ->save();

//#add Store
    /** @var $store Mage_Core_Model_Store */
    $store = Mage::getModel('core/store');
    $store->setCode('<your_store_view_code_here>')
        ->setWebsiteId($storeGroup->getWebsiteId())
        ->setGroupId($storeGroup->getId())
        ->setName('<your_store_view_name>')
        ->setIsActive(1)
        ->save();
VN:F [1.9.22_1171]
Rating: 0 (from 0 votes)

Written by R Vadgama (RV)

R. Vadgama(RV) is a web developer who has a love for creativity and enjoys experimenting with various techniques in both developing and maintaining. Check out RV's web development tutorials and articles at raisereview.com. R Vadgama

View all magento system config xml

In Magento system config.xml file is used to setup the module details. We used to setup system config.xml file in PackageName/ModuleName/etc/.

Magento collect all the config data from different modules and combine it all into a single file named system config.xml

To view this file simply paste this code in any controllers, run it and see the magic. A huge tree with lots of nodes.

It will show whole generated magento system config in xml format

<?php
echo $config = Mage::getConfig()
->loadModulesConfiguration('config.xml')
->getNode()
->asXML();
die;
?>
VN:F [1.9.22_1171]
Rating: +1 (from 1 vote)

Written by R Vadgama (RV)

R. Vadgama(RV) is a web developer who has a love for creativity and enjoys experimenting with various techniques in both developing and maintaining. Check out RV's web development tutorials and articles at raisereview.com. R Vadgama

Magento Urls & Paths

magento

You sometimes need to retrieve Magento url / path like the website base URL or the media directory path on the server. Magento brings us 2 functions allowing to do that easily.

For web adresses you need to use Mage::getBaseUrl() with the link type in parameter. The types are described in the model Mage_Core_Model_Store

Read More…

VN:F [1.9.22_1171]
Rating: +1 (from 1 vote)

Written by R Vadgama (RV)

R. Vadgama(RV) is a web developer who has a love for creativity and enjoys experimenting with various techniques in both developing and maintaining. Check out RV's web development tutorials and articles at raisereview.com. R Vadgama

Magento overriding core files (Blocks, Models, Resources, Controllers)

magento overiding core filesWhen building custom modules for Magento, one of the most common needs is to override Magento’s core files, most commonly Blocks, Models, Resources, and Controllers. And, by the way, when I say “override”, that is also synonymous with “rewrite” or “extend”.

I wanted to write this up for my own reference, but I hope this ends up helping you to. At the time of writing this, all of these methods have been tested on 1.4.0. This post assumes you to have familiarity with writing Magento modules. And remember, you only need to include functions in your file that you are modifying. Leave all untouched functions out of your file.

Also, the reason I haven’t included much for examples of the actual block/model code is that 90% of getting a rewrite to work correctly is just getting your config.xml correct. It matters way less of where you put your files in your module (though it’s good to keep it organized and clean). Read More…

VN:F [1.9.22_1171]
Rating: +1 (from 1 vote)

Written by R Vadgama (RV)

R. Vadgama(RV) is a web developer who has a love for creativity and enjoys experimenting with various techniques in both developing and maintaining. Check out RV's web development tutorials and articles at raisereview.com. R Vadgama

Magento customize tinymce

customized tinymce magento

customized tinymce magento

In magento admin we always need to remove some buttons from magento tinymce.

also while we add tinymce in our custom module at that time we can also customize the magento tinymce view. here is the way to magento customize tinymce. while adding magento field as magento tinymce..

Read More…

VN:F [1.9.22_1171]
Rating: +2 (from 2 votes)

Written by R Vadgama (RV)

R. Vadgama(RV) is a web developer who has a love for creativity and enjoys experimenting with various techniques in both developing and maintaining. Check out RV's web development tutorials and articles at raisereview.com. R Vadgama

Remove non alphanumeric characters from string

Below is the solution to remove non alphanumeric characters from string using php

<?php
$string = "string containing # and @ and other non alpha characters";
$clean_string = preg_replace("/[^a-z0-9\s]/", "", $string);
?>
VN:F [1.9.22_1171]
Rating: +2 (from 2 votes)

Written by R Vadgama (RV)

R. Vadgama(RV) is a web developer who has a love for creativity and enjoys experimenting with various techniques in both developing and maintaining. Check out RV's web development tutorials and articles at raisereview.com. R Vadgama

Magento form validation with css class

As we all know Magento use Prototype as javascript library. It provides a simple way to validate html form values. there are a lots of magento form validation terms already there in magento.

Below is full list of magento form validate class and its error message that I found in prototype lib. Read More…

VN:F [1.9.22_1171]
Rating: +2 (from 2 votes)

Written by R Vadgama (RV)

R. Vadgama(RV) is a web developer who has a love for creativity and enjoys experimenting with various techniques in both developing and maintaining. Check out RV's web development tutorials and articles at raisereview.com. R Vadgama

Magento event and observer cheat sheet

There is an Event-Observer methodology used in Magento, Magento has been programmed to raise events in crucial areas of the flow.

We can use these events for our requirement.

I am describing here a way to use it. An example would be the event ‘checkout_onepage_controller_success_action’ (this has been use by me at many instances) which will be raised by Magento immediately after an order is placed succesfully. There are many events used in Magento, you can use them as per your requirement.

Event An Event is something that occurs in a certain place during a particular sequence flow.

Observer An Observer is an event handler. It listens to any event it is attached to and accordingly reacts to the event. Read More…

VN:F [1.9.22_1171]
Rating: +3 (from 3 votes)

Written by R Vadgama (RV)

R. Vadgama(RV) is a web developer who has a love for creativity and enjoys experimenting with various techniques in both developing and maintaining. Check out RV's web development tutorials and articles at raisereview.com. R Vadgama

1 2 3 4  Scroll to top