Get all parent id of sub category

Consider this tree as example.

 - 5
   - 8
 - 6
   - 9
   - 12
     - 20

The easiest way to do so is this:

$category = Mage::getModel('catalog/category')->load(20);

Each category has a field called path that contains the ids of the parents and current category.

$path = $category->getPath();

This should return something like this 1/2/6/12. All you need to do is to split this string by / and remove the first element. That one is the id for ‘root of all roots’.

$ids = explode('/', $path);

Delete all custom option on catalog_product_save_before event using observer

Hope you have configure observer for this event.if not please configure and add below code to it.

$product            = $observer->getProduct();
if ($product->getId()) {
            $productMod = Mage::getModel('catalog/product')->load($product->getId());
            $opt        = $productMod->getOptions();
            foreach ($opt as $o) {
                /** delete the selected custom option **/

Create custom e-mail template in magento

I hope you are aware with the system.xml file in magento so we will not go deep in to it.just add below code to your system.xml file to add select box for choose our custom template.

<email_template translate="label">
<label>Email Template (Sender Notification)</label>

The next step is to add an html-template of the letter. /app/locale/en_US/template/email/contact_sender_notification.html

<!--@subject My Email Subject Subject @-->
<!--@vars {"store url=\"\"":"Store Url", "var logo_url":"Email Logo Image Url", "var logo_alt":"Email Logo Image Alt", "htmlescape var=$" : "Email sender contact form" } @-->
<!--@styles body,td { color:#2f2f2f; font:11px/1.35em Verdana, Arial, Helvetica, sans-serif; } @-->

<body style="background:#F6F6F6; font-family:Verdana, Arial, Helvetica, sans-serif; font-size:12px; margin:0; padding:0;">
<div style="background:#F6F6F6; font-family:Verdana, Arial, Helvetica, sans-serif; font-size:12px; margin:0; padding:0;">
<table cellspacing="0" cellpadding="0" border="0" height="100%" width="100%">
<td align="center" valign="top" style="padding:20px 0 20px 0">
            <!-- [ header starts here] -->
<table bgcolor="FFFFFF" cellspacing="0" cellpadding="10" border="0" width="650" style="border:1px solid #E0E0E0;">
<td valign="top">
                        <a href="{{store url=""}}" style="color:#1E7EC8;"><img src="{{var logo_url}}" alt="{{var logo_alt}}" border="0"/></a></td>
<!-- [ middle starts here] -->
<td valign="top">
<h1 style="font-size:22px; font-weight:normal; line-height:22px; margin:0 0 11px 0;">Dear {{htmlescape var=$}},</h1>
Some text</td>
<td bgcolor="#EAEAEA" align="center" style="background:#EAEAEA; text-align:center;">

Thank you again, <strong>{{var store.getFrontendName()}}</strong>

IMPORTANT NOTE :: On the above section you have notice commented code it is not actually commented.

But it use internally in magento to setup subject and var.
If you forgot to define subject it will send mail and raise exceptions in log file.

After adding the code (see above) we will declare the template in the configuration file and will set the template as default in Email Template (Sender Notification) app/code/local/namespace/module/etc/config.xml

               <contacts_sender_notification_email_template translate="label" module="{justmodulenameonly}">
                   <label>Contact Sender Notification</label>

IMPORTANT NOTE :: in the above config.xml file. “contacts_sender_notification_email_template” is the combination of your{section_group_field} of your system.xml file(Please take care of this otherwise it will not reflect on your configuration).

Now you can send mail using this template.