<?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 &#187; Admin</title>
	<atom:link href="http://magentocoder.jigneshpatel.co.in/category/admin/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>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>

