Version Notes
Automatically create SKUs for products that are manually added via admin or imported via CSV of XML files for admin. This is ideal for stores that do not have a fixed SKU coming in from external ERP systems or their suppliers. The extension works on both Enterprise and Community Editions.
Download this release
Release Info
Developer | Shilpa |
Extension | SKU_Auto_Generator |
Version | 1.0.5 |
Comparing to | |
See all releases |
Code changes from version 1.0.4 to 1.0.5
app/code/local/Neev/Skuautogenerate/Block/Adminhtml/Catalog/Product/Edit.php
CHANGED
@@ -34,19 +34,93 @@
|
|
34 |
|
35 |
class Neev_Skuautogenerate_Block_Adminhtml_Catalog_Product_Edit extends Mage_Adminhtml_Block_Catalog_Product_Edit
|
36 |
{
|
37 |
-
|
|
|
38 |
{
|
39 |
-
|
40 |
$this->setTemplate('skuautogenerate/catalog/product/edit.phtml');
|
41 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
42 |
}
|
43 |
-
|
44 |
|
45 |
public function skuAuto($type)
|
46 |
{
|
47 |
$connection = Mage::getSingleton('core/resource')->getConnection('read');
|
48 |
-
|
49 |
-
|
|
|
50 |
$skuautores=$skuauto->fetch();
|
51 |
if(!$skuautores["skuautogenerate_id"]){
|
52 |
$skuauto = $connection->query("SELECT * FROM {$table} WHERE product_type='unique'");
|
@@ -58,7 +132,7 @@ public function __construct()
|
|
58 |
public function getprevEntityId()
|
59 |
{
|
60 |
$connection = Mage::getSingleton('core/resource')->getConnection('read');
|
61 |
-
$table =
|
62 |
$sql = "SELECT entity_id FROM {$table} ORDER BY entity_id DESC LIMIT 1";
|
63 |
$getprevEntityId=$connection->fetchOne($sql);
|
64 |
return $getprevEntityId;
|
34 |
|
35 |
class Neev_Skuautogenerate_Block_Adminhtml_Catalog_Product_Edit extends Mage_Adminhtml_Block_Catalog_Product_Edit
|
36 |
{
|
37 |
+
|
38 |
+
protected function _prepareLayout()
|
39 |
{
|
40 |
+
if (!$this->getRequest()->getParam('popup')) {
|
41 |
$this->setTemplate('skuautogenerate/catalog/product/edit.phtml');
|
42 |
+
|
43 |
+
$this->setChild('back_button',
|
44 |
+
$this->getLayout()->createBlock('adminhtml/widget_button')
|
45 |
+
->setData(array(
|
46 |
+
'label' => Mage::helper('catalog')->__('Back'),
|
47 |
+
'onclick' => 'setLocation(\''.$this->getUrl('*/*/', array('store'=>$this->getRequest()->getParam('store', 0))).'\')',
|
48 |
+
'class' => 'back'
|
49 |
+
))
|
50 |
+
);
|
51 |
+
} else {
|
52 |
+
$this->setChild('back_button',
|
53 |
+
$this->getLayout()->createBlock('adminhtml/widget_button')
|
54 |
+
->setData(array(
|
55 |
+
'label' => Mage::helper('catalog')->__('Close Window'),
|
56 |
+
'onclick' => 'window.close()',
|
57 |
+
'class' => 'cancel'
|
58 |
+
))
|
59 |
+
);
|
60 |
+
}
|
61 |
+
|
62 |
+
if (!$this->getProduct()->isReadonly()) {
|
63 |
+
$this->setChild('reset_button',
|
64 |
+
$this->getLayout()->createBlock('adminhtml/widget_button')
|
65 |
+
->setData(array(
|
66 |
+
'label' => Mage::helper('catalog')->__('Reset'),
|
67 |
+
'onclick' => 'setLocation(\''.$this->getUrl('*/*/*', array('_current'=>true)).'\')'
|
68 |
+
))
|
69 |
+
);
|
70 |
+
|
71 |
+
$this->setChild('save_button',
|
72 |
+
$this->getLayout()->createBlock('adminhtml/widget_button')
|
73 |
+
->setData(array(
|
74 |
+
'label' => Mage::helper('catalog')->__('Save'),
|
75 |
+
'onclick' => 'removeCheck();productForm.submit()',
|
76 |
+
'class' => 'save'
|
77 |
+
))
|
78 |
+
);
|
79 |
+
}
|
80 |
+
|
81 |
+
if (!$this->getRequest()->getParam('popup')) {
|
82 |
+
if (!$this->getProduct()->isReadonly()) {
|
83 |
+
$this->setChild('save_and_edit_button',
|
84 |
+
$this->getLayout()->createBlock('adminhtml/widget_button')
|
85 |
+
->setData(array(
|
86 |
+
'label' => Mage::helper('catalog')->__('Save and Continue Edit'),
|
87 |
+
'onclick' => 'removeCheck();saveAndContinueEdit(\''.$this->getSaveAndContinueUrl().'\')',
|
88 |
+
'class' => 'save'
|
89 |
+
))
|
90 |
+
);
|
91 |
+
}
|
92 |
+
if ($this->getProduct()->isDeleteable()) {
|
93 |
+
$this->setChild('delete_button',
|
94 |
+
$this->getLayout()->createBlock('adminhtml/widget_button')
|
95 |
+
->setData(array(
|
96 |
+
'label' => Mage::helper('catalog')->__('Delete'),
|
97 |
+
'onclick' => 'confirmSetLocation(\''.Mage::helper('catalog')->__('Are you sure?').'\', \''.$this->getDeleteUrl().'\')',
|
98 |
+
'class' => 'delete'
|
99 |
+
))
|
100 |
+
);
|
101 |
+
}
|
102 |
+
|
103 |
+
if ($this->getProduct()->isDuplicable()) {
|
104 |
+
$this->setChild('duplicate_button',
|
105 |
+
$this->getLayout()->createBlock('adminhtml/widget_button')
|
106 |
+
->setData(array(
|
107 |
+
'label' => Mage::helper('catalog')->__('Duplicate'),
|
108 |
+
'onclick' => 'setLocation(\'' . $this->getDuplicateUrl() . '\')',
|
109 |
+
'class' => 'add'
|
110 |
+
))
|
111 |
+
);
|
112 |
+
}
|
113 |
+
}
|
114 |
+
|
115 |
+
// return parent::_prepareLayout();
|
116 |
}
|
|
|
117 |
|
118 |
public function skuAuto($type)
|
119 |
{
|
120 |
$connection = Mage::getSingleton('core/resource')->getConnection('read');
|
121 |
+
$table = Mage::getSingleton('core/resource')->getTableName('skuautogenerate');
|
122 |
+
|
123 |
+
$skuauto = $connection->query("SELECT skuautogenerate_id,appendstring , min_length FROM {$table} WHERE status = 1 AND product_type='{$type}'");
|
124 |
$skuautores=$skuauto->fetch();
|
125 |
if(!$skuautores["skuautogenerate_id"]){
|
126 |
$skuauto = $connection->query("SELECT * FROM {$table} WHERE product_type='unique'");
|
132 |
public function getprevEntityId()
|
133 |
{
|
134 |
$connection = Mage::getSingleton('core/resource')->getConnection('read');
|
135 |
+
$table = Mage::getSingleton('core/resource')->getTableName('catalog_product_entity');
|
136 |
$sql = "SELECT entity_id FROM {$table} ORDER BY entity_id DESC LIMIT 1";
|
137 |
$getprevEntityId=$connection->fetchOne($sql);
|
138 |
return $getprevEntityId;
|
app/code/local/Neev/Skuautogenerate/sql/skuautogenerate_setup/mysql4-install-0.1.0.php
CHANGED
@@ -6,12 +6,12 @@ $installer->startSetup();
|
|
6 |
|
7 |
$installer->run("
|
8 |
|
9 |
-
DROP TABLE IF EXISTS {$this->getTable('skuautogenerate')};
|
10 |
CREATE TABLE {$this->getTable('skuautogenerate')} (
|
11 |
`skuautogenerate_id` int(11) unsigned NOT NULL auto_increment,
|
12 |
-
`
|
13 |
-
|
14 |
-
|
15 |
`min_length` varchar(5) NOT NULL default '',
|
16 |
`product_type` varchar(50) NOT NULL default '',
|
17 |
`status` smallint(6) NOT NULL default '0',
|
@@ -23,15 +23,15 @@ CREATE TABLE {$this->getTable('skuautogenerate')} (
|
|
23 |
");
|
24 |
$installer->run("INSERT INTO {$this->getTable('skuautogenerate')} (
|
25 |
`skuautogenerate_id` ,
|
26 |
-
`
|
27 |
-
`
|
28 |
`stringfunction` ,
|
29 |
`min_length` ,
|
30 |
`product_type` ,
|
31 |
`status`
|
32 |
)
|
33 |
VALUES (
|
34 |
-
NULL , '', 'PRE', '
|
35 |
)");
|
36 |
|
37 |
$installer->endSetup();
|
6 |
|
7 |
$installer->run("
|
8 |
|
9 |
+
-- DROP TABLE IF EXISTS {$this->getTable('skuautogenerate')};
|
10 |
CREATE TABLE {$this->getTable('skuautogenerate')} (
|
11 |
`skuautogenerate_id` int(11) unsigned NOT NULL auto_increment,
|
12 |
+
`appendstring` varchar(5) NOT NULL default '',
|
13 |
+
`prependstring` varchar(5) NOT NULL default '',
|
14 |
+
`stringfunction` varchar(50) NOT NULL default '',
|
15 |
`min_length` varchar(5) NOT NULL default '',
|
16 |
`product_type` varchar(50) NOT NULL default '',
|
17 |
`status` smallint(6) NOT NULL default '0',
|
23 |
");
|
24 |
$installer->run("INSERT INTO {$this->getTable('skuautogenerate')} (
|
25 |
`skuautogenerate_id` ,
|
26 |
+
`appendstring` ,
|
27 |
+
`prependstring` ,
|
28 |
`stringfunction` ,
|
29 |
`min_length` ,
|
30 |
`product_type` ,
|
31 |
`status`
|
32 |
)
|
33 |
VALUES (
|
34 |
+
NULL , '', 'PRE', 'prepend', '10', 'unique', '1'
|
35 |
)");
|
36 |
|
37 |
$installer->endSetup();
|
app/design/adminhtml/default/default/template/skuautogenerate/catalog/product/edit.phtml
CHANGED
@@ -31,9 +31,7 @@
|
|
31 |
?>
|
32 |
|
33 |
|
34 |
-
|
35 |
-
Mage::getSingleton('adminhtml/session')->addNotice($msg); ?>
|
36 |
-
|
37 |
<div class="content-header">
|
38 |
<h3 class="icon-head head-products"><?php echo $this->getHeader() ?></h3>
|
39 |
<p class="content-buttons form-buttons"><?php echo $this->getBackButtonHtml() ?>
|
@@ -86,6 +84,7 @@ function saveAndContinueEdit(urlTemplate) {
|
|
86 |
function setSettings(urlTemplate, setElement, typeElement) {
|
87 |
var template = new Template(urlTemplate, productTemplateSyntax);
|
88 |
setLocation(template.evaluate({attribute_set:$F(setElement),type:$F(typeElement)}));
|
|
|
89 |
}
|
90 |
|
91 |
function setSuperSettings(urlTemplate, attributesClass, validateField) {
|
@@ -138,48 +137,57 @@ function setSettings(urlTemplate, setElement, typeElement) {
|
|
138 |
|
139 |
<?php
|
140 |
$getprevEntityId=$this->getprevEntityId();
|
141 |
-
if($this->getRequest()->getParam('type')
|
142 |
$skuautores= $this->skuAuto($this->getRequest()->getParam('type'));
|
143 |
-
|
144 |
?>
|
145 |
|
146 |
<script type="text/javascript">
|
147 |
if(document.getElementById('sku').value == ""){
|
148 |
var skustring,finalskustring;
|
149 |
-
var
|
150 |
-
var minlen
|
151 |
-
var
|
152 |
-
var
|
153 |
var stingfunction="<?php echo $skuautores["stringfunction"] ?>";
|
154 |
-
if(stingfunction=="
|
155 |
-
skustring=
|
156 |
if(skustring.length < minlen)
|
157 |
-
finalskustring= Array(minlen+1-skustring.length).join(0) +
|
158 |
else var finalskustring=skustring;
|
159 |
}
|
160 |
-
else if(stingfunction=="
|
161 |
-
skustring=
|
162 |
if(skustring.length < minlen)
|
163 |
-
finalskustring=
|
164 |
else var finalskustring=skustring;
|
165 |
}
|
166 |
else {
|
167 |
-
skustring = "<?php echo $skuautores["
|
168 |
-
if(skustring.length < minlen)
|
169 |
-
finalskustring=
|
|
|
170 |
else var finalskustring=skustring;
|
171 |
}
|
172 |
//Code to place sku in text box
|
173 |
var innermyspan =$('sku').parentNode.innerHTML;
|
174 |
$('sku').parentNode.innerHTML = innermyspan+'<input type="checkbox" class="checkbox" onclick="toggleValueElements(this, this.parentNode);istoggle();" checked="checked" value="1" name="isauto" id="isauto">';
|
175 |
document.getElementById('sku').value =finalskustring;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
176 |
}
|
|
|
177 |
|
178 |
function istoggle(){
|
179 |
if(document.getElementById('isauto').checked){
|
180 |
|
181 |
document.getElementById('sku').value =finalskustring;}}
|
182 |
-
toggleValueElements($('isauto'), $('isauto').parentNode);
|
183 |
</script>
|
184 |
-
<?php endif; ?>
|
185 |
-
<?php endif; ?>
|
31 |
?>
|
32 |
|
33 |
|
34 |
+
<h1>Auto Generate Sku Module is enable.</h1>
|
|
|
|
|
35 |
<div class="content-header">
|
36 |
<h3 class="icon-head head-products"><?php echo $this->getHeader() ?></h3>
|
37 |
<p class="content-buttons form-buttons"><?php echo $this->getBackButtonHtml() ?>
|
84 |
function setSettings(urlTemplate, setElement, typeElement) {
|
85 |
var template = new Template(urlTemplate, productTemplateSyntax);
|
86 |
setLocation(template.evaluate({attribute_set:$F(setElement),type:$F(typeElement)}));
|
87 |
+
//alert($F(typeElement));
|
88 |
}
|
89 |
|
90 |
function setSuperSettings(urlTemplate, attributesClass, validateField) {
|
137 |
|
138 |
<?php
|
139 |
$getprevEntityId=$this->getprevEntityId();
|
140 |
+
if($this->getRequest()->getParam('type'))
|
141 |
$skuautores= $this->skuAuto($this->getRequest()->getParam('type'));
|
142 |
+
|
143 |
?>
|
144 |
|
145 |
<script type="text/javascript">
|
146 |
if(document.getElementById('sku').value == ""){
|
147 |
var skustring,finalskustring;
|
148 |
+
var skustringtoprepend="<?php echo $skuautores["prependstring"]; ?>";
|
149 |
+
var minlen=parseInt('<?php echo $skuautores["min_length"]; ?>');
|
150 |
+
var append="<?php echo ($getprevEntityId + 1).$skuautores["appendstring"]; ?>";
|
151 |
+
var prepend="<?php echo $skuautores["prependstring"].($getprevEntityId + 1); ?>";
|
152 |
var stingfunction="<?php echo $skuautores["stringfunction"] ?>";
|
153 |
+
if(stingfunction=="append"){
|
154 |
+
skustring=append;
|
155 |
if(skustring.length < minlen)
|
156 |
+
finalskustring= Array(minlen+1-skustring.length).join(0) + append;
|
157 |
else var finalskustring=skustring;
|
158 |
}
|
159 |
+
else if(stingfunction=="prepend"){
|
160 |
+
skustring=prepend;
|
161 |
if(skustring.length < minlen)
|
162 |
+
finalskustring= skustringtoprepend + Array(minlen+1-skustring.length).join(0) + <?php echo $getprevEntityId + 1 ?> ;
|
163 |
else var finalskustring=skustring;
|
164 |
}
|
165 |
else {
|
166 |
+
skustring = "<?php echo $skuautores["prependstring"].($getprevEntityId + 1).$skuautores["appendstring"]; ?>";
|
167 |
+
if(skustring.length < minlen){
|
168 |
+
finalskustring=skustringtoprepend + Array(minlen+1-skustring.length).join(0) + append;
|
169 |
+
alert(finalskustring);}
|
170 |
else var finalskustring=skustring;
|
171 |
}
|
172 |
//Code to place sku in text box
|
173 |
var innermyspan =$('sku').parentNode.innerHTML;
|
174 |
$('sku').parentNode.innerHTML = innermyspan+'<input type="checkbox" class="checkbox" onclick="toggleValueElements(this, this.parentNode);istoggle();" checked="checked" value="1" name="isauto" id="isauto">';
|
175 |
document.getElementById('sku').value =finalskustring;
|
176 |
+
toggleValueElements($('isauto'), $('isauto').parentNode);
|
177 |
+
|
178 |
+
}
|
179 |
+
|
180 |
+
function removeCheck(){
|
181 |
+
if(document.getElementById('sku').value!=""){
|
182 |
+
if(document.getElementById("isauto"))
|
183 |
+
document.getElementById("isauto").checked = false;
|
184 |
+
document.getElementById('sku').disabled = false;
|
185 |
+
|
186 |
}
|
187 |
+
}
|
188 |
|
189 |
function istoggle(){
|
190 |
if(document.getElementById('isauto').checked){
|
191 |
|
192 |
document.getElementById('sku').value =finalskustring;}}
|
|
|
193 |
</script>
|
|
|
|
package.xml
CHANGED
@@ -1,18 +1,18 @@
|
|
1 |
<?xml version="1.0"?>
|
2 |
<package>
|
3 |
<name>SKU_Auto_Generator</name>
|
4 |
-
<version>1.0.
|
5 |
<stability>stable</stability>
|
6 |
-
<license>OSL</license>
|
7 |
<channel>community</channel>
|
8 |
<extends/>
|
9 |
-
<summary>Automatically create SKUs for products that are manually added via admin or imported via CSV of XML files.</summary>
|
10 |
-
<description>Automatically create SKUs for products that are manually added via admin or imported via CSV of XML files.</description>
|
11 |
-
<notes>Automatically create SKUs for products that are manually added via admin or imported via CSV of XML files.</notes>
|
12 |
-
<authors><author><name>
|
13 |
-
<date>2013-
|
14 |
-
<time>
|
15 |
-
<contents><target name="mage"><dir name="app"><dir name="code"><dir name="local"><dir name="Neev"><
|
16 |
<compatible/>
|
17 |
-
<dependencies
|
18 |
</package>
|
1 |
<?xml version="1.0"?>
|
2 |
<package>
|
3 |
<name>SKU_Auto_Generator</name>
|
4 |
+
<version>1.0.5</version>
|
5 |
<stability>stable</stability>
|
6 |
+
<license uri="http://opensource.org/licenses/osl-3.0.php">OSL</license>
|
7 |
<channel>community</channel>
|
8 |
<extends/>
|
9 |
+
<summary>Automatically create SKUs for products that are manually added via admin or imported via CSV of XML files for admin. This is ideal for stores that do not have a fixed SKU coming in from external ERP systems or their suppliers. The extension works on both Enterprise and Community Editions.</summary>
|
10 |
+
<description>Automatically create SKUs for products that are manually added via admin or imported via CSV of XML files for admin. This is ideal for stores that do not have a fixed SKU coming in from external ERP systems or their suppliers. The extension works on both Enterprise and Community Editions.</description>
|
11 |
+
<notes>Automatically create SKUs for products that are manually added via admin or imported via CSV of XML files for admin. This is ideal for stores that do not have a fixed SKU coming in from external ERP systems or their suppliers. The extension works on both Enterprise and Community Editions.</notes>
|
12 |
+
<authors><author><name>Shilpa</name><user>Neev</user><email>magentoaccount@neevtech.com</email></author></authors>
|
13 |
+
<date>2013-09-13</date>
|
14 |
+
<time>05:16:56</time>
|
15 |
+
<contents><target name="mage"><dir name="app"><dir name="code"><dir name="local"><dir name="Neev"><file name="HowTouse.txt" hash=""/><dir><dir name="Skuautogenerate"><dir name="Block"><dir name="Adminhtml"><dir name="Catalog"><dir name="Product"><file name="Edit.php" hash="84d689f2f622195f04f5cbb5be57425c"/></dir></dir><dir name="Skuautogenerate"><dir name="Edit"><file name="Form.php" hash="6d3cea1cb156ab627f78be0809ef69f1"/><dir name="Tab"><file name="Form.php" hash="b395242561f3880f45fac6b534ba0457"/></dir><file name="Tabs.php" hash="7e3677bb77a034f28742cbd8cebafac4"/></dir><file name="Edit.php" hash="5630983d8c038d4772e996b5bbf5868c"/><file name="Grid.php" hash="927513b143d1ec99532fa5a71903f967"/></dir><file name="Skuautogenerate.php" hash="dd8e6d26cba313240428e8cc7f5a9fc3"/></dir><file name="Skuautogenerate.php" hash="5c4fa69402f87f9ac3a0aa15ca790b58"/></dir><dir name="Helper"><file name="Data.php" hash="4e9fb6d3fa6104bbf645815831615bf7"/></dir><dir name="Model"><dir name="Mysql4"><dir name="Skuautogenerate"><file name="Collection.php" hash="cd83d79930f6141b72f4eb885d648522"/></dir><file name="Skuautogenerate.php" hash="b2fc3235c1dfc0c7592354597fff696e"/></dir><file name="Skuautogenerate.php" hash="1b3d1452e9152f0225d0055205edb5f0"/><file name="Status.php" hash="044ca08797c2ac7643e14c65d1e7cbc6"/></dir><dir name="controllers"><dir name="Adminhtml"><file name="SkuautogenerateController.php" hash="741da95b0774e7835958d4984f08c402"/></dir><file name="IndexController.php" hash="14a0aa7d2586c277fbe896dc379f2bce"/></dir><dir name="etc"><file name="config.xml" hash="fecc9aa2b9129bfb86a8a30ae23f8a7f"/></dir><dir name="sql"><dir name="skuautogenerate_setup"><file name="mysql4-install-0.1.0.php" hash="25a2cacc2fcee16857777af2cafe5e33"/></dir></dir></dir></dir></dir></dir></dir><dir name="etc"><dir name="modules"><file name="Neev_Skuautogenerate.xml" hash="bcbd229d7ef67308e8b8802233d96da2"/></dir></dir><dir name="design"><dir name="adminhtml"><dir name="default"><dir name="default"><dir name="template"><dir name="skuautogenerate"><dir name="catalog"><dir name="product"><file name="edit.phtml" hash="3d3e29e44efd5aed9116e910f2e075cd"/></dir></dir></dir></dir><dir name="layout"><file name="skuautogenerate.xml" hash="daaef43e86f6b7da79c2d48cd5d1ca15"/></dir></dir></dir></dir></dir></dir></target></contents>
|
16 |
<compatible/>
|
17 |
+
<dependencies><required><php><min>5.1.0</min><max>6.0.0</max></php><package><name></name><channel>connect.magentocommerce.com/core</channel><min></min><max></max></package></required></dependencies>
|
18 |
</package>
|