Gec_Customimport - Version 2.0.0.3

Version Notes

Major bug-fix and feature release (Tested on Magento 1.9.x)

Bug-fixes:

1. The extension is now independent of any frontend theme changes. Earlier theme changes required porting of frontend section to the new theme.

2. Added missing referential integrity for 'default' attributeset that needs to be associated with products having an empty attributesetid.

3. Fixed attribute value import for text, textarea and boolean attributes.

New Features & Improvements:

1. Default turning off visibility in search results for simple products associated to configurable ones.

2. Import of special price and related dates to enable scheduling of sale pricing.

3. Inventory control - ATP quantity and ability to control back-ordering of products.

4. Several major logging improvements.

5. Improved error-handling, data error tolerance and reporting for missing elements in the import file. Report the issue and continue with the next element instead of aborting the process.

6. Performance improvements related to categories and attributes import.

Download this release

Release Info

Developer Vince Clark
Extension Gec_Customimport
Version 2.0.0.3
Comparing to
See all releases


Code changes from version 2.0.0.2 to 2.0.0.3

app/design/adminhtml/default/default/template/customimport/customimport.phtml ADDED
@@ -0,0 +1,166 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <style>
2
+ .fileUpload input.upload{position: absolute;top: 0;right: 0;margin: 0;padding: 0;font-size: 20px;cursor: pointer;opacity: 0;filter: alpha(opacity=0);}
3
+ .import_div{font-size:16px;}
4
+ .btn{background-image: none;border: 1px solid transparent;border-radius: 4px;cursor: pointer;display: inline-block;font-size: 14px;font-weight: normal;line-height: 1.42857;margin-bottom: 0;padding: 6px 12px;text-align: center;vertical-align: middle;white-space: nowrap;}
5
+ .btn-info{background-image: linear-gradient(to bottom, #5bc0de 0px, #2aabd2 100%);
6
+ background-repeat: repeat-x;border-color: #28a4c9;}
7
+ .btn-primary{background-color: #535353;border-color: #535353;color: #fff;text-shadow: 0 -1px 0 rgba(0, 0, 0, 0.25);}
8
+ .btn-primary:hover{background-color: #0099e6;border-color: #0099e6;color: #fff;}
9
+ </style>
10
+ <form action="<?php echo $this->getUrl('*/*/'); ?>" method="post" enctype="multipart/form-data"><br>
11
+ <?php echo $this->getBlockHtml('formkey')?>
12
+ <div class="import_div" style="font-size:16px;">
13
+ <?php echo $this->__('Select File to import') ?>: <br/><br/>
14
+ </div>
15
+ <input class="btn btn-info" type="file" name="uploadFile"> <br/><br/>
16
+ <input class="fileUpload btn btn-primary" name="upload_xml" type="submit" value="Upload File">
17
+ <br /><br />
18
+ <i>Allowed file name characters - [a-z,A-Z,0-9,_,-]. <br />(If any other character is part of the file name, then the import process shall not complete successfully.)</i>
19
+ </form>
20
+ <?php
21
+ ob_start();
22
+ set_time_limit(0);
23
+ $dir_root = Mage::getBaseDir() . DS;
24
+ $xmlPath = $dir_root . 'xmlfiles' . DS;
25
+ $logPath = Mage::getBaseDir('log') . '/customimport.log';
26
+
27
+ if ($data = $this->getRequest()->getPost()) {
28
+ $customHelper = Mage::helper('customimport');
29
+ if (isset($_FILES['uploadFile']['name']) && $_FILES['uploadFile']['name'] != '') {
30
+ $filename = $_FILES["uploadFile"]['name'];
31
+ try {
32
+ $uploader = new Varien_File_Uploader('uploadFile');
33
+ $uploader->setAllowedExtensions(array('xml')); // Set allowed file extesion.
34
+ $uploader->setAllowRenameFiles(false);
35
+ $uploader->setFilesDispersion(false); // (file will go in something like /media/f/i/file.jpg)
36
+ $uploader->save($xmlPath, $filename);
37
+ }
38
+ catch (Exception $e) {
39
+ $customHelper->reportError($e->getMessage());
40
+ $customHelper->sendLogEmail($logPath);
41
+ }
42
+
43
+ $pathAndName = $xmlPath . $filename;
44
+ $today_date = date("Y-m-d_H-i-s");
45
+ $current_file_path = $pathAndName;
46
+ $file = basename($filename, ".xml");
47
+ $new_error_file_path = $xmlPath . $file . '_' . $today_date . '_error.xml';
48
+ $new_completed_file_path = $xmlPath . $file . '_' . $today_date . '_completed.xml';
49
+ $t0 = microtime(true);
50
+ unlink($logPath);
51
+ $this->parseXml($pathAndName);
52
+ $flag = true;
53
+ try {
54
+ ################# Code start for import categories #################
55
+ $categories = $this->showCategory();
56
+ $msgcollection = "";
57
+ if ($categories) {
58
+ $this->importAllCategory($categories);
59
+ $customHelper->reportSuccess($this->__('Categories was successfully imported'));
60
+ } else {
61
+ $customHelper->reportInfo($this->__("There was no category found."));
62
+ }
63
+
64
+ $categoryRelationStatus = $this->parseAndUpdateCategoryRelation();
65
+ if ($categoryRelationStatus == 1) {
66
+ $customHelper->reportSuccess($this->__("Categories relations was successfully imported"));
67
+ } else if ($categoryRelationStatus == 0) {
68
+ $customHelper->reportInfo($this->__("There was no category relation found."));
69
+ } else {
70
+ $customHelper->reportInfo($this->__("Categories relations was successfully imported with some issues."));
71
+ }
72
+ ################# Code End for import categories #################
73
+
74
+ ################# Code Start for import attributes #################
75
+ $parsedAttribute = $this->parseAttribute();
76
+ if ($parsedAttribute) {
77
+ $this->importAttribute($parsedAttribute);
78
+ $customHelper->reportSuccess($this->__("Attribute was successfully imported"));
79
+ } else {
80
+ $customHelper->reportInfo($this->__("There was no attribute found."));
81
+ }
82
+
83
+ $parsedAttributeSet = $this->parseAttributeSet();
84
+ if ($parsedAttributeSet) {
85
+ $this->importAttributeSet($parsedAttributeSet);
86
+ $customHelper->reportSuccess($this->__("Attribute Set was successfully imported"));
87
+ } else {
88
+ $customHelper->reportInfo($this->__("There was no attribute set found."));
89
+ }
90
+
91
+ $parseAttributegrp = $this->parseAttributegrp();
92
+ if ($parseAttributegrp) {
93
+ $this->importAttributeGrp($parseAttributegrp);
94
+ $customHelper->reportSuccess($this->__("Attribute Group was successfully imported"));
95
+ } else {
96
+ $customHelper->reportInfo($this->__("There was no attribute group found."));
97
+ }
98
+ ################# Code End for import attributes #################
99
+
100
+ ################# Code Start for import products #################
101
+ $products = $this->showProducts();
102
+ if ($products) {
103
+ $this->importAllProducts($products, $current_file_path, $new_error_file_path);
104
+ $customHelper->reportSuccess($this->__("Products was successfully imported"));
105
+ } else {
106
+ $customHelper->reportInfo($this->__("There was no products found."));
107
+ }
108
+ ################# Code End for import products #################
109
+
110
+ ################# Code Start for category product association #################
111
+ $associatedProductsCategory = $this->associatedProductsCategory();
112
+ if ($associatedProductsCategory) {
113
+ $this->associateProducts($associatedProductsCategory);
114
+ $customHelper->reportSuccess($this->__("Category-Product Association was successfully imported"));
115
+ } else {
116
+ $customHelper->reportInfo($this->__("There was no category-product association found."));
117
+ }
118
+ ################# Code End for category product association #################
119
+
120
+ ################# Code Start for product association #################
121
+ $associatedProductsProducts = $this->associatedProductsProducts();
122
+ if ($associatedProductsProducts) {
123
+ $this->associatePdtPdt($associatedProductsProducts);
124
+ $customHelper->reportSuccess($this->__("Product-Product Association was successfully imported"));
125
+ } else {
126
+ if (($products->type == "configurable") || ($products->type == "bundle")) {
127
+ $customHelper->reportInfo($this->__("There was no product-product association found."));
128
+ }
129
+ }
130
+ ################# Code End for product association #################
131
+
132
+ }
133
+ catch (Exception $e) {
134
+ $flag = false;
135
+ $customHelper->reportError($e->getMessage());
136
+ $customHelper->sendLogEmail($logPath);
137
+ }
138
+
139
+ if ($flag === false) {
140
+ $is_exist = file_exists($current_file_path);
141
+ if ($is_exist == '1') {
142
+ rename($current_file_path, $new_error_file_path);
143
+ }
144
+ $customHelper->reportError($this->__('There was an error during xml import'));
145
+ } else {
146
+ $is_exist = file_exists($current_file_path);
147
+ if ($is_exist == '1') {
148
+ rename($current_file_path, $new_completed_file_path);
149
+ }
150
+ $customHelper->reportSuccess($this->__('Import process was completed successfully'));
151
+ }
152
+ $t1 = microtime(true);
153
+ $time = $t1 - $t0;
154
+ $customHelper->reportInfo($this->__('It took') . ' ' . $time . ' ' . $this->__('sec'));
155
+ $customHelper->sendLogEmail($logPath);
156
+
157
+ // CODE FOR INDEXING
158
+ $indexingProcesses = Mage::getSingleton('index/indexer')->getProcessesCollection();
159
+ foreach ($indexingProcesses as $process) {
160
+ $process->reindexEverything();
161
+ }
162
+ ob_end_flush();
163
+
164
+ } //uploadFile if condition end
165
+ } //post if condition end
166
+ ?>
package.xml CHANGED
@@ -1,7 +1,7 @@
1
  <?xml version="1.0"?>
2
  <package>
3
  <name>Gec_Customimport</name>
4
- <version>2.0.0.2</version>
5
  <stability>stable</stability>
6
  <license uri="http://www.gnu.org/licenses/agpl-3.0.txt">GNU Affero General Public License</license>
7
  <channel>community</channel>
@@ -54,8 +54,8 @@ New Features &amp; Improvements:&#xD;
54
  </notes>
55
  <authors><author><name>Vince Clark</name><user>vclark</user><email>vclark@globalera.com</email></author><author><name>Shrenik Bhura</name><user>shrenikbhura</user><email>shrenik.bhura@intelliant.net</email></author></authors>
56
  <date>2015-12-04</date>
57
- <time>07:51:37</time>
58
- <contents><target name="magelocal"><dir name="Gec"><dir name="Customimport"><dir name="Block"><dir name="Adminhtml"><file name="Catalogimport.php" hash="ee6d4d26cb3e2761c73384b5e64c2076"/><file name="Customimport.php" hash="9ffc09825a7574cd2de488cafb64e0dc"/></dir><dir name="Catalog"><dir name="Product"><dir name="Attribute"><dir name="Edit"><dir name="Tab"><file name="Options.php" hash="48eb00080ff3d4a2dabf9f6ed3c4f0de"/></dir></dir></dir></dir></dir></dir><dir name="Helper"><dir name="Catalog"><file name="Image.php" hash="c259ada8399c0a869a051d1b7c547c10"/></dir><file name="Data.php" hash="8490506d8a9b9938cacfaad66362ab89"/></dir><dir name="Model"><file name="Attrgroup.php" hash="86a327bf1a25b7eba1ad80562f2c501f"/><file name="Attrsetmapping.php" hash="62331110f2ca033c9f5ce2153156e6ba"/><dir name="Catalog"><dir name="Resource"><dir name="Eav"><dir name="Mysql4"><file name="Attribute.php" hash="4d76fa412eb1ab2ebf985ffc1c47aba3"/></dir></dir></dir></dir><file name="Catalogentity.php" hash="2d13b0be393feb623bda33ecc2d41e8e"/><file name="Customimport.php" hash="a1220c38c4dba8837ee81cc050d7bb36"/><file name="Eavattributegroup.php" hash="9bba68ded711a3310787a7578a613d29"/><file name="Eavattributeoption.php" hash="bb6b70ae5077607ce8a2d3494696eb0f"/><file name="Eaventityattribute.php" hash="af01fe556787a14cfa4528bbc77c2cf8"/><file name="Externalcategorymappinginfo.php" hash="6463a500908e4f4fc56640afe950bd72"/><dir name="Mysql4"><dir name="Attrgroup"><file name="Collection.php" hash="cf2aeb119b1a00bda6fbb9ec4400e22e"/></dir><file name="Attrgroup.php" hash="e6eef5397a72447494313f5aa08b6396"/><dir name="Attrsetmapping"><file name="Collection.php" hash="82fb958991fd44cd09fd3f1bc8542704"/></dir><file name="Attrsetmapping.php" hash="b249625624c986eaed9fa16bfe700d03"/><dir name="Catalogentity"><file name="Collection.php" hash="1bd3fb627e7d204528fe9f147aff289e"/></dir><file name="Catalogentity.php" hash="d22449c6577a4601cd72c2c9e7eb8a1a"/><dir name="Customimport"><file name="Collection.php" hash="1e898a23cac9c3dce0bae079576c3647"/></dir><file name="Customimport.php" hash="8e1b5d21a29149d7b705d55252087d0d"/><dir name="Eavattributegroup"><file name="Collection.php" hash="d4f41930aabd0f9bffe144a8300aac97"/></dir><file name="Eavattributegroup.php" hash="77039ce31e5368e8b18a951cb1fac8ce"/><dir name="Eavattributeoption"><file name="Collection.php" hash="faa0ba2294bca2e74063ac869215bcbe"/></dir><file name="Eavattributeoption.php" hash="c8d9f44e390d64bd1af0e8c4dc86e8f6"/><dir name="Eaventityattribute"><file name="Collection.php" hash="8dd0dd41e5c4df79963dcba325e2e7f3"/></dir><file name="Eaventityattribute.php" hash="ee92de3640f29e66622af0b58eec56a7"/><dir name="Externalcategorymappinginfo"><file name="Collection.php" hash="503471182e7f4babf340e0bb08bb6311"/></dir><file name="Externalcategorymappinginfo.php" hash="4548556d997eb8f08ad9a141c9dc11dc"/><file name="Setup.php" hash="1e5b593b53599d605774d31d3fa63bb2"/></dir><file name="Status.php" hash="b241452a94455ceb89afc7ed17252b84"/></dir><dir name="controllers"><dir name="Adminhtml"><file name="IndexController.php" hash="0196d4ba3d36abba756e60f9d75cb5d1"/></dir></dir><dir name="etc"><file name="adminhtml.xml" hash="5b20522ba1ad223a13a6b193b0312ebb"/><file name="config.xml" hash="0006aa368de798444a99be27293ce47f"/><file name="system.xml" hash="b87fa034807a671992b211d6cbfd1d7b"/></dir><dir name="sql"><dir name="customimport_setup"><file name="mysql4-install-0.1.0.php" hash="cc714904399b6ad061834b36857fdca9"/></dir></dir></dir></dir></target><target name="magedesign"><dir name="adminhtml"><dir name="default"><dir name="default"><dir name="layout"><file name="customimport.xml" hash="58e97b28b754651736288d8f6d0e9231"/></dir><dir name="template"><dir name="gec"><dir name="catalog"><dir name="product"><dir name="attribute"><file name="options.phtml" hash="10940f1e0d06ca177755254d39d499a4"/></dir></dir></dir></dir></dir></dir></dir></dir></target><target name="mageetc"><dir name="modules"><file name="Gec_Customimport.xml" hash="f2da24afaca09dc23fcf34d9ee3dd8c5"/></dir></target></contents>
59
  <compatible/>
60
  <dependencies><required><php><min>5.4.0</min><max>5.5.30</max></php><package><name>Mage_Core_Modules</name><channel>community</channel><min>1.7.0.0</min><max>1.9.2.2</max></package><package><name/><channel>connect.magentocommerce.com/core</channel><min/><max/></package><extension><name>Core</name><min>5.4.0</min><max>5.5.30</max></extension><extension><name>SimpleXML</name><min/><max/></extension><extension><name>pdo_mysql</name><min/><max/></extension><extension><name>mcrypt</name><min/><max/></extension><extension><name>hash</name><min/><max/></extension><extension><name>gd</name><min/><max/></extension><extension><name>dom</name><min/><max/></extension><extension><name>date</name><min/><max/></extension><extension><name>iconv</name><min/><max/></extension><extension><name>curl</name><min/><max/></extension></required></dependencies>
61
  </package>
1
  <?xml version="1.0"?>
2
  <package>
3
  <name>Gec_Customimport</name>
4
+ <version>2.0.0.3</version>
5
  <stability>stable</stability>
6
  <license uri="http://www.gnu.org/licenses/agpl-3.0.txt">GNU Affero General Public License</license>
7
  <channel>community</channel>
54
  </notes>
55
  <authors><author><name>Vince Clark</name><user>vclark</user><email>vclark@globalera.com</email></author><author><name>Shrenik Bhura</name><user>shrenikbhura</user><email>shrenik.bhura@intelliant.net</email></author></authors>
56
  <date>2015-12-04</date>
57
+ <time>10:13:47</time>
58
+ <contents><target name="magelocal"><dir name="Gec"><dir name="Customimport"><dir name="Block"><dir name="Adminhtml"><file name="Catalogimport.php" hash="ee6d4d26cb3e2761c73384b5e64c2076"/><file name="Customimport.php" hash="9ffc09825a7574cd2de488cafb64e0dc"/></dir><dir name="Catalog"><dir name="Product"><dir name="Attribute"><dir name="Edit"><dir name="Tab"><file name="Options.php" hash="48eb00080ff3d4a2dabf9f6ed3c4f0de"/></dir></dir></dir></dir></dir></dir><dir name="Helper"><dir name="Catalog"><file name="Image.php" hash="c259ada8399c0a869a051d1b7c547c10"/></dir><file name="Data.php" hash="8490506d8a9b9938cacfaad66362ab89"/></dir><dir name="Model"><file name="Attrgroup.php" hash="86a327bf1a25b7eba1ad80562f2c501f"/><file name="Attrsetmapping.php" hash="62331110f2ca033c9f5ce2153156e6ba"/><dir name="Catalog"><dir name="Resource"><dir name="Eav"><dir name="Mysql4"><file name="Attribute.php" hash="4d76fa412eb1ab2ebf985ffc1c47aba3"/></dir></dir></dir></dir><file name="Catalogentity.php" hash="2d13b0be393feb623bda33ecc2d41e8e"/><file name="Customimport.php" hash="a1220c38c4dba8837ee81cc050d7bb36"/><file name="Eavattributegroup.php" hash="9bba68ded711a3310787a7578a613d29"/><file name="Eavattributeoption.php" hash="bb6b70ae5077607ce8a2d3494696eb0f"/><file name="Eaventityattribute.php" hash="af01fe556787a14cfa4528bbc77c2cf8"/><file name="Externalcategorymappinginfo.php" hash="6463a500908e4f4fc56640afe950bd72"/><dir name="Mysql4"><dir name="Attrgroup"><file name="Collection.php" hash="cf2aeb119b1a00bda6fbb9ec4400e22e"/></dir><file name="Attrgroup.php" hash="e6eef5397a72447494313f5aa08b6396"/><dir name="Attrsetmapping"><file name="Collection.php" hash="82fb958991fd44cd09fd3f1bc8542704"/></dir><file name="Attrsetmapping.php" hash="b249625624c986eaed9fa16bfe700d03"/><dir name="Catalogentity"><file name="Collection.php" hash="1bd3fb627e7d204528fe9f147aff289e"/></dir><file name="Catalogentity.php" hash="d22449c6577a4601cd72c2c9e7eb8a1a"/><dir name="Customimport"><file name="Collection.php" hash="1e898a23cac9c3dce0bae079576c3647"/></dir><file name="Customimport.php" hash="8e1b5d21a29149d7b705d55252087d0d"/><dir name="Eavattributegroup"><file name="Collection.php" hash="d4f41930aabd0f9bffe144a8300aac97"/></dir><file name="Eavattributegroup.php" hash="77039ce31e5368e8b18a951cb1fac8ce"/><dir name="Eavattributeoption"><file name="Collection.php" hash="faa0ba2294bca2e74063ac869215bcbe"/></dir><file name="Eavattributeoption.php" hash="c8d9f44e390d64bd1af0e8c4dc86e8f6"/><dir name="Eaventityattribute"><file name="Collection.php" hash="8dd0dd41e5c4df79963dcba325e2e7f3"/></dir><file name="Eaventityattribute.php" hash="ee92de3640f29e66622af0b58eec56a7"/><dir name="Externalcategorymappinginfo"><file name="Collection.php" hash="503471182e7f4babf340e0bb08bb6311"/></dir><file name="Externalcategorymappinginfo.php" hash="4548556d997eb8f08ad9a141c9dc11dc"/><file name="Setup.php" hash="1e5b593b53599d605774d31d3fa63bb2"/></dir><file name="Status.php" hash="b241452a94455ceb89afc7ed17252b84"/></dir><dir name="controllers"><dir name="Adminhtml"><file name="IndexController.php" hash="0196d4ba3d36abba756e60f9d75cb5d1"/></dir></dir><dir name="etc"><file name="adminhtml.xml" hash="5b20522ba1ad223a13a6b193b0312ebb"/><file name="config.xml" hash="0006aa368de798444a99be27293ce47f"/><file name="system.xml" hash="b87fa034807a671992b211d6cbfd1d7b"/></dir><dir name="sql"><dir name="customimport_setup"><file name="mysql4-install-0.1.0.php" hash="cc714904399b6ad061834b36857fdca9"/></dir></dir></dir></dir></target><target name="magedesign"><dir name="adminhtml"><dir name="default"><dir name="default"><dir name="layout"><file name="customimport.xml" hash="58e97b28b754651736288d8f6d0e9231"/></dir><dir name="template"><dir name="gec"><dir name="catalog"><dir name="product"><dir name="attribute"><file name="options.phtml" hash="10940f1e0d06ca177755254d39d499a4"/></dir></dir></dir></dir><dir name="customimport"><file name="customimport.phtml" hash="1e68c8e3cb71abf09b16c474ffef1ae4"/></dir></dir></dir></dir></dir></target><target name="mageetc"><dir name="modules"><file name="Gec_Customimport.xml" hash="f2da24afaca09dc23fcf34d9ee3dd8c5"/></dir></target></contents>
59
  <compatible/>
60
  <dependencies><required><php><min>5.4.0</min><max>5.5.30</max></php><package><name>Mage_Core_Modules</name><channel>community</channel><min>1.7.0.0</min><max>1.9.2.2</max></package><package><name/><channel>connect.magentocommerce.com/core</channel><min/><max/></package><extension><name>Core</name><min>5.4.0</min><max>5.5.30</max></extension><extension><name>SimpleXML</name><min/><max/></extension><extension><name>pdo_mysql</name><min/><max/></extension><extension><name>mcrypt</name><min/><max/></extension><extension><name>hash</name><min/><max/></extension><extension><name>gd</name><min/><max/></extension><extension><name>dom</name><min/><max/></extension><extension><name>date</name><min/><max/></extension><extension><name>iconv</name><min/><max/></extension><extension><name>curl</name><min/><max/></extension></required></dependencies>
61
  </package>