<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Magento Coder</title>
	<atom:link href="http://magentocoder.jigneshpatel.co.in/feed/" rel="self" type="application/rss+xml" />
	<link>http://magentocoder.jigneshpatel.co.in</link>
	<description>hacks &#38; solutions for Magento Ecommerce development</description>
	<lastBuildDate>Sun, 19 Jun 2011 16:13:55 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.1.2</generator>
		<item>
		<title>Magento &#8211; Add custom comment box to each product in Cart</title>
		<link>http://magentocoder.jigneshpatel.co.in/magento-add-comment-box-to-each-product-in-cart/</link>
		<comments>http://magentocoder.jigneshpatel.co.in/magento-add-comment-box-to-each-product-in-cart/#comments</comments>
		<pubDate>Tue, 17 Aug 2010 11:18:57 +0000</pubDate>
		<dc:creator>Jignesh</dc:creator>
				<category><![CDATA[Cart]]></category>

		<guid isPermaLink="false">http://magentocoder.jigneshpatel.co.in/?p=127</guid>
		<description><![CDATA[Are you looking for the solution i.e. customer can provide their inputs or comments along with the products they are going to order. To make it easier, one way is to allow them enter the comments for each individual item they order. On the other hand, admin should be able to view the comment on the order page. Adding a custom comment box for each item in the cart is actually very easy. First lets [...]]]></description>
			<content:encoded><![CDATA[<p>Are you looking for the solution i.e. customer can provide their inputs or comments along with the products they are going to order. To make it easier, one way is to allow them enter the comments for each individual item they order. </p>
<p>On the other hand, admin should be able to view the comment on the order page.</p>
<p>Adding a custom comment box for each item in the cart is actually very easy. First lets add the textarea field for each item.</p>
<p>In your theme, for the file: template/checkout/cart.phtml<br />
Add the new heading along with other heading for cart items.</p>
<pre class="brush: php; title: ;">&lt;th&gt;&lt;?php echo $this-&gt;__('Comments') ?&gt;&lt;/th&gt; </pre>
<p>In the file: template/checkout/cart/item/default.phtml<br />
Add a new column</p>
<pre class="brush: php; title: ;">
            &lt;td class=&quot;a-center&quot;&gt;
            &lt;textarea name=&quot;cart[&lt;?php echo $_item-&gt;getId() ?&gt;][comments]&quot; rows=&quot;3&quot; cols=&quot;20&quot;&gt;&lt;?php echo $_item-&gt;getItemcomment() ?&gt;&lt;/textarea&gt;
            &lt;/td&gt;
</pre>
<p>For Older version of Magento it would be:</p>
<pre class="brush: php; title: ;">
            &lt;td class=&quot;a-center&quot;&gt;
            &lt;textarea name=&quot;cart[&lt;?php echo $_item-&gt;getId() ?&gt;][comments]&quot; rows=&quot;3&quot; cols=&quot;20&quot;&gt;&lt;?php echo $this-&gt;getItemItemcomment($_item) ?&gt;&lt;/textarea&gt;
            &lt;/td&gt;
</pre>
<p>Doing upto this. shoul show the text area added </p>
<p><a href="http://magentocoder.jigneshpatel.co.in/wp-content/uploads/2010/08/CommentBoxAddedOnCartPage.png"><img src="http://magentocoder.jigneshpatel.co.in/wp-content/uploads/2010/08/CommentBoxAddedOnCartPage.png" alt="" title="CommentBoxAddedOnCartPage" width="531" height="278" class="alignnone size-full wp-image-140" /></a></p>
<p>The next step is to save the comment in DB, when customer update the cart.</p>
<p>So add a new field &#8216;itemcomment&#8217; in the tabel &#8216;sales_flat_quote_item&#8217;. (For older version of Magento the table would be &#8216;sales_quote_item&#8217;)</p>
<p>Now we are going to add the code which will do the DB operation. For this we will need to modify the file:<br />
app/code/core/Mage/Checkout/Model/Cart.php (Note: If you are planning to upgrade your Magento setup, copy this file to local &#038; modify.)</p>
<p>Here we need to add some code to the function updateItems(), such a way that the function should now look like below:</p>
<pre class="brush: php; title: ;">
    public function updateItems($data)
    {
        Mage::dispatchEvent('checkout_cart_update_items_before', array('cart'=&gt;$this, 'info'=&gt;$data));

        foreach ($data as $itemId =&gt; $itemInfo) {

            $item = $this-&gt;getQuote()-&gt;getItemById($itemId);
            if (!$item) {
                continue;
            }

            if (!empty($itemInfo['remove']) || (isset($itemInfo['qty']) &amp;&amp; $itemInfo['qty']=='0')) {
                $this-&gt;removeItem($itemId);
                continue;
            }

            $qty = isset($itemInfo['qty']) ? (float) $itemInfo['qty'] : false;
            if ($qty &gt; 0) {
                $item-&gt;setQty($qty);
            }

        /* Start: Custom code added for comments */
        if(!empty($itemInfo['comments'])) {

        	$write = Mage::getSingleton('core/resource')-&gt;getConnection('core_write');

        	# make the frame_queue active
      		$query = &quot;UPDATE `sales_flat_quote_item` SET itemcomment = '&quot;.$itemInfo['comments'].&quot;' where item_id = $itemId&quot;;
			$write-&gt;query($query);

        	$item-&gt;setItemcomment($itemInfo['comments']);
        }
        /* End: Custom code added for comments */

        }

        Mage::dispatchEvent('checkout_cart_update_items_after', array('cart'=&gt;$this, 'info'=&gt;$data));
        return $this;
    }
</pre>
<p>Showing the comment in Admin -> View Order</p>
<p>Add a new function getItemcomment() to the file below:<br />
app/code/core/Mage/Adminhtml/Block/Sales/Order/View/Items.php</p>
<p>If you are on verstion 1.5 or later.. add it to the file below.<br />
app/code/core/Mage/Adminhtml/Block/Sales/Order/View/Items.php</p>
<pre class="brush: php; title: ;">

	public function getItemcomment($item) {
		$itemId = $item-&gt;getId();

		$write = Mage::getSingleton('core/resource')-&gt;getConnection('core_write');

    	$query = &quot;SELECT q.* FROM `sales_flat_order_item` o
	    LEFT JOIN `sales_flat_quote_item` q on o.quote_item_id = q.item_id
	    WHERE o.item_id = $itemId&quot;;

		# For older versions of Magento
/*	    $query = &quot;SELECT q.* FROM `sales_order_entity_int` o
	    LEFT JOIN `sales_flat_quote_item` q on o.value = q.entity_id
	    WHERE o.entity_id = $itemId AND o.attribute_id = 343&quot;;       */	    

		$res = $write-&gt;query($query);

		while ($row = $res-&gt;fetch() ) {
			if(key_exists('itemcomment',$row)) {
				echo nl2br($row['itemcomment']);
			}
		}
	}    
</pre>
<p>To add the comments column to the items edit the .phtml file below:<br />
app/design/adminhtml/default/default/template/sales/order/view/items.phtml</p>
<p>Adding header for items to make it look like below:</p>
<pre class="brush: php; title: ;">
.
.
&lt;tr class=&quot;headings&quot;&gt;
    &lt;th&gt;&lt;?php echo $this-&gt;helper('sales')-&gt;__('Product') ?&gt;&lt;/th&gt;
    &lt;th&gt;&lt;?php echo $this-&gt;helper('sales')-&gt;__('Comments') ?&gt;&lt;/th&gt;
    &lt;th&gt;&lt;?php echo $this-&gt;helper('sales')-&gt;__('Item Status') ?&gt;&lt;/th&gt;
.
.
.
</pre>
<p>Adding Column with comments. app/design/adminhtml/default/default/template/sales/order/view/items/renderer/default.phtml<br />
Add a column for item comments juts before status columns to make it look a like below.</p>
<pre class="brush: php; title: ;">
.
.
&lt;td&gt;&lt;?php echo $this-&gt;getItemcomment($_item) ?&gt;&lt;/td&gt; &lt;!-- New column added for item comments --&gt;
&lt;td class=&quot;a-center&quot;&gt;&lt;?php echo $_item-&gt;getStatus() ?&gt;&lt;/td&gt;
.
.
</pre>
<p>Doing upto this will show the comments column in the item table. It should look like image below.</p>
<p><a href="http://magentocoder.jigneshpatel.co.in/wp-content/uploads/2010/08/Items-Ordered-Admin.png"><img src="http://magentocoder.jigneshpatel.co.in/wp-content/uploads/2010/08/Items-Ordered-Admin.png" alt="" title="Items-Ordered-Admin" width="352" height="296" class="alignnone size-full wp-image-165" /></a></p>
]]></content:encoded>
			<wfw:commentRss>http://magentocoder.jigneshpatel.co.in/magento-add-comment-box-to-each-product-in-cart/feed/</wfw:commentRss>
		<slash:comments>34</slash:comments>
		</item>
		<item>
		<title>Magento 1.4.1 &#8211; Onepage checkout Paypal WPP bug</title>
		<link>http://magentocoder.jigneshpatel.co.in/magento-1-4-1-onepage-checkout-paypal-wpp-bug/</link>
		<comments>http://magentocoder.jigneshpatel.co.in/magento-1-4-1-onepage-checkout-paypal-wpp-bug/#comments</comments>
		<pubDate>Sun, 01 Aug 2010 07:09:26 +0000</pubDate>
		<dc:creator>Jignesh</dc:creator>
				<category><![CDATA[Cart]]></category>
		<category><![CDATA[Checkout]]></category>

		<guid isPermaLink="false">http://magentocoder.jigneshpatel.co.in/?p=112</guid>
		<description><![CDATA[Magento 1.4.1 having some issues, when using Paypal WPP payment method. It does not work properly when you press Continue even after you have put the card details correctly. As a solution, I replaced the version of file below from Magento 1.4.0 to Magento 1.4.1 js/prototype/validation.js Also disabled the Centinel Validation by commenting the line below in file : app/code/core/Mage/Payment/Model/Method/Cc.php this-&#62;getCentinelValidator()-&#62;validate($this-&#62;getCentinelValidationData());]]></description>
			<content:encoded><![CDATA[<p>Magento 1.4.1 having some issues, when using Paypal WPP payment method. It does not work properly when you press Continue even after you have put the card details correctly.</p>
<p>As a solution, I replaced the version of file below from Magento 1.4.0 to Magento 1.4.1</p>
<p><code>js/prototype/validation.js</code></p>
<p>Also disabled the Centinel Validation by commenting the line below in file : app/code/core/Mage/Payment/Model/Method/Cc.php</p>
<pre class="brush: php; title: ;">
this-&gt;getCentinelValidator()-&gt;validate($this-&gt;getCentinelValidationData());
</pre>
]]></content:encoded>
			<wfw:commentRss>http://magentocoder.jigneshpatel.co.in/magento-1-4-1-onepage-checkout-paypal-wpp-bug/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Magento &#8211; Fatal error: Maximum execution time of 60 seconds exceeded in &#8230;</title>
		<link>http://magentocoder.jigneshpatel.co.in/magento-fatal-error-maximum-execution-time-of-60-seconds-exceeded-in/</link>
		<comments>http://magentocoder.jigneshpatel.co.in/magento-fatal-error-maximum-execution-time-of-60-seconds-exceeded-in/#comments</comments>
		<pubDate>Tue, 18 May 2010 05:36:24 +0000</pubDate>
		<dc:creator>Jignesh</dc:creator>
				<category><![CDATA[PHP]]></category>

		<guid isPermaLink="false">http://magentocoder.jigneshpatel.co.in/?p=103</guid>
		<description><![CDATA[Have you ever encountered the following kind of error while installing Magento 1.4 ? Fatal error: Maximum execution time of 120 seconds exceeded in... To fix it, open your php.ini and replace the value for &#8216;max_execution_time&#8217; and &#8216;max_input_time&#8217; as per below. max_execution_time = 3600 max_input_time = 3600]]></description>
			<content:encoded><![CDATA[<p>Have you ever encountered the following kind of error while installing Magento 1.4 ?</p>
<p><code style='color:red;'><strong>Fatal error</strong>: Maximum execution time of 120 seconds exceeded in...</code></p>
<p>To fix it, open your php.ini and replace the value for &#8216;max_execution_time&#8217; and &#8216;max_input_time&#8217; as per below.</p>
<pre class="brush:php">

max_execution_time = 3600
max_input_time = 3600
</pre>
]]></content:encoded>
			<wfw:commentRss>http://magentocoder.jigneshpatel.co.in/magento-fatal-error-maximum-execution-time-of-60-seconds-exceeded-in/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>How to add a new body class to Magento layout</title>
		<link>http://magentocoder.jigneshpatel.co.in/how-to-add-a-new-body-class-to-magento-layout/</link>
		<comments>http://magentocoder.jigneshpatel.co.in/how-to-add-a-new-body-class-to-magento-layout/#comments</comments>
		<pubDate>Fri, 11 Dec 2009 13:28:02 +0000</pubDate>
		<dc:creator>Jignesh</dc:creator>
				<category><![CDATA[Frontend]]></category>

		<guid isPermaLink="false">http://magentocoder.jigneshpatel.co.in/?p=89</guid>
		<description><![CDATA[Adding a CSS body class to Magento layouts seems very easy. In case you want different CSS body class for different module pages on frontend, what you need to do is to find the syntax: $this->loadLayout(); in module controller files and add some new lines just below it. Example: I want to set the &#8216;my-profile&#8217; class to all the customer pages on frontend. So I opened the AccountController.php &#038; edited the function indexAction(). Just below [...]]]></description>
			<content:encoded><![CDATA[<p>Adding a CSS body class to Magento layouts seems very easy.</p>
<p>In case you want different CSS body class for different module pages on frontend, what you need to do is to find the syntax: $this->loadLayout(); in module controller files and add some new lines just below it. </p>
<p>Example:<br />
I want to set the &#8216;my-profile&#8217; class to all the customer pages on frontend. So I opened the AccountController.php &#038; edited the function indexAction(). Just below the &#8216;$this->loadLayout();&#8217; I added few lines. So it will look as below.</p>
<pre class="brush: php; title: ;">
        $this-&gt;loadLayout();

	    if ($root = $this-&gt;getLayout()-&gt;getBlock('root')) {
	            $root-&gt;addBodyClass('my-profile');
	    }
</pre>
<p>However above code needed to be altered in the core code. So better to follow the below.</p>
<p>To update it via layout XML, </p>
<pre class="brush:php">
<reference name="root">
 <action method="addBodyClass"><className>my-profile</className></action>
</reference>
</pre>
<p>This will affect in the &lt;body&gt; tag.</p>
<pre class="brush:php">
&lt;body &lt;?php echo $this->getBodyClass()?'class="'.$this->getBodyClass().'"':'' ?&gt;&gt;
</pre>
]]></content:encoded>
			<wfw:commentRss>http://magentocoder.jigneshpatel.co.in/how-to-add-a-new-body-class-to-magento-layout/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Adding a new Page Layout to Magento</title>
		<link>http://magentocoder.jigneshpatel.co.in/adding-a-new-page-layout-to-magento/</link>
		<comments>http://magentocoder.jigneshpatel.co.in/adding-a-new-page-layout-to-magento/#comments</comments>
		<pubDate>Mon, 09 Nov 2009 06:19:52 +0000</pubDate>
		<dc:creator>Jignesh</dc:creator>
				<category><![CDATA[HTML]]></category>

		<guid isPermaLink="false">http://magentocoder.jigneshpatel.co.in/?p=82</guid>
		<description><![CDATA[Adding a new page layout in Magento is very simple. But why someone need to add a new page layout. Page layouts are already there. Well, that can be needed specially for a Home page. One of my friend faced many issues in managing the Home page with existing layout. As a result, he needed to write other codes as well to maintain the concurrency between other pages. If we do change in current layout, [...]]]></description>
			<content:encoded><![CDATA[<p>Adding a new page layout in Magento is very simple. But why someone need to add a new page layout. Page layouts are already there.</p>
<p>Well, that can be needed specially for a Home page. One of my friend faced many issues in managing the Home page with existing layout. As a result, he needed to write other codes as well to maintain the concurrency between other pages. If we do change in current layout, it would affect the other pages as well using the same layout.</p>
<p>So better way it to create a new layout.<br />
[The steps below are updated to make it work with Magento 1.4 as well]</p>
<p>Steps:</p>
<p>1. Open the file: app/etc/modules/Mage_All.xml<br />
Edit the  &lt;codePool &gt; tag to &#8216;local&#8217; such that it looks like: </p>
<pre class="brush:php">
<Mage_Page>
          <active>true</active>
          <codePool>local</codePool>
          <depends>
                  <Mage_Core />
           </depends>
</Mage_Page>
</pre>
<p>2. Copy config.xml<br />
from app/code/core/Mage/Page/etc/config.xml<br />
to app/code/local/Mage/Page/etc/config.xml</p>
<p>3. The file can be edited: app/code/local/Mage/Page/etc/config.xml<br />
Add new lines between &lt;layout&gt; .. &lt;/layout&gt; along with other layouts.</p>
<pre class="brush:php">
<page>
		<layouts>
.
.
		<home module="page" translate="label">
			<label>Home</label>
			<template>page/home.phtml</template>
			<layout_handle>page_home</layout_handle>
		</home>
.
.
		</layouts>
</page>
</pre>
<p>2. Create new file :  template/page/home.phtml along with 1column.phtml, 2columns-left.phtml etc.. You can just copy the existing code of one of the column layout phtml inside the home.phtml. Modify the code inside home.phtml as per your need.</p>
<p>3. On the Admin, Go To CMS -> Manage Pages. Edit the home page. Change the Layout to  &#8216;Home&#8217; under the &#8216;Design&#8217; Tab.</p>
<p><a href="http://magentocoder.jigneshpatel.co.in/wp-content/uploads/2009/11/new_pagelayout.png"><img src="http://magentocoder.jigneshpatel.co.in/wp-content/uploads/2009/11/new_pagelayout.png" alt="" title="new_pagelayout" width="580" height="150" class="alignnone size-full wp-image-124" /></a></p>
<p>This will apply the home.phtml to Home page.</p>
]]></content:encoded>
			<wfw:commentRss>http://magentocoder.jigneshpatel.co.in/adding-a-new-page-layout-to-magento/feed/</wfw:commentRss>
		<slash:comments>11</slash:comments>
		</item>
		<item>
		<title>Add to Cart with custom attributes &amp; values</title>
		<link>http://magentocoder.jigneshpatel.co.in/add-to-cart-with-custom-attributes-values/</link>
		<comments>http://magentocoder.jigneshpatel.co.in/add-to-cart-with-custom-attributes-values/#comments</comments>
		<pubDate>Sat, 03 Oct 2009 06:02:23 +0000</pubDate>
		<dc:creator>Jignesh</dc:creator>
				<category><![CDATA[Cart]]></category>

		<guid isPermaLink="false">http://magentocoder.jigneshpatel.co.in/?p=74</guid>
		<description><![CDATA[I want to display the custom price on the Shopping Cart page. By default if you add to cart the product it will take the price &#038; will show that price on the cart page. The data on the cart page is coming from the table &#8216;sales_flat_quote_item&#8217;. This table is having lot many fields. Some of them are product_id, name, description, qty, price. Those are the fields which basically reflects on the cart page. My [...]]]></description>
			<content:encoded><![CDATA[<p>I want to display the custom price on the Shopping Cart page. By default if you add to cart the product it will take the price &#038; will show that price on the cart page. </p>
<p>The data on the cart page is coming from the table &#8216;sales_flat_quote_item&#8217;. This table is having lot many fields. Some of them are product_id, name, description, qty, price. Those are the fields which basically reflects on the cart page. </p>
<p>My task was to display the custom image, custom price, custom description in the row of a product on the cart page.</p>
<p>So first of all we need to insert those values in the DB, while adding the product to the cart.</p>
<p>The phase of adding the product to cart is bit complicated to understand.</p>
<p>These are list of some functions involved in Add to cart phase.</p>
<p>app/code/core/Mage/Checkout/controllers/CartController.php: addAction()<br />
app/code/core/Mage/Checkout/Model/Cart.php: addProduct($product, $info)<br />
app/code/core/Mage/Sales/Model/Quote.php: addProduct(Mage_Catalog_Model_Product $product, $request=null)</p>
<p>In the above function, you can set the custom values for the product.</p>
<p>Find the for loop:<br />
foreach ($cartCandidates as $candidate) { &#8230; }<br />
Inside that custom fields can be set.</p>
<pre class="brush:php">

foreach ($cartCandidates as $candidate) {
            $item = $this->_addCatalogProduct($candidate, $candidate->getCartQty());
            ...
            ...
            ...
            $item->setCustomPrice('custom value goes here');
            $item->setCustomImage('custom value goes here');
            ...
            ...
}
</pre>
<p>I want the custom image as well. So I have added the one more field in the table &#8216;sales_flat_quote_item&#8217;.</p>
<p>Getting those custom values on the cart page is very easy. Go to template/checkout/cart/item/default.phtml.<br />
The below lines can get those values.</p>
<pre class="brush:php">
echo $_item->getCustomImage();
</pre>
<p>The price on the cart page will replaced automatically by custom_price value if that has been set.</p>
]]></content:encoded>
			<wfw:commentRss>http://magentocoder.jigneshpatel.co.in/add-to-cart-with-custom-attributes-values/feed/</wfw:commentRss>
		<slash:comments>14</slash:comments>
		</item>
		<item>
		<title>Create custom Reports in Magento Admin</title>
		<link>http://magentocoder.jigneshpatel.co.in/create-custom-reports-in-magento-admin/</link>
		<comments>http://magentocoder.jigneshpatel.co.in/create-custom-reports-in-magento-admin/#comments</comments>
		<pubDate>Mon, 07 Sep 2009 09:26:36 +0000</pubDate>
		<dc:creator>Jignesh</dc:creator>
				<category><![CDATA[Reports]]></category>

		<guid isPermaLink="false">http://magentocoder.jigneshpatel.co.in/?p=60</guid>
		<description><![CDATA[Want to create a custom report in Magento Admin? After taking help from some forums &#38; all I was able to generate a new Report the way I wanted. I was looking to generate the Report for the Products sold along with the name of the Artist to whom the product belongs to. These are the steps to be followed / I followed. 1. The title of the report is: &#8216;Artist Sold Works&#8217;. To add [...]]]></description>
			<content:encoded><![CDATA[<p>Want to create a custom report in Magento Admin?</p>
<p>After taking help from some forums &amp; all I was able to generate a new Report the way I wanted.</p>
<p>I was looking to generate the Report for the Products sold along with the name of the Artist to whom the product belongs to.</p>
<p>These are the steps to be followed / I followed.</p>
<p>1. The title of the report is: &#8216;Artist Sold Works&#8217;. To add the new item under the Reports -&gt; Products.</p>
<p>Open the &#8216;app/code/code/Mage/Reports/etc/config.xml&#8217;</p>
<p>Add the followind code in the &#8216;children of &#8216;products&#8217; (near line 221).</p>
<pre class="brush:php">
	&lt;title&gt;Artist Sold Works&lt;/title&gt;
	adminhtml/report_product/artistsold
</pre>
<p>Add the followind code in the  of</p>
<p>(near line 370).</p>
<pre class="brush:php">
		&lt;title&gt;Artists Sold Works&lt;/title&gt;
</pre>
<p>2. Copy files</p>
<p>app/code/core/Mage/Adminhtml/Block/Report/Product/Sold.php to app/code/core/Mage/Adminhtml/Block/Report/Product/Artistsold.php.</p>
<p>3. Copy directories</p>
<p>app/code/core/Mage/Adminhtml/Block/Report/Product/Sold   to</p>
<p>app/code/core/Mage/Adminhtml/Block/Report/Product/Artistsold</p>
<p>app/code/core/Mage/Reports/Model/Mysql4/Product/Sold   to</p>
<p>app/code/core/Mage/Reports/Model/Mysql4/Product/Artistsold</p>
<p>4. In the file Artistsold.php, change the class name from</p>
<p>Mage_Adminhtml_Block_Report_Product_Sold to Mage_Adminhtml_Block_Report_Product_Artistsold.</p>
<p>Change the lines</p>
<pre class="brush:php">        $this-&gt;_controller = 'report_product_sold';
        $this-&gt;_headerText = Mage::helper('reports')-&gt;__('Products Ordered');
</pre>
<p>to</p>
<pre class="brush:php">        $this-&gt;_controller = 'report_product_artistsold';
        $this-&gt;_headerText = Mage::helper('reports')-&gt;__('Artist Sold Works');
</pre>
<p>5. Add/Modify the columns in the</p>
<p>app/code/core/Mage/Adminhtml/Block/Report/Product/Artistsold/Grid.php</p>
<p>Here in my case:</p>
<pre class="brush:php">
        $this-&gt;addColumn('artistId', array(
            'header'    =&gt;Mage::helper('reports')-&gt;__('Artist'),
            'width'     =&gt;'120px',
            'index'     =&gt;'artistname',
        ));		

        $this-&gt;addColumn('sale_percentage', array(
            'header'    =&gt;Mage::helper('reports')-&gt;__('Artist Share'),
            'width'     =&gt;'60px',
            'index'     =&gt;'sale_percentage',
            'align'     =&gt;'right'
        ));

        $this-&gt;addColumn('base_price_total', array(
            'header'    =&gt;Mage::helper('reports')-&gt;__('Total Product Base Price ($)'),
            'width'     =&gt;'60px',
            'index'     =&gt;'base_price_total',
            'align'     =&gt;'right',
            'total'     =&gt;'sum',
            'type'      =&gt;'number'

        ));

        $this-&gt;addColumn('artist_earned', array(
            'header'    =&gt;Mage::helper('reports')-&gt;__('Artist Earned ($)'),
            'width'     =&gt;'60px',
            'index'     =&gt;'artist_earned',
            'align'     =&gt;'right',
            'total'     =&gt;'sum',
            'type'      =&gt;'number'
        ));
</pre>
<p>6. Add new functions to</p>
<p>app/code/core/Mage/Adminhtml/controllers/Report/ProductController.php</p>
<pre class="brush:php">    public function artistsoldAction()
    {
        $this-&gt;_initAction()
            -&gt;_setActiveMenu('report/product/artistsold')
            -&gt;_addBreadcrumb(Mage::helper('reports')-&gt;__('Artists Sold Works'), Mage::helper('reports')-&gt;__('Artists Sold Works'))
            -&gt;_addContent($this-&gt;getLayout()-&gt;createBlock('adminhtml/report_product_artistsold'))
            -&gt;renderLayout();
    }
</pre>
<p>7.  Open the file</p>
<p>app/code/core/Mage/Reports/Model/Mysql4/Product/Artistsold/Collection.php.</p>
<p>Rename the class name from</p>
<p>Mage_Reports_Model_Mysql4_Product_Sold_Collection  to</p>
<p>Mage_Reports_Model_Mysql4_Product_Artistsold_Collection</p>
<p>Customize the function setDateRange() in the  as per your need.</p>
<p>Here in my case:</p>
<pre class="brush:php">    public function setDateRange($frmdate, $todate)
    {
        $this-&gt;_reset()
            -&gt;addAttributeToSelect('*')
            -&gt;addOrderedQtyForArtistSold($frmdate,$todate);
		return $this;
    }
</pre>
<p>8. To get the new fields, to alter the sql query I copied the function addOrderedQty() to addOrderedQtyForArtistSold() in the file</p>
<p>app/code/core/Mage/Reports/Model/Mysql4/Product/Collection.php</p>
<p>And I did changes in the functions as per my need to get the extra columns.</p>
<p>Here in my case:</p>
<pre class="brush:php">
	public function addOrderedQtyForArtistSold($frm = '', $to = '')
    {
		if(key_exists('report',$_SESSION)) {
    		$artistId = $_SESSION['report']['artistid'];
		}
		else {
			$artistId ='';
		}

        $qtyOrderedTableName = $this-&gt;getTable('sales/order_item');
        $qtyOrderedFieldName = 'qty_ordered';

        $productIdTableName = $this-&gt;getTable('sales/order_item');
        $productIdFieldName = 'product_id';

		$productEntityIntTable = (string)Mage::getConfig()-&gt;getTablePrefix() . 'catalog_product_entity_varchar';
		$adminUserTable = $this-&gt;getTable('admin_user');
		$artistsTable = $this-&gt;getTable('appartists');
		$eavAttributeTable = $this-&gt;getTable('eav/attribute');

        $compositeTypeIds = Mage::getSingleton('catalog/product_type')-&gt;getCompositeTypes();

        # This was added by Dev1 to get the configurable items in the list &amp; not to get the simple products
        $compositeTypeIds = Array (
						    '0' =&gt; 'grouped',
						    '1' =&gt; 'simple',
						    '2' =&gt; 'bundle'
							);

        $productTypes = $this-&gt;getConnection()-&gt;quoteInto(' AND (e.type_id NOT IN (?))', $compositeTypeIds);

        if ($frm != '' &amp;&amp; $to != '') {
            $dateFilter = " AND `order`.created_at BETWEEN '{$frm}' AND '{$to}'";
        } else {
            $dateFilter = "";
        }

        $this-&gt;getSelect()-&gt;reset()-&gt;from(
           array('order_items' =&gt; $qtyOrderedTableName),
           array('ordered_qty' =&gt; "SUM(order_items.{$qtyOrderedFieldName})",'base_price_total' =&gt; "SUM(order_items.price)")
        );

        $order = Mage::getResourceSingleton('sales/order');

        $stateAttr = $order-&gt;getAttribute('state');
        if ($stateAttr-&gt;getBackend()-&gt;isStatic()) {

            $_joinCondition = $this-&gt;getConnection()-&gt;quoteInto(
                'order.entity_id = order_items.order_id AND order.state&lt;&gt;?', Mage_Sales_Model_Order::STATE_CANCELED
            );
            $_joinCondition .= $dateFilter;

            $this-&gt;getSelect()-&gt;joinInner(
                array('order' =&gt; $this-&gt;getTable('sales/order')),
                $_joinCondition,
                array()
            );
        } else {

            $_joinCondition = 'order.entity_id = order_state.entity_id';
            $_joinCondition .= $this-&gt;getConnection()-&gt;quoteInto(' AND order_state.attribute_id=? ', $stateAttr-&gt;getId());
            $_joinCondition .= $this-&gt;getConnection()-&gt;quoteInto(' AND order_state.value&lt;&gt;? ', Mage_Sales_Model_Order::STATE_CANCELED);

            $this-&gt;getSelect()
                -&gt;joinInner(
                    array('order' =&gt; $this-&gt;getTable('sales/order')),
                    'order.entity_id = order_items.order_id' . $dateFilter,
                    array())
                -&gt;joinInner(
                    array('order_state' =&gt; $stateAttr-&gt;getBackend()-&gt;getTable()),
                    $_joinCondition,
                    array());
        }

        $this-&gt;getSelect()
            -&gt;joinInner(array('e' =&gt; $this-&gt;getProductEntityTableName()),
                "e.entity_id = order_items.{$productIdFieldName}")
             -&gt;group('e.entity_id')
            -&gt;having('ordered_qty &gt; 0');

        $artistIdConcat = $artistId != '' ? " AND artistId=$artistId" : "";

        $this-&gt;getSelect()
            -&gt;joinInner(
                array('pei' =&gt; $productEntityIntTable),
                "e.entity_id = pei.entity_id",
                array())
            -&gt;joinInner(
                array('ea' =&gt; $eavAttributeTable),
                "pei.attribute_id=ea.attribute_id AND ea.attribute_code='artistid'",
                array())
            -&gt;joinInner(
                array('au' =&gt; $adminUserTable),
                "au.user_id=pei.value",
                array("artistname" =&gt; "CONCAT(firstname, ' ',lastname)"))
            -&gt;joinInner(
                array('ar' =&gt; $artistsTable),
                "ar.artistId=au.user_id".$artistIdConcat,
                array("sale_percentage" =&gt; "CONCAT(sale_percentage,'%')","artist_earned" =&gt; "((SUM(order_items.price)) * (sale_percentage)) / 100"));

        return $this;
    }
</pre>
<p><a href="http://magentocoder.jigneshpatel.co.in/wp-content/uploads/2009/09/Artist_sold_works_report.png" target="_blank"></p>
<p><img class="alignnone size-full wp-image-66" title="Artist_sold_works_report" src="http://magentocoder.jigneshpatel.co.in/wp-content/uploads/2009/09/Artist_sold_works_report.png" alt="Artist_sold_works_report" width="600" /></a></p>
]]></content:encoded>
			<wfw:commentRss>http://magentocoder.jigneshpatel.co.in/create-custom-reports-in-magento-admin/feed/</wfw:commentRss>
		<slash:comments>46</slash:comments>
		</item>
		<item>
		<title>Magento Redirection loop problem after installing SSL</title>
		<link>http://magentocoder.jigneshpatel.co.in/magento-redirection-loop-problem-after-installing-ssl/</link>
		<comments>http://magentocoder.jigneshpatel.co.in/magento-redirection-loop-problem-after-installing-ssl/#comments</comments>
		<pubDate>Thu, 20 Aug 2009 06:15:09 +0000</pubDate>
		<dc:creator>Jignesh</dc:creator>
				<category><![CDATA[PHP]]></category>

		<guid isPermaLink="false">http://magentocoder.jigneshpatel.co.in/?p=55</guid>
		<description><![CDATA[On one of the Magento based project, I am working on I was facing lot many issues after having SSL on Godaddy hosting. Godaddy hosting is always having issues. The biggest problem was, one page checkout page was getting infinite redirection loops. So it was not opening anyhow. The solution was in Magento Admin only: System -&#62; Configuration -&#62; Web. Disable everything under the &#8216;Session Validation Settings&#8217; box.]]></description>
			<content:encoded><![CDATA[<p>On one of the Magento based project, I am working on I was facing lot many issues after having SSL on Godaddy hosting. Godaddy hosting is always having issues.</p>
<p>The biggest problem was, one page checkout page was getting infinite redirection loops. So it was not opening anyhow.</p>
<p>The solution was in Magento Admin only:</p>
<p>System -&gt; Configuration -&gt; Web.<br />
Disable everything under the &#8216;Session Validation Settings&#8217; box.</p>
<p><img class="alignnone size-full wp-image-56" title="Session_Validation_Settings" src="http://magentocoder.jigneshpatel.co.in/wp-content/uploads/2009/08/Session_Validation_Settings.png" alt="Session_Validation_Settings" width="478" height="201" /></p>
]]></content:encoded>
			<wfw:commentRss>http://magentocoder.jigneshpatel.co.in/magento-redirection-loop-problem-after-installing-ssl/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>Automated quick simple product creation in Magento</title>
		<link>http://magentocoder.jigneshpatel.co.in/automated-quick-simple-product-creation-in-magento/</link>
		<comments>http://magentocoder.jigneshpatel.co.in/automated-quick-simple-product-creation-in-magento/#comments</comments>
		<pubDate>Mon, 27 Jul 2009 09:13:37 +0000</pubDate>
		<dc:creator>Jignesh</dc:creator>
				<category><![CDATA[Admin]]></category>

		<guid isPermaLink="false">http://magentocoder.jigneshpatel.co.in/?p=38</guid>
		<description><![CDATA[Creating the Associated Products for the configurable products in Magento is very easy, the way it can be in Admin panel. You just need to fill the values in &#8216;Quick simple product creation&#8217; box &#38; press &#8216;Quick create&#8217; button. However, if you want to create big amount of simple products, its painful to fill the form every time. In my case, I had to create simple product for the T-shirt. I have to choose the [...]]]></description>
			<content:encoded><![CDATA[<p>Creating the Associated Products for the configurable products in Magento is very easy, the way it can be in Admin panel.</p>
<p>You just need to fill the values in &#8216;Quick simple product creation&#8217; box &amp; press &#8216;Quick create&#8217; button.</p>
<p>However, if you want to create big amount of simple products, its painful to fill the form every time.</p>
<p>In my case, I had to create simple product for the T-shirt. I have to choose the Style from the drop down, then color from the drop down &amp; the size from the drop down. There were about 280 combinations. So I had to create 280 simple products.</p>
<p>Then I decided to create a script which can make the process of creating simple products very fast.</p>
<p>I took the inner HTML of &#8216;Quick simple product creation&#8217; box, did some modifications.</p>
<pre class="brush:javascript">
<script type="text/javascript">

var style = new Array();
style['size'] = new Array(100,99,98,136,135,134);
style['sizename'] = new Array('small','medium','large','xl','xxl','xxxl');

var colors = new Array();
colors[24] = "black";
colors[150] = "creme";
colors[149] = "lemon";
colors[57] = "pink";
colors[145] = "babyblue";
colors[144] = "navy";
colors[143] = "asphalt";
colors[25] = "blue";
colors[59] = "brown";
colors[61] = "gray";
colors[22] = "green";
colors[58] = "magneta";
colors[26] = "red";
colors[23] = "silver";
colors[60] = "white";

function savedata()
{
	for (i in style['size'])
	{
		submitdata(style['size'][i],style['sizename'][i]);
	}
}

function submitdata(tsize,tsizename) {
	var frmObj = document.forms['formsimple'];
	frmObj.target = "_blank";
	var colorkey;
	colorkey = 24;	

	frmObj.elements['simple_product[name]'].value = 'productname_style_'+colors[key]+'_'+tsizename;
	frmObj.elements['simple_product[color]'].value = colorkey; 
	frmObj.elements['simple_product[style]'].value = 100;
	frmObj.elements['simple_product[shirt_size]'].value = tsize ;
	frmObj.submit();
}

</script>
</pre>
<pre class="brush:php">
<div id="config_super_product_simple_form" class="configurable-simple-product ignore-validate">
<div class="entry-edit">
<div class="entry-edit-head">
<h4 class="icon-head head-edit-form fieldset-legend">Quick simple product creation</h4>
<div class="form-buttons"></div>
<div id="simple_product" class="fieldset">
<div class="hor-scroll">

<!-- Set the action URL for the form below as per your need, in the below line 299 is the id of the configurable product  -->
<form action="http://www.hostname.com/index.php/admin/catalog_product/quickCreate/product/299/?isAjax=true" method="post">
<input name="form_key" type="hidden" />
<table class="form-list" style="width: 100%;" border="0" cellspacing="0">
<tbody>
<tr>
<td class="label"><label for="simple_product_name">Name <span class="required">*</span></label></td>
<td class="value">
<input id="simple_product_name" class="required-entry input-text validation-passed" name="simple_product[name]" type="text" />
<input id="simple_product_name_autogenerate" onclick="toggleValueElements(this, this.parentNode)" name="simple_product[name_autogenerate]" type="checkbox" value="1" /> <label for="simple_product_name_autogenerate">Autogenerate</label></td>
<td class="scope-label">[STORE VIEW]</td>
<td><small> </small></td>
</tr>
<tr>
<td class="label"><label for="simple_product_sku">SKU <span class="required">*</span></label></td>
<td class="value">
<input id="simple_product_sku" class="required-entry input-text validation-passed disabled" name="simple_product[sku]" type="text" />
<input id="simple_product_sku_autogenerate" onclick="toggleValueElements(this, this.parentNode)" checked="checked" name="simple_product[sku_autogenerate]" type="checkbox" value="1" /> <label for="simple_product_sku_autogenerate">Autogenerate</label></td>
<td class="scope-label">[GLOBAL]</td>
<td><small> </small></td>
</tr>
<tr>
<td class="label"><label for="simple_product_status">Status <span class="required">*</span></label></td>
<td class="value">
<select id="simple_product_status" class="required-entry select validation-passed" name="simple_product[status]">
<option>-- Please Select --</option>
<option selected="selected" value="1">Enabled</option>
<option value="2">Disabled</option>
</select>
</td>
<td class="scope-label">[WEBSITE]</td>
<td><small> </small></td>
</tr>
<tr>
<td class="label"><label for="simple_product_visibility">Visibility <span class="required">*</span></label></td>
<td class="value">
<select id="simple_product_visibility" class="required-entry select validation-passed" name="simple_product[visibility]">
<option>-- Please Select --</option>
<option selected="selected" value="1">Nowhere</option>
<option value="2">Catalog</option>
<option value="3">Search</option>
<option value="4">Catalog, Search</option>
</select>
</td>
<td class="scope-label">[STORE VIEW]</td>
<td><small> </small></td>
</tr>
<tr>
<td class="label"><label for="simple_product_style">Style <span class="required">*</span></label></td>
<td class="value">
<div class="left">
<select id="simple_product_style" class="validate-configurable required-entry select validation-passed" name="simple_product[style]">
<option selected="selected">
		</option>
<option value="125">Men</option>
<option value="123">Hoodies</option>
<option value="124">Women</option>
<option value="127">Kids</option>
</select>
</div>
<div id="simple_product_style_pricing_container" class="left">
<div>
<div id="advice-validate-configurable-simple_product_style" class="validation-advice" style="display: none;">Product with this combination of attributes already associated to configurable.</div>
</div>
</div>
</td>
<td class="scope-label"></td>
<td><small> </small></td>
</tr>
<tr>
<td class="label"><label for="simple_product_color">Color <span class="required">*</span></label></td>
<td class="value">
<div class="left">
<select id="simple_product_color" class="validate-configurable required-entry select validation-passed" name="simple_product[color]">
<option selected="selected">
		</option>
<option value="24">Black</option>
<option value="150">Creme</option>
<option value="149">Lemon</option>
<option value="57">Pink</option>
<option value="145">Baby Blue</option>
<option value="144">Navy</option>
<option value="143">Asphalt</option>
<option value="25">Blue</option>
<option value="59">Brown</option>
<option value="61">Gray</option>
<option value="22">Green</option>
<option value="58">Magneta</option>
<option value="26">Red</option>
<option value="23">Silver</option>
<option value="60">White</option>
</select>
</div>
<div id="simple_product_color_pricing_container" class="left">
<div>
<div id="advice-validate-configurable-simple_product_color" class="validation-advice" style="display: none;">Product with this combination of attributes already associated to configurable.</div>
</div>
</div>
</td>
<td class="scope-label"></td>
<td><small> </small></td>
</tr>
<tr>
<td class="label"><label for="simple_product_shirt_size">Size <span class="required">*</span></label></td>
<td class="value">
<div class="left">
<select id="simple_product_shirt_size" class="validate-configurable required-entry select validation-passed" name="simple_product[shirt_size]">
<option selected="selected">
		</option>
<option value="136">X Large</option>
<option value="137">X Small</option>
<option value="135">XX Large</option>
<option value="134">XXX Large</option>
<option value="100">Small</option>
<option value="99">Medium</option>
<option value="98">Large</option>
</select>
</div>
<div id="simple_product_shirt_size_pricing_container" class="left">
<div>
<div id="advice-validate-configurable-simple_product_shirt_size" class="validation-advice" style="display: none;">Product with this combination of attributes already associated to configurable.</div>
</div>
</div>
</td>
<td class="scope-label"></td>
<td><small> </small></td>
</tr>
<tr>
<td class="label"><label for="simple_product_inventory_qty">Qty <span class="required">*</span></label></td>
<td class="value">
<input id="simple_product_inventory_qty" class="validate-number required-entry input-text validation-passed" name="simple_product[stock_data][qty]" type="text" value="100" /></td>
<td class="scope-label"></td>
<td><small> </small></td>
</tr>
<tr>
<td class="label"><label for="simple_product_inventory_is_in_stock">Stock Availability</label></td>
<td class="value">
<select id="simple_product_inventory_is_in_stock" class="select validation-passed" name="simple_product[stock_data][is_in_stock]">
<option selected="selected" value="1">In Stock</option>
<option value="0">Out of Stock</option>
</select>
</td>
<td class="scope-label"></td>
<td><small> </small></td>
</tr>
<input id="simple_product_color_pricing_value" name="simple_product[pricing][color][value]" type="hidden" />
<input id="simple_product_color_pricing_type" name="simple_product[pricing][color][is_percent]" type="hidden" />
<input id="simple_product_style_pricing_value" name="simple_product[pricing][style][value]" type="hidden" />
<input id="simple_product_style_pricing_type" name="simple_product[pricing][style][is_percent]" type="hidden" />
<input id="simple_product_shirt_size_pricing_value" name="simple_product[pricing][shirt_size][value]" type="hidden" />
<input id="simple_product_shirt_size_pricing_type" name="simple_product[pricing][shirt_size][is_percent]" type="hidden" />
<input id="simple_product_inventory_use_config_min_qty" name="simple_product[stock_data][use_config_min_qty]" type="hidden" value="1" />
<input id="simple_product_inventory_use_config_min_sale_qty" name="simple_product[stock_data][use_config_min_sale_qty]" type="hidden" value="1" />
<input id="simple_product_inventory_use_config_max_sale_qty" name="simple_product[stock_data][use_config_max_sale_qty]" type="hidden" value="1" />
<input id="simple_product_inventory_use_config_backorders" name="simple_product[stock_data][use_config_backorders]" type="hidden" value="1" />
<input id="simple_product_inventory_use_config_notify_stock_qty" name="simple_product[stock_data][use_config_notify_stock_qty]" type="hidden" value="1" />
<input id="simple_product_inventory_is_qty_decimal" name="simple_product[stock_data][is_qty_decimal]" type="hidden" value="0" />
<tr>
<td class="label"></td>
<td class="value"><span id="create_button">
    <button id="id_c49ac12a15be8789166c9c04a3c46e4e" class="scalable save" onclick="savedata()"><span>Quick Create</span></button>
    </span></td>
<td class="scope-label"></td>
<td><small> </small></td>
</tr>
</tbody>
</table>
</form>
</div>
</div>
</div>
</div>
</div>
</pre>
<p><b>If you want to use the above script, follow the steps below:</b><br />
Set the array with the id of the size labels. </p>
<pre class="brush:javascript">
var style = new Array();
style['size'] = new Array(100,99,98,136,135,134);
style['sizename'] = new Array('small','medium','large','xl','xxl','xxxl');
</pre>
<p>Create the colors array, here the key will be the label id of the attribute &#038; the value can be anything which will used in the name of the simple product you are going to create</p>
<pre class="brush:javascript">
var colors = new Array();
colors[24] = "black";
colors[150] = "creme";
.
.
.
</pre>
<p>.</p>
<p><b>Example:</b></p>
<p>I want to create simple product having the attributes as per below:<br />
Style: Men<br />
Color: Black<br />
Size: Small</p>
<p>So I can set the colorkey with value 24 (on line 44).</p>
<pre class="brush:php">
colorkey = 24;
</pre>
<p>Set the style on line 48.</p>
<pre class="brush:php">
frmObj.elements['simple_product[style]'].value = 125;
</pre>
<p>Save the file &#038; run it in browser. You will see the screen as below.</p>
<p><img src="http://magentocoder.jigneshpatel.co.in/wp-content/uploads/2009/07/screen554115502.png" alt="Quick simple product creation" title="Quick simple product creation" width="591" class="alignnone size-full wp-image-49" /></p>
<p>Press the Quick create button. This will submit the form to your host. Make sure that you are logged in as Admin in your Magento setup. </p>
<p>In this case the form will submitted six times, each time with different value of shirt size. As a result six products will be inserted with Black color, in Man style with size different sizes.</p>
<p>The mechanism above is bit tricky &#038; awkward. Let me know your doubts in comments.</p>
]]></content:encoded>
			<wfw:commentRss>http://magentocoder.jigneshpatel.co.in/automated-quick-simple-product-creation-in-magento/feed/</wfw:commentRss>
		<slash:comments>5</slash:comments>
		</item>
		<item>
		<title>Add custom input fields on Admin html forms in Magento</title>
		<link>http://magentocoder.jigneshpatel.co.in/add-custom-input-fields-on-admin-html-in-magento/</link>
		<comments>http://magentocoder.jigneshpatel.co.in/add-custom-input-fields-on-admin-html-in-magento/#comments</comments>
		<pubDate>Thu, 16 Jul 2009 13:11:41 +0000</pubDate>
		<dc:creator>Jignesh</dc:creator>
				<category><![CDATA[Admin]]></category>

		<guid isPermaLink="false">http://magentocoder.jigneshpatel.co.in/?p=21</guid>
		<description><![CDATA[Adding a custom input type on the forms on Admin html is very easy. I used this in the module which I created with Module Creator. I supposed to show the uploaded image on the edit form on Admin. The images are uploaded by the user from the front end. For displaying the thumbnail, by default there is no way in Magento. So I created a new class &#8216;Varien_Data_Form_Element_Thumbnail&#8217; &#38; named it Thumbnail.php. class Varien_Data_Form_Element_Thumbnail [...]]]></description>
			<content:encoded><![CDATA[<p>Adding a custom input type on the forms on Admin html is very easy.</p>
<p>I used this in the module which I created with <a href="http://www.magentocommerce.com/extension/1108/modulecreator">Module Creator</a>.<br />
I supposed to show the uploaded image on the edit form on Admin. The images are uploaded by the user from the front end.</p>
<p>For displaying the thumbnail, by default there is no way in Magento.<br />
So I created a new class &#8216;Varien_Data_Form_Element_Thumbnail&#8217; &amp; named it Thumbnail.php.</p>
<pre class="brush:php">
class Varien_Data_Form_Element_Thumbnail extends Varien_Data_Form_Element_Abstract
{
    public function __construct($data)
    {
        parent::__construct($data);
        $this-&gt;setType('file');
    }

    public function getElementHtml()
    {
        $html = '';

        if ($this-&gt;getValue()) {
            $url = $this-&gt;_getUrl();

            if( !preg_match("/^http\:\/\/|https\:\/\//", $url) ) {
                $url = Mage::getBaseUrl('media') . $url;
            }

            $html = '<a onclick="imagePreview(\''.$this-&gt;getHtmlId().'_image\'); return false;" href="'.$url.'"><img id="'.$this-&gt;getHtmlId().'_image" class="small-image-preview v-middle" style="border: 1px solid #d6d6d6;" title="'.$this-&gt;getValue().'" src="'.$url.'" alt="'.$this-&gt;getValue().'" width="300" /></a> ';
        }
        $this-&gt;setClass('input-file');
        $html.= parent::getElementHtml();

        return $html;
    }

    protected function _getUrl()
    {
        return $this-&gt;getValue();
    }

    public function getName()
    {
        return  $this-&gt;getData('name');
    }
}
</pre>
<p>Copy the file at &#8216;/lib/Varien/Data/Form/Element/&#8217;.</p>
<p>To Display the thumbnail, inside the function _prepareForm() write the code below. (In my case I edited the file.. &#8216;app/code/local/Mage/Modulename/Block/Adminhtml/Modulename/Edit/Tab/Form.php&#8217;. This module was created with Module Creator)</p>
<pre class="brush:php">
$form = new Varien_Data_Form();
      $this-&gt;setForm($form);
      $fieldset = $form-&gt;addFieldset('modulename_form', array('legend'=&gt;Mage::helper('modulename')-&gt;__('Module information')));
      $tempArray = array(
	          'label'     =&gt; Mage::helper('arequets')-&gt;__('Sample Work'),
	          'name'      =&gt; 'samplefilename',
	          'style'     =&gt; 'display:none;',
		  );
      $fieldset-&gt;addField('samplefilename', 'thumbnail',$tempArray);
</pre>
<p>Here, &#8216;samplefilename&#8217; should be the path of the thumbnail.</p>
]]></content:encoded>
			<wfw:commentRss>http://magentocoder.jigneshpatel.co.in/add-custom-input-fields-on-admin-html-in-magento/feed/</wfw:commentRss>
		<slash:comments>19</slash:comments>
		</item>
	</channel>
</rss>

