AMartinez_CustomImportExport - Version 1.5.013

Version Notes

Magento 1.5 version.

Download this release

Release Info

Developer Antonio Martinez
Extension AMartinez_CustomImportExport
Version 1.5.013
Comparing to
See all releases


Code changes from version 1.5.011 to 1.5.013

amartinez_customimportexport.php ADDED
@@ -0,0 +1,16 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Magento
4
+ *
5
+ * @category AMartinez
6
+ * @package AMartinez_CustomImportExport
7
+ * @author Antonio Martinez
8
+ * @copyright Copyright (c) 2011 Antonio Martinez (toniyecla [at] gmail [dot] com)
9
+ * @license http://opensource.org/licenses/osl-3.0 Open Software License (OSL 3.0)
10
+ */
11
+
12
+ /**
13
+ * Require the AMartinez_CustomImportExport class
14
+ */
15
+ require_once 'app/code/community/AMartinez/CustomImportExport/shell/run.php';
16
+ ?>
app/code/community/AMartinez/CustomImportExport/Helper/Data.php CHANGED
@@ -5,7 +5,7 @@
5
  * @category AMartinez
6
  * @package AMartinez_CustomImportExport
7
  * @author Antonio Martinez
8
- * @copyright Copyright (c) 2011 Antonio Martínez (toniyecla [at] gmail [dot] com)
9
  * @license http://opensource.org/licenses/osl-3.0 Open Software License (OSL 3.0)
10
  */
11
 
@@ -14,5 +14,239 @@
14
  */
15
  class AMartinez_CustomImportExport_Helper_Data extends Mage_Core_Helper_Abstract
16
  {
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
17
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
18
  }
5
  * @category AMartinez
6
  * @package AMartinez_CustomImportExport
7
  * @author Antonio Martinez
8
+ * @copyright Copyright (c) 2011 Antonio Martinez (toniyecla [at] gmail [dot] com)
9
  * @license http://opensource.org/licenses/osl-3.0 Open Software License (OSL 3.0)
10
  */
11
 
14
  */
15
  class AMartinez_CustomImportExport_Helper_Data extends Mage_Core_Helper_Abstract
16
  {
17
+ /**
18
+ * Recalculate catalog price rules
19
+ */
20
+ public function applyRules()
21
+ {
22
+ echo "Recalculating catalog price rules...\n";
23
+
24
+ try
25
+ {
26
+ Mage::getModel('catalogrule/rule')->applyAll();
27
+ Mage::app()->removeCache('catalog_rules_dirty');
28
+ }
29
+ catch (Exception $e)
30
+ {
31
+ echo $e;
32
+ }
33
+ }
34
+
35
+ /**
36
+ * Flush catalog images cache
37
+ */
38
+ public function flushImages()
39
+ {
40
+ echo "Erasing catalog images cache...\n";
41
+
42
+ try
43
+ {
44
+ Mage::getModel('catalog/product_image')->clearCache();
45
+ }
46
+ catch (Exception $e)
47
+ {
48
+ echo $e;
49
+ }
50
+ }
51
+
52
+ /**
53
+ * Reindex data by all indexers
54
+ *
55
+ * @return array
56
+ */
57
+ public function reindexAll()
58
+ {
59
+ echo "Reindexing data...\n";
60
+
61
+ $processes = array();
62
+
63
+ $collection = Mage::getSingleton('index/indexer')->getProcessesCollection();
64
+ foreach ($collection as $process)
65
+ {
66
+ $processes[] = $process;
67
+ }
68
 
69
+ foreach ($processes as $process) {
70
+ /* @var $process Mage_Index_Model_Process */
71
+ try
72
+ {
73
+ echo "\t" . $process->getIndexer()->getName() . "... ";
74
+ $process->reindexEverything();
75
+ echo "index was rebuilt successfully\n";
76
+ }
77
+ catch (Mage_Core_Exception $e)
78
+ {
79
+ echo $e->getMessage() . "\n";
80
+ }
81
+ catch (Exception $e)
82
+ {
83
+ echo "index process unknown error:\n";
84
+ echo "\t" . $e . "\n";
85
+ }
86
+ }
87
+
88
+ return $processes;
89
+ }
90
+
91
+ /**
92
+ * Clean cache
93
+ */
94
+ public function cleanCache()
95
+ {
96
+ echo "Cleaning cache...\n";
97
+
98
+ try
99
+ {
100
+ Mage::app()->cleanCache();
101
+ }
102
+ catch (Exception $e)
103
+ {
104
+ echo $e;
105
+ }
106
+ }
107
+
108
+ /**
109
+ * Delete all products and non-root categories
110
+ *
111
+ * Alternative method: run.php -e -i -b delete
112
+ */
113
+ public function deleteAllProducts()
114
+ {
115
+ // products
116
+ $connection = Mage::getSingleton('core/resource')->getConnection('read');
117
+ $select = $connection->select()
118
+ ->from(Mage::getResourceModel('catalog/product')->getTable('catalog/product'), array('sku'));
119
+ $result = $connection->query($select);
120
+
121
+ $filename = Mage::getConfig()->getOptions()->getTmpDir() . DS . 'deleteallproducts.csv';
122
+ $f = fopen($filename, 'w');
123
+ fwrite($f, "sku\n");
124
+ while ($row = $result->fetch())
125
+ {
126
+ fwrite($f, $row['sku'] . "\n");
127
+ }
128
+ fclose($f);
129
+
130
+ $import = Mage::getModel('customimportexport/import');
131
+ $import->setEntity('catalog_product');
132
+ $import->setBehavior('delete');
133
+ $validationResult = $import->validateSource($filename);
134
+ $processedRowsCount = $import->getProcessedRowsCount();
135
+ if ($processedRowsCount > 0)
136
+ {
137
+ $import->importSource();
138
+ }
139
+
140
+ unlink($filename);
141
+
142
+ // categories
143
+ $tree = Mage::getResourceSingleton('catalog/category_tree')->load();
144
+ $ids = $tree->getCollection()->getAllIds();
145
+ if ($ids)
146
+ {
147
+ foreach ($ids as $id)
148
+ {
149
+ $cat = Mage::getModel('catalog/category');
150
+ $cat->load($id);
151
+ // skip root categories
152
+ if ($cat->getParentId() > 1)
153
+ {
154
+ $cat->delete();
155
+ }
156
+ }
157
+ }
158
+
159
+ return $processedRowsCount;
160
+ }
161
+
162
+ /**
163
+ * Delete all customers
164
+ *
165
+ * Alternative method: run.php -ce -ci -b delete
166
+ */
167
+ public function deleteAllCustomers()
168
+ {
169
+ $websiteIdToCode = array();
170
+ foreach (Mage::app()->getWebsites(true) as $website) {
171
+ $websiteIdToCode[$website->getId()] = $website->getCode();
172
+ }
173
+
174
+ $connection = Mage::getSingleton('core/resource')->getConnection('read');
175
+ $select = $connection->select()
176
+ ->from(Mage::getResourceModel('customer/customer_collection')->getTable('customer_entity'), array('email','website_id'));
177
+ $result = $connection->query($select);
178
+
179
+ $filename = Mage::getConfig()->getOptions()->getTmpDir() . DS . 'deleteallcustomers.csv';
180
+ $f = fopen($filename, 'w');
181
+ fwrite($f, "email,_website\n");
182
+ while ($row = $result->fetch())
183
+ {
184
+ fwrite($f, $row['email'] . "," . $websiteIdToCode[$row['website_id']] . "\n");
185
+ }
186
+ fclose($f);
187
+
188
+ $import = Mage::getModel('customimportexport/import');
189
+ $import->setEntity('customer');
190
+ $import->setBehavior('delete');
191
+ $validationResult = $import->validateSource($filename);
192
+ $processedRowsCount = $import->getProcessedRowsCount();
193
+ if ($processedRowsCount > 0)
194
+ {
195
+ $import->importSource();
196
+ }
197
+
198
+ unlink($filename);
199
+
200
+ return $processedRowsCount;
201
+ }
202
+
203
+ /**
204
+ * Split file into pieces
205
+ */
206
+ public function splitFile($filename, $linecount)
207
+ {
208
+ $extension = pathinfo($filename, PATHINFO_EXTENSION);
209
+ $count = 0;
210
+ $i = 0;
211
+ $j = 0;
212
+ $files = array();
213
+ $h = fopen($filename, 'r');
214
+ $header = fgets($h);
215
+ while($line = fgets($h))
216
+ {
217
+ // first iteration / no "attr-only" line / line count has been reached
218
+ if ($i == 0 || (substr($line, 0 ,1) != ',' && substr($line, 0 ,2) != '""' && substr($line, 0 ,2) != "''" && $i >= $linecount && !($linecount === true)))
219
+ {
220
+ if (defined('t'))
221
+ {
222
+ fclose($t);
223
+ }
224
+ $files[] = Mage::getConfig()->getOptions()->getTmpDir() . DS . pathinfo($filename, PATHINFO_FILENAME) . '.tmp.' . $j . '.' . $extension;
225
+ $t = fopen($files[$j++], 'w');
226
+ fwrite($t, $header);
227
+ $i = 0;
228
+ }
229
+ fwrite($t, $line);
230
+ $count++;
231
+ $i++;
232
+ }
233
+ fclose($h);
234
+ if (defined('t'))
235
+ {
236
+ fclose($t);
237
+ }
238
+
239
+ return $files;
240
+ }
241
+
242
+ /**
243
+ * Unlink temp files
244
+ */
245
+ public function unlinkFiles($files)
246
+ {
247
+ foreach ($files as $file)
248
+ {
249
+ unlink($file);
250
+ }
251
+ }
252
  }
app/code/community/AMartinez/CustomImportExport/Model/Backup.php CHANGED
@@ -5,7 +5,7 @@
5
  * @category AMartinez
6
  * @package AMartinez_CustomImportExport
7
  * @author Antonio Martinez
8
- * @copyright Copyright (c) 2011 Antonio Martínez (toniyecla [at] gmail [dot] com)
9
  * @license http://opensource.org/licenses/osl-3.0 Open Software License (OSL 3.0)
10
  */
11
 
5
  * @category AMartinez
6
  * @package AMartinez_CustomImportExport
7
  * @author Antonio Martinez
8
+ * @copyright Copyright (c) 2011 Antonio Martinez (toniyecla [at] gmail [dot] com)
9
  * @license http://opensource.org/licenses/osl-3.0 Open Software License (OSL 3.0)
10
  */
11
 
app/code/community/AMartinez/CustomImportExport/Model/Export.php CHANGED
@@ -5,7 +5,7 @@
5
  * @category AMartinez
6
  * @package AMartinez_CustomImportExport
7
  * @author Antonio Martinez
8
- * @copyright Copyright (c) 2011 Antonio Martínez (toniyecla [at] gmail [dot] com)
9
  * @license http://opensource.org/licenses/osl-3.0 Open Software License (OSL 3.0)
10
  */
11
 
5
  * @category AMartinez
6
  * @package AMartinez_CustomImportExport
7
  * @author Antonio Martinez
8
+ * @copyright Copyright (c) 2011 Antonio Martinez (toniyecla [at] gmail [dot] com)
9
  * @license http://opensource.org/licenses/osl-3.0 Open Software License (OSL 3.0)
10
  */
11
 
app/code/community/AMartinez/CustomImportExport/Model/Import.php CHANGED
@@ -5,7 +5,7 @@
5
  * @category AMartinez
6
  * @package AMartinez_CustomImportExport
7
  * @author Antonio Martinez
8
- * @copyright Copyright (c) 2011 Antonio Martínez (toniyecla [at] gmail [dot] com)
9
  * @license http://opensource.org/licenses/osl-3.0 Open Software License (OSL 3.0)
10
  */
11
 
@@ -39,60 +39,4 @@ class AMartinez_CustomImportExport_Model_Import extends Mage_ImportExport_Model_
39
 
40
  return $result;
41
  }
42
-
43
- /**
44
- * Reindex data by all indexers
45
- *
46
- * @return array
47
- */
48
- public function reindexAll()
49
- {
50
- $processes = array();
51
-
52
- $collection = Mage::getSingleton('index/indexer')->getProcessesCollection();
53
- foreach ($collection as $process) {
54
- $processes[] = $process;
55
- }
56
-
57
- foreach ($processes as $process) {
58
- /* @var $process Mage_Index_Model_Process */
59
- try {
60
- echo "\t" . $process->getIndexer()->getName() . "... ";
61
- $process->reindexEverything();
62
- echo "index was rebuilt successfully\n";
63
- } catch (Mage_Core_Exception $e) {
64
- echo $e->getMessage() . "\n";
65
- } catch (Exception $e) {
66
- echo "index process unknown error:\n";
67
- echo "\t" . $e . "\n";
68
- }
69
- }
70
-
71
- return $processes;
72
- }
73
-
74
- /**
75
- * Clean cache
76
- */
77
- public function cleanCache()
78
- {
79
- Mage::app()->cleanCache();
80
- }
81
-
82
- /**
83
- * Flush catalog images cache
84
- */
85
- public function flushImages()
86
- {
87
- Mage::getModel('catalog/product_image')->clearCache();
88
- }
89
-
90
- /**
91
- * Recalculate catalog price rules
92
- */
93
- public function applyRules()
94
- {
95
- Mage::getModel('catalogrule/rule')->applyAll();
96
- Mage::app()->removeCache('catalog_rules_dirty');
97
- }
98
  }
5
  * @category AMartinez
6
  * @package AMartinez_CustomImportExport
7
  * @author Antonio Martinez
8
+ * @copyright Copyright (c) 2011 Antonio Martinez (toniyecla [at] gmail [dot] com)
9
  * @license http://opensource.org/licenses/osl-3.0 Open Software License (OSL 3.0)
10
  */
11
 
39
 
40
  return $result;
41
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
42
  }
app/code/community/AMartinez/CustomImportExport/Model/Import/Adapter.php CHANGED
@@ -5,7 +5,7 @@
5
  * @category AMartinez
6
  * @package AMartinez_CustomImportExport
7
  * @author Antonio Martinez
8
- * @copyright Copyright (c) 2011 Antonio Martínez (toniyecla [at] gmail [dot] com)
9
  * @license http://opensource.org/licenses/osl-3.0 Open Software License (OSL 3.0)
10
  */
11
 
5
  * @category AMartinez
6
  * @package AMartinez_CustomImportExport
7
  * @author Antonio Martinez
8
+ * @copyright Copyright (c) 2011 Antonio Martinez (toniyecla [at] gmail [dot] com)
9
  * @license http://opensource.org/licenses/osl-3.0 Open Software License (OSL 3.0)
10
  */
11
 
app/code/community/AMartinez/CustomImportExport/Model/Import/Adapter/Csv1.php CHANGED
@@ -5,7 +5,7 @@
5
  * @category AMartinez
6
  * @package AMartinez_CustomImportExport
7
  * @author Antonio Martinez
8
- * @copyright Copyright (c) 2011 Antonio Martínez (toniyecla [at] gmail [dot] com)
9
  * @license http://opensource.org/licenses/osl-3.0 Open Software License (OSL 3.0)
10
  */
11
 
5
  * @category AMartinez
6
  * @package AMartinez_CustomImportExport
7
  * @author Antonio Martinez
8
+ * @copyright Copyright (c) 2011 Antonio Martinez (toniyecla [at] gmail [dot] com)
9
  * @license http://opensource.org/licenses/osl-3.0 Open Software License (OSL 3.0)
10
  */
11
 
app/code/community/AMartinez/CustomImportExport/Model/Import/Entity/Customer.php CHANGED
@@ -5,7 +5,7 @@
5
  * @category AMartinez
6
  * @package AMartinez_CustomImportExport
7
  * @author Antonio Martinez
8
- * @copyright Copyright (c) 2011 Antonio Martínez (toniyecla [at] gmail [dot] com)
9
  * @license http://opensource.org/licenses/osl-3.0 Open Software License (OSL 3.0)
10
  */
11
 
5
  * @category AMartinez
6
  * @package AMartinez_CustomImportExport
7
  * @author Antonio Martinez
8
+ * @copyright Copyright (c) 2011 Antonio Martinez (toniyecla [at] gmail [dot] com)
9
  * @license http://opensource.org/licenses/osl-3.0 Open Software License (OSL 3.0)
10
  */
11
 
app/code/community/AMartinez/CustomImportExport/Model/Import/Entity/Customer/Address.php CHANGED
@@ -5,7 +5,7 @@
5
  * @category AMartinez
6
  * @package AMartinez_CustomImportExport
7
  * @author Antonio Martinez
8
- * @copyright Copyright (c) 2011 Antonio Martínez (toniyecla [at] gmail [dot] com)
9
  * @license http://opensource.org/licenses/osl-3.0 Open Software License (OSL 3.0)
10
  */
11
 
5
  * @category AMartinez
6
  * @package AMartinez_CustomImportExport
7
  * @author Antonio Martinez
8
+ * @copyright Copyright (c) 2011 Antonio Martinez (toniyecla [at] gmail [dot] com)
9
  * @license http://opensource.org/licenses/osl-3.0 Open Software License (OSL 3.0)
10
  */
11
 
app/code/community/AMartinez/CustomImportExport/Model/Import/Entity/Product.php CHANGED
@@ -5,7 +5,7 @@
5
  * @category AMartinez
6
  * @package AMartinez_CustomImportExport
7
  * @author Antonio Martinez
8
- * @copyright Copyright (c) 2011 Antonio Martínez (toniyecla [at] gmail [dot] com)
9
  * @license http://opensource.org/licenses/osl-3.0 Open Software License (OSL 3.0)
10
  */
11
 
@@ -41,20 +41,23 @@ class AMartinez_CustomImportExport_Model_Import_Entity_Product extends Mage_Impo
41
  $valid = (float)$val == $val;
42
  break;
43
  case 'select':
44
- $valid = isset($attrParams['options'][strtolower($rowData[$attrCode])]);
45
- if (!$valid) {
46
- if (in_array($attrCode . ":" . $rowData[$attrCode], $this->_newAttrParams))
47
- {
48
- return true;
49
- }
50
- if ($this->parseAttributeOption($attrCode, $rowData[$attrCode]))
51
- {
52
- $this->_newAttrParams[] = $attrCode . ":" . $rowData[$attrCode];
53
- echo ":::: " . Mage::helper('importexport')->__("New attribute option added: ") . $attrCode . " - " . $rowData[$attrCode] . " (first ocurrence in line " . ($rowNum+1) . ") ::::\n";
54
- $this->addRowError(Mage::helper('importexport')->__("Attribute option added for '%s'"), $rowNum, $attrCode);
55
- }
56
- return true; // no false
 
 
57
  }
 
58
  break;
59
  case 'int':
60
  $val = trim($rowData[$attrCode]);
@@ -71,7 +74,7 @@ class AMartinez_CustomImportExport_Model_Import_Entity_Product extends Mage_Impo
71
  $val = Mage::helper('core/string')->cleanString($rowData[$attrCode]);
72
  //// convert to utf-8
73
  //// $val = iconv('ISO-8859-1', 'UTF-8' . '//IGNORE//TRANSLIT', $val);
74
- $valid = Mage::helper('core/string')->strlen($val) < self::DB_MAX_VARCHAR_LENGTH;
75
  break;
76
  default:
77
  $valid = true;
@@ -85,7 +88,7 @@ class AMartinez_CustomImportExport_Model_Import_Entity_Product extends Mage_Impo
85
 
86
  /* Mage_ImportExport_Model_Import_Entity_Product */
87
 
88
- protected $_entity_type_id;
89
  protected $eav_entity_setup;
90
 
91
  /**
@@ -95,15 +98,15 @@ class AMartinez_CustomImportExport_Model_Import_Entity_Product extends Mage_Impo
95
  */
96
  function parseAttributeOption($code, $value)
97
  {
98
- if (!$this->_entity_type_id) {
99
- $entity_type_id = Mage::getModel('eav/entity')->setType('catalog_product')->getTypeId();
100
  }
101
 
102
  if (!$this->eav_entity_setup) {
103
- $eav_entity_setup = new Mage_Eav_Model_Entity_Setup('core_setup');
104
  }
105
 
106
- if ( !$id = $eav_entity_setup->getAttribute($entity_type_id, $code, 'attribute_id')) {
107
  return false;
108
  }
109
 
@@ -112,7 +115,7 @@ class AMartinez_CustomImportExport_Model_Import_Entity_Product extends Mage_Impo
112
 
113
  $new_option['attribute_id'] = $id;
114
  $new_option['value']['_custom_'.$value][0] = $value;
115
- $eav_entity_setup->addAttributeOption($new_option);
116
 
117
  return true;
118
  }
5
  * @category AMartinez
6
  * @package AMartinez_CustomImportExport
7
  * @author Antonio Martinez
8
+ * @copyright Copyright (c) 2011 Antonio Martinez (toniyecla [at] gmail [dot] com)
9
  * @license http://opensource.org/licenses/osl-3.0 Open Software License (OSL 3.0)
10
  */
11
 
41
  $valid = (float)$val == $val;
42
  break;
43
  case 'select':
44
+ foreach (explode(",", $rowData[$attrCode]) as $code)
45
+ {
46
+ $valid = isset($attrParams['options'][strtolower($code)]);
47
+ if (!$valid) {
48
+ if (!in_array($attrCode . ":" . $code, $this->_newAttrParams))
49
+ {
50
+ if ($this->parseAttributeOption($attrCode, $code))
51
+ {
52
+ $this->_newAttrParams[] = $attrCode . ":" . $code;
53
+ echo ":::: " . Mage::helper('importexport')->__("New attribute option added: ") . $attrCode . " - " . $code . " (first ocurrence in line " . ($rowNum+1) . ") ::::\n";
54
+ $this->addRowError(Mage::helper('importexport')->__("Attribute option added for '%s'"), $rowNum, $attrCode);
55
+ }
56
+ }
57
+
58
+ }
59
  }
60
+ return true;
61
  break;
62
  case 'int':
63
  $val = trim($rowData[$attrCode]);
74
  $val = Mage::helper('core/string')->cleanString($rowData[$attrCode]);
75
  //// convert to utf-8
76
  //// $val = iconv('ISO-8859-1', 'UTF-8' . '//IGNORE//TRANSLIT', $val);
77
+ $valid = Mage::helper('core/string')->strlen($val) < self::DB_MAX_TEXT_LENGTH;
78
  break;
79
  default:
80
  $valid = true;
88
 
89
  /* Mage_ImportExport_Model_Import_Entity_Product */
90
 
91
+ protected $entity_type_id;
92
  protected $eav_entity_setup;
93
 
94
  /**
98
  */
99
  function parseAttributeOption($code, $value)
100
  {
101
+ if (!$this->entity_type_id) {
102
+ $this->entity_type_id = Mage::getModel('eav/entity')->setType('catalog_product')->getTypeId();
103
  }
104
 
105
  if (!$this->eav_entity_setup) {
106
+ $this->eav_entity_setup = new Mage_Eav_Model_Entity_Setup('core_setup');
107
  }
108
 
109
+ if ( !$id = $this->eav_entity_setup->getAttribute($this->entity_type_id, $code, 'attribute_id')) {
110
  return false;
111
  }
112
 
115
 
116
  $new_option['attribute_id'] = $id;
117
  $new_option['value']['_custom_'.$value][0] = $value;
118
+ $this->eav_entity_setup->addAttributeOption($new_option);
119
 
120
  return true;
121
  }
app/code/community/AMartinez/CustomImportExport/Model/Import/Entity/Product/Type/Configurable.php CHANGED
@@ -5,7 +5,7 @@
5
  * @category AMartinez
6
  * @package AMartinez_CustomImportExport
7
  * @author Antonio Martinez
8
- * @copyright Copyright (c) 2011 Antonio Martínez (toniyecla [at] gmail [dot] com)
9
  * @license http://opensource.org/licenses/osl-3.0 Open Software License (OSL 3.0)
10
  */
11
 
@@ -16,24 +16,84 @@ class AMartinez_CustomImportExport_Model_Import_Entity_Product_Type_Configurable
16
  extends Mage_ImportExport_Model_Import_Entity_Product_Type_Configurable
17
  {
18
  /**
19
- * Validate row attributes. Pass VALID row data ONLY as argument.
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
20
  *
21
  * @param array $rowData
22
- * @param int $rowNum
23
- * @param boolean $checkRequiredAttributes OPTIONAL Flag which can disable validation required values.
24
- * @return boolean
25
  */
26
- public function isRowValid(array $rowData, $rowNum, $checkRequiredAttributes = true)
27
  {
28
- // create sub-row's new attribute options
29
- if (Mage_ImportExport_Model_Import_Entity_Product::SCOPE_NULL == $this->_entityModel->getRowScope($rowData)) {
30
- foreach ($this->_getProductAttributes($rowData) as $attrCode => $attrParams) {
 
31
  if (isset($rowData[$attrCode]) && strlen($rowData[$attrCode])) {
32
- $this->_entityModel->isAttributeValid($attrCode, $attrParams, $rowData, $rowNum);
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
33
  }
34
  }
35
- }
36
-
37
- return Mage_ImportExport_Model_Import_Entity_Product_Type_Abstract::isRowValid($rowData, $rowNum, $checkRequiredAttributes);
38
  }
39
  }
5
  * @category AMartinez
6
  * @package AMartinez_CustomImportExport
7
  * @author Antonio Martinez
8
+ * @copyright Copyright (c) 2011 Antonio Martinez (toniyecla [at] gmail [dot] com)
9
  * @license http://opensource.org/licenses/osl-3.0 Open Software License (OSL 3.0)
10
  */
11
 
16
  extends Mage_ImportExport_Model_Import_Entity_Product_Type_Configurable
17
  {
18
  /**
19
+ * Initialize attributes parameters for all attributes' sets.
20
+ *
21
+ * @return Mage_ImportExport_Model_Import_Entity_Product_Type_Abstract
22
+ */
23
+ protected function _initAttributes()
24
+ {
25
+ // temporary storage for attributes' parameters to avoid double querying inside the loop
26
+ $attributesCache = array();
27
+
28
+ foreach (Mage::getResourceModel('eav/entity_attribute_set_collection')
29
+ ->setEntityTypeFilter($this->_entityModel->getEntityTypeId()) as $attributeSet) {
30
+ foreach (Mage::getResourceModel('catalog/product_attribute_collection')
31
+ ->setAttributeSetFilter($attributeSet->getId()) as $attribute) {
32
+
33
+ $attributeCode = $attribute->getAttributeCode();
34
+ $attributeId = $attribute->getId();
35
+
36
+ if ($attribute->getIsVisible() || in_array($attributeCode, $this->_forcedAttributesCodes)) {
37
+ if (!isset($attributesCache[$attributeId])) {
38
+ $attributesCache[$attributeId] = array(
39
+ 'id' => $attributeId,
40
+ 'code' => $attributeCode,
41
+ 'for_configurable' => $attribute->getIsConfigurable(),
42
+ 'is_global' => $attribute->getIsGlobal(),
43
+ 'is_required' => $attribute->getIsRequired(),
44
+ 'frontend_label' => $attribute->getFrontendLabel(),
45
+ 'frontend_input' => $attribute->getFrontendInput(),
46
+ 'is_static' => $attribute->isStatic(),
47
+ 'apply_to' => $attribute->getApplyTo(),
48
+ 'type' => Mage_ImportExport_Model_Import::getAttributeType($attribute),
49
+ 'default_value' => strlen($attribute->getDefaultValue())
50
+ ? $attribute->getDefaultValue() : null,
51
+ 'options' => $this->_entityModel
52
+ ->getAttributeOptions($attribute, $this->_indexValueAttributes)
53
+ );
54
+ }
55
+ $this->_addAttributeParams($attributeSet->getAttributeSetName(), $attributesCache[$attributeId]);
56
+ }
57
+ }
58
+ }
59
+ return $this;
60
+ }
61
+
62
+ /**
63
+ * Prepare attributes values for save: remove non-existent, remove empty values, remove static.
64
  *
65
  * @param array $rowData
66
+ * @return array
 
 
67
  */
68
+ public function prepareAttributesForSave(array $rowData)
69
  {
70
+ $resultAttrs = array();
71
+
72
+ foreach ($this->_getProductAttributes($rowData) as $attrCode => $attrParams) {
73
+ if (!$attrParams['is_static']) {
74
  if (isset($rowData[$attrCode]) && strlen($rowData[$attrCode])) {
75
+ switch ($attrParams['frontend_input'])
76
+ {
77
+ case 'multiselect':
78
+ $codes = array();
79
+ foreach (explode(",", $rowData[$attrCode]) as $code)
80
+ {
81
+ $codes[] = $attrParams['options'][strtolower($code)];
82
+ }
83
+ $resultAttrs[$attrCode] = implode(",", array_unique($codes));
84
+ break;
85
+ case 'select':
86
+ $resultAttrs[$attrCode] = $attrParams['options'][strtolower($rowData[$attrCode])];
87
+ break;
88
+ default:
89
+ $resultAttrs[$attrCode] = $rowData[$attrCode];
90
+ }
91
+ } elseif (null !== $attrParams['default_value']) {
92
+ $resultAttrs[$attrCode] = $attrParams['default_value'];
93
  }
94
  }
95
+ }
96
+
97
+ return $resultAttrs;
98
  }
99
  }
app/code/community/AMartinez/CustomImportExport/Model/Import/Entity/Product/Type/Grouped.php CHANGED
@@ -5,7 +5,7 @@
5
  * @category AMartinez
6
  * @package AMartinez_CustomImportExport
7
  * @author Antonio Martinez
8
- * @copyright Copyright (c) 2011 Antonio Martínez (toniyecla [at] gmail [dot] com)
9
  * @license http://opensource.org/licenses/osl-3.0 Open Software License (OSL 3.0)
10
  */
11
 
@@ -16,24 +16,84 @@ class AMartinez_CustomImportExport_Model_Import_Entity_Product_Type_Grouped
16
  extends Mage_ImportExport_Model_Import_Entity_Product_Type_Grouped
17
  {
18
  /**
19
- * Validate row attributes. Pass VALID row data ONLY as argument.
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
20
  *
21
  * @param array $rowData
22
- * @param int $rowNum
23
- * @param boolean $checkRequiredAttributes OPTIONAL Flag which can disable validation required values.
24
- * @return boolean
25
  */
26
- public function isRowValid(array $rowData, $rowNum, $checkRequiredAttributes = true)
27
  {
28
- // create sub-row's new attribute options
29
- if (Mage_ImportExport_Model_Import_Entity_Product::SCOPE_NULL == $this->_entityModel->getRowScope($rowData)) {
30
- foreach ($this->_getProductAttributes($rowData) as $attrCode => $attrParams) {
 
31
  if (isset($rowData[$attrCode]) && strlen($rowData[$attrCode])) {
32
- $this->_entityModel->isAttributeValid($attrCode, $attrParams, $rowData, $rowNum);
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
33
  }
34
  }
35
- }
36
-
37
- return Mage_ImportExport_Model_Import_Entity_Product_Type_Abstract::isRowValid($rowData, $rowNum, $checkRequiredAttributes);
38
  }
39
  }
5
  * @category AMartinez
6
  * @package AMartinez_CustomImportExport
7
  * @author Antonio Martinez
8
+ * @copyright Copyright (c) 2011 Antonio Martinez (toniyecla [at] gmail [dot] com)
9
  * @license http://opensource.org/licenses/osl-3.0 Open Software License (OSL 3.0)
10
  */
11
 
16
  extends Mage_ImportExport_Model_Import_Entity_Product_Type_Grouped
17
  {
18
  /**
19
+ * Initialize attributes parameters for all attributes' sets.
20
+ *
21
+ * @return Mage_ImportExport_Model_Import_Entity_Product_Type_Abstract
22
+ */
23
+ protected function _initAttributes()
24
+ {
25
+ // temporary storage for attributes' parameters to avoid double querying inside the loop
26
+ $attributesCache = array();
27
+
28
+ foreach (Mage::getResourceModel('eav/entity_attribute_set_collection')
29
+ ->setEntityTypeFilter($this->_entityModel->getEntityTypeId()) as $attributeSet) {
30
+ foreach (Mage::getResourceModel('catalog/product_attribute_collection')
31
+ ->setAttributeSetFilter($attributeSet->getId()) as $attribute) {
32
+
33
+ $attributeCode = $attribute->getAttributeCode();
34
+ $attributeId = $attribute->getId();
35
+
36
+ if ($attribute->getIsVisible() || in_array($attributeCode, $this->_forcedAttributesCodes)) {
37
+ if (!isset($attributesCache[$attributeId])) {
38
+ $attributesCache[$attributeId] = array(
39
+ 'id' => $attributeId,
40
+ 'code' => $attributeCode,
41
+ 'for_configurable' => $attribute->getIsConfigurable(),
42
+ 'is_global' => $attribute->getIsGlobal(),
43
+ 'is_required' => $attribute->getIsRequired(),
44
+ 'frontend_label' => $attribute->getFrontendLabel(),
45
+ 'frontend_input' => $attribute->getFrontendInput(),
46
+ 'is_static' => $attribute->isStatic(),
47
+ 'apply_to' => $attribute->getApplyTo(),
48
+ 'type' => Mage_ImportExport_Model_Import::getAttributeType($attribute),
49
+ 'default_value' => strlen($attribute->getDefaultValue())
50
+ ? $attribute->getDefaultValue() : null,
51
+ 'options' => $this->_entityModel
52
+ ->getAttributeOptions($attribute, $this->_indexValueAttributes)
53
+ );
54
+ }
55
+ $this->_addAttributeParams($attributeSet->getAttributeSetName(), $attributesCache[$attributeId]);
56
+ }
57
+ }
58
+ }
59
+ return $this;
60
+ }
61
+
62
+ /**
63
+ * Prepare attributes values for save: remove non-existent, remove empty values, remove static.
64
  *
65
  * @param array $rowData
66
+ * @return array
 
 
67
  */
68
+ public function prepareAttributesForSave(array $rowData)
69
  {
70
+ $resultAttrs = array();
71
+
72
+ foreach ($this->_getProductAttributes($rowData) as $attrCode => $attrParams) {
73
+ if (!$attrParams['is_static']) {
74
  if (isset($rowData[$attrCode]) && strlen($rowData[$attrCode])) {
75
+ switch ($attrParams['frontend_input'])
76
+ {
77
+ case 'multiselect':
78
+ $codes = array();
79
+ foreach (explode(",", $rowData[$attrCode]) as $code)
80
+ {
81
+ $codes[] = $attrParams['options'][strtolower($code)];
82
+ }
83
+ $resultAttrs[$attrCode] = implode(",", array_unique($codes));
84
+ break;
85
+ case 'select':
86
+ $resultAttrs[$attrCode] = $attrParams['options'][strtolower($rowData[$attrCode])];
87
+ break;
88
+ default:
89
+ $resultAttrs[$attrCode] = $rowData[$attrCode];
90
+ }
91
+ } elseif (null !== $attrParams['default_value']) {
92
+ $resultAttrs[$attrCode] = $attrParams['default_value'];
93
  }
94
  }
95
+ }
96
+
97
+ return $resultAttrs;
98
  }
99
  }
app/code/community/AMartinez/CustomImportExport/Model/Import/Entity/Product/Type/Simple.php CHANGED
@@ -5,7 +5,7 @@
5
  * @category AMartinez
6
  * @package AMartinez_CustomImportExport
7
  * @author Antonio Martinez
8
- * @copyright Copyright (c) 2011 Antonio Martínez (toniyecla [at] gmail [dot] com)
9
  * @license http://opensource.org/licenses/osl-3.0 Open Software License (OSL 3.0)
10
  */
11
 
@@ -16,24 +16,84 @@ class AMartinez_CustomImportExport_Model_Import_Entity_Product_Type_Simple
16
  extends Mage_ImportExport_Model_Import_Entity_Product_Type_Simple
17
  {
18
  /**
19
- * Validate row attributes. Pass VALID row data ONLY as argument.
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
20
  *
21
  * @param array $rowData
22
- * @param int $rowNum
23
- * @param boolean $checkRequiredAttributes OPTIONAL Flag which can disable validation required values.
24
- * @return boolean
25
  */
26
- public function isRowValid(array $rowData, $rowNum, $checkRequiredAttributes = true)
27
  {
28
- // create sub-row's new attribute options
29
- if (Mage_ImportExport_Model_Import_Entity_Product::SCOPE_NULL == $this->_entityModel->getRowScope($rowData)) {
30
- foreach ($this->_getProductAttributes($rowData) as $attrCode => $attrParams) {
 
31
  if (isset($rowData[$attrCode]) && strlen($rowData[$attrCode])) {
32
- $this->_entityModel->isAttributeValid($attrCode, $attrParams, $rowData, $rowNum);
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
33
  }
34
  }
35
- }
36
-
37
- return Mage_ImportExport_Model_Import_Entity_Product_Type_Abstract::isRowValid($rowData, $rowNum, $checkRequiredAttributes);
38
  }
39
  }
5
  * @category AMartinez
6
  * @package AMartinez_CustomImportExport
7
  * @author Antonio Martinez
8
+ * @copyright Copyright (c) 2011 Antonio Martinez (toniyecla [at] gmail [dot] com)
9
  * @license http://opensource.org/licenses/osl-3.0 Open Software License (OSL 3.0)
10
  */
11
 
16
  extends Mage_ImportExport_Model_Import_Entity_Product_Type_Simple
17
  {
18
  /**
19
+ * Initialize attributes parameters for all attributes' sets.
20
+ *
21
+ * @return Mage_ImportExport_Model_Import_Entity_Product_Type_Abstract
22
+ */
23
+ protected function _initAttributes()
24
+ {
25
+ // temporary storage for attributes' parameters to avoid double querying inside the loop
26
+ $attributesCache = array();
27
+
28
+ foreach (Mage::getResourceModel('eav/entity_attribute_set_collection')
29
+ ->setEntityTypeFilter($this->_entityModel->getEntityTypeId()) as $attributeSet) {
30
+ foreach (Mage::getResourceModel('catalog/product_attribute_collection')
31
+ ->setAttributeSetFilter($attributeSet->getId()) as $attribute) {
32
+
33
+ $attributeCode = $attribute->getAttributeCode();
34
+ $attributeId = $attribute->getId();
35
+
36
+ if ($attribute->getIsVisible() || in_array($attributeCode, $this->_forcedAttributesCodes)) {
37
+ if (!isset($attributesCache[$attributeId])) {
38
+ $attributesCache[$attributeId] = array(
39
+ 'id' => $attributeId,
40
+ 'code' => $attributeCode,
41
+ 'for_configurable' => $attribute->getIsConfigurable(),
42
+ 'is_global' => $attribute->getIsGlobal(),
43
+ 'is_required' => $attribute->getIsRequired(),
44
+ 'frontend_label' => $attribute->getFrontendLabel(),
45
+ 'frontend_input' => $attribute->getFrontendInput(),
46
+ 'is_static' => $attribute->isStatic(),
47
+ 'apply_to' => $attribute->getApplyTo(),
48
+ 'type' => Mage_ImportExport_Model_Import::getAttributeType($attribute),
49
+ 'default_value' => strlen($attribute->getDefaultValue())
50
+ ? $attribute->getDefaultValue() : null,
51
+ 'options' => $this->_entityModel
52
+ ->getAttributeOptions($attribute, $this->_indexValueAttributes)
53
+ );
54
+ }
55
+ $this->_addAttributeParams($attributeSet->getAttributeSetName(), $attributesCache[$attributeId]);
56
+ }
57
+ }
58
+ }
59
+ return $this;
60
+ }
61
+
62
+ /**
63
+ * Prepare attributes values for save: remove non-existent, remove empty values, remove static.
64
  *
65
  * @param array $rowData
66
+ * @return array
 
 
67
  */
68
+ public function prepareAttributesForSave(array $rowData)
69
  {
70
+ $resultAttrs = array();
71
+
72
+ foreach ($this->_getProductAttributes($rowData) as $attrCode => $attrParams) {
73
+ if (!$attrParams['is_static']) {
74
  if (isset($rowData[$attrCode]) && strlen($rowData[$attrCode])) {
75
+ switch ($attrParams['frontend_input'])
76
+ {
77
+ case 'multiselect':
78
+ $codes = array();
79
+ foreach (explode(",", $rowData[$attrCode]) as $code)
80
+ {
81
+ $codes[] = $attrParams['options'][strtolower($code)];
82
+ }
83
+ $resultAttrs[$attrCode] = implode(",", array_unique($codes));
84
+ break;
85
+ case 'select':
86
+ $resultAttrs[$attrCode] = $attrParams['options'][strtolower($rowData[$attrCode])];
87
+ break;
88
+ default:
89
+ $resultAttrs[$attrCode] = $rowData[$attrCode];
90
+ }
91
+ } elseif (null !== $attrParams['default_value']) {
92
+ $resultAttrs[$attrCode] = $attrParams['default_value'];
93
  }
94
  }
95
+ }
96
+
97
+ return $resultAttrs;
98
  }
99
  }
app/code/community/AMartinez/CustomImportExport/etc/config.xml CHANGED
@@ -6,7 +6,7 @@
6
  * @category AMartinez
7
  * @package AMartinez_CustomImportExport
8
  * @author Antonio Martinez
9
- * @copyright Copyright (c) 2011 Antonio Martínez (toniyecla [at] gmail [dot] com)
10
  * @license http://opensource.org/licenses/osl-3.0 Open Software License (OSL 3.0)
11
  */
12
  -->
@@ -14,7 +14,7 @@
14
 
15
  <modules>
16
  <AMartinez_CustomImportExport>
17
- <version>1.5.011</version>
18
  <depends>
19
  <!-- no dependencies -->
20
  </depends>
@@ -58,12 +58,12 @@
58
  <default>
59
  <customimportexport>
60
  <products>
61
- <sourcefile>var/customimportexport/productsimport.csv</sourcefile>
62
- <outputfile>var/customimportexport/productsexport.csv</outputfile>
63
  </products>
64
  <customers>
65
- <sourcefile>var/customimportexport/customersimport.csv</sourcefile>
66
- <outputfile>var/customimportexport/customersexport.csv</outputfile>
67
  </customers>
68
  </customimportexport>
69
  </default>
6
  * @category AMartinez
7
  * @package AMartinez_CustomImportExport
8
  * @author Antonio Martinez
9
+ * @copyright Copyright (c) 2011 Antonio Martinez (toniyecla [at] gmail [dot] com)
10
  * @license http://opensource.org/licenses/osl-3.0 Open Software License (OSL 3.0)
11
  */
12
  -->
14
 
15
  <modules>
16
  <AMartinez_CustomImportExport>
17
+ <version>1.5.013</version>
18
  <depends>
19
  <!-- no dependencies -->
20
  </depends>
58
  <default>
59
  <customimportexport>
60
  <products>
61
+ <sourcefile>var/customimportexport/products.csv</sourcefile>
62
+ <outputfile>var/customimportexport/products.csv</outputfile>
63
  </products>
64
  <customers>
65
+ <sourcefile>var/customimportexport/customers.csv</sourcefile>
66
+ <outputfile>var/customimportexport/customers.csv</outputfile>
67
  </customers>
68
  </customimportexport>
69
  </default>
app/code/community/AMartinez/CustomImportExport/shell/run.php CHANGED
@@ -5,7 +5,7 @@
5
  * @category AMartinez
6
  * @package AMartinez_CustomImportExport
7
  * @author Antonio Martinez
8
- * @copyright Copyright (c) 2011 Antonio Martínez (toniyecla [at] gmail [dot] com)
9
  * @license http://opensource.org/licenses/osl-3.0 Open Software License (OSL 3.0)
10
  */
11
 
@@ -25,7 +25,7 @@ class AMartinez_CustomImportExport extends Mage_Shell_Abstract
25
  Mage::setIsDeveloperMode(true);
26
  ini_set('display_errors', 1);
27
  // ini_set("memory_limit","2048M");
28
- echo "";
29
 
30
  // help
31
  if ($this->getArg('h') || $this->getArg('help') || count($this->_args) == 0)
@@ -33,10 +33,6 @@ class AMartinez_CustomImportExport extends Mage_Shell_Abstract
33
  die($this->usageHelp());
34
  }
35
 
36
- // behavior
37
- $this->behavior = ($this->getArg('b') ? $this->getArg('b') : ($this->getArg('behavior') ? $this->getArg('behavior') : 'replace'));
38
- $this->behavior === true ? $this->behavior = 'replace': '';
39
-
40
  // database export
41
  if ($backup = $this->initDatabaseBackupModel()) {
42
  echo "Start database output to file " . $backup->getPath() . DS . $backup->getFilename() . "\n";
@@ -44,19 +40,63 @@ class AMartinez_CustomImportExport extends Mage_Shell_Abstract
44
 
45
  $backupDb = Mage::getModel('backup/db');
46
  Mage::register('backup_model', $backup);
47
- if ($backupDb->createBackup($backup)) {
 
48
  echo "Done.\n";
49
  }
50
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
51
 
52
- $import = $this->initImportModel();
 
 
53
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
54
  // products import
55
  if ($filename = $this->getSourceFile()) {
56
- $files = $this->splitFile($filename, ($this->getArg('l') ? $this->getArg('l') : ($this->getArg('linecount') ? $this->getArg('linecount') : true)));
57
 
58
  echo "Start products '$this->behavior' action from $filename\n";
59
- Mage::log("Start proucts '$this->behavior' action from $filename", Zend_Log::DEBUG);
60
 
61
  $count = 0;
62
  foreach ($files as $file)
@@ -80,7 +120,7 @@ class AMartinez_CustomImportExport extends Mage_Shell_Abstract
80
  }
81
 
82
  if ($message) {
83
- $this->unlinkFiles($files);
84
  Mage::throwException(sprintf("File %s contains %s corrupt records (from a total of %s)", $file, $import->getInvalidRowsCount(), $processedRowsCount) . $message);
85
  }
86
 
@@ -93,33 +133,32 @@ class AMartinez_CustomImportExport extends Mage_Shell_Abstract
93
  $import->importSource();
94
  }
95
  }
96
- $this->unlinkFiles($files);
97
  echo "\nDone (processed rows count: " . $count . ")\n";
98
  }
99
-
100
- // products export
101
- if ($file = $this->getOutputFile()) {
102
- echo "Start products output to file $file\n";
103
- Mage::log("Start products output to file $file", Zend_Log::DEBUG);
104
 
105
- $export = $this->initExportModel();
106
  if ($f = fopen($file, 'w'))
107
  {
108
- $result = $export->export();
109
  fwrite($f, $result);
110
  fclose($f);
111
- echo "Done (processed rows count: " . (substr_count($result, "\n") - 1). ")\n";
112
  }
113
  else
114
  {
115
- echo "Cannot output products to file $file\n";
116
  };
117
  }
118
-
119
  // customers import
120
  if ($filename = $this->getCustomersSourceFile()) {
121
- // get only one field each time to prevent disruption because global errors
122
- $files = $this->splitFile($filename, ($this->getArg('l') ? $this->getArg('l') : ($this->getArg('linecount') ? $this->getArg('linecount') : true)));
123
 
124
  echo "Start customers '$this->behavior' action from $filename\n";
125
  Mage::log("Start customers '$this->behavior' action from $filename", Zend_Log::DEBUG);
@@ -134,14 +173,17 @@ class AMartinez_CustomImportExport extends Mage_Shell_Abstract
134
 
135
  if ($processedRowsCount > 0)
136
  {
 
137
  while (!$validationResult)
138
  {
 
139
  $errorLines = array();
140
  foreach ($customersimport->getErrors() as $type => $lines)
141
  {
142
- echo ":::: " . $type . " in line(s) " . implode(", ", $lines) . "::::\n";
143
  $errorLines = array_merge($errorLines, $lines);
144
  }
 
145
  $file_ = str_replace('tmp.', 'tmp._', $file);
146
  $files_[] = $file_;
147
  $h = fopen($file, 'r');
@@ -162,7 +204,7 @@ class AMartinez_CustomImportExport extends Mage_Shell_Abstract
162
  }
163
  else
164
  {
165
- echo ":::: Line " . $i . " :::: " . $line;
166
  $error = true;
167
  }
168
  }
@@ -182,75 +224,123 @@ class AMartinez_CustomImportExport extends Mage_Shell_Abstract
182
  }
183
  }
184
 
185
- $this->unlinkFiles($files);
186
- $this->unlinkFiles($files_);
187
  echo "\nDone (processed rows count: " . $count . ")\n";
188
  }
 
 
 
 
 
 
189
 
190
- // customers export
191
- if ($file = $this->getCustomersOutputFile()) {
192
- echo "Start customers output to file $file\n";
193
- Mage::log("Start customers output to file $file", Zend_Log::DEBUG);
194
-
195
- $customersexport = $this->initCustomersExportModel();
196
- if ($f = fopen($file, 'w'))
197
- {
198
- $result = $customersexport->export();
199
- fwrite($f, $result);
200
- fclose($f);
201
- echo "Done (processed rows count: " . (substr_count($result, "\n") - 1) . ")\n";
202
- }
203
- else
204
- {
205
- echo "Cannot output customers to file $file\n";
206
- };
207
  }
208
 
209
  // index
210
  if ($this->getArg('r') || $this->getArg('reindex') || $this->getArg('a') || $this->getArg('all'))
211
  {
212
- echo "Reindexing data...\n";
213
- try
214
- {
215
- $import->reindexAll();
216
- }
217
- catch (Exception $e) {}
218
  }
219
-
220
  // cache
221
  if ($this->getArg('c') || $this->getArg('cleancache') || $this->getArg('a') || $this->getArg('all'))
222
  {
223
- echo "Cleaning cache...\n";
224
- try
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
225
  {
226
- $import->cleanCache();
 
 
 
 
 
 
227
  }
228
- catch (Exception $e) {}
229
- }
230
-
231
- // image files
232
- if ($this->getArg('f') || $this->getArg('flushimages') || $this->getArg('a') || $this->getArg('all'))
233
- {
234
- echo "Erasing catalog images cache...\n";
235
- try
236
  {
237
- $import->flushImages();
 
 
 
 
 
 
238
  }
239
- catch (Exception $e) {}
 
 
 
 
 
 
240
  }
 
 
 
 
 
 
 
 
 
 
 
 
241
 
242
- // price rules
243
- if ($this->getArg('p') || $this->getArg('applyrules') || $this->getArg('a') || $this->getArg('all'))
 
 
 
 
 
 
 
 
 
 
 
244
  {
245
- echo "Recalculating catalog price rules...\n";
246
- try
 
 
 
 
 
 
 
 
 
 
 
247
  {
248
- $import->applyRules();
249
  }
250
- catch (Exception $e) {}
251
  }
252
  }
253
-
254
  /**
255
  * Initialize products import model
256
  *
@@ -317,28 +407,28 @@ class AMartinez_CustomImportExport extends Mage_Shell_Abstract
317
  }
318
 
319
  /**
320
- * Initialize products export model
321
  *
322
  * @return AMartinez_CustomImportExport_Model_Export
323
  */
324
- public function initExportModel()
325
  {
326
- $export = Mage::getModel('customimportexport/export');
327
- $export->setEntity('catalog_product');
328
- $export->setData('file_format', 'csv');
329
 
330
- return $export;
331
  }
332
 
333
  /**
334
- * Return the specified products output file
335
  *
336
  * @return string
337
  */
338
- public function getOutputFile()
339
  {
340
- $option1 = $this->getArg('e');
341
- $option2 = $this->getArg('export');
342
  if ($option1 || $option2)
343
  {
344
  if ($option1 && $option1 != 1)
@@ -349,17 +439,17 @@ class AMartinez_CustomImportExport extends Mage_Shell_Abstract
349
  {
350
  return $option2;
351
  }
352
- if ($default = Mage::getStoreConfig('customimportexport/products/outputfile'))
353
  {
354
  return $default;
355
  }
356
  else
357
  {
358
- echo "No default products output file found in config.xml\n";
359
  }
360
  }
361
  }
362
-
363
  /**
364
  * Initialize customers import model
365
  *
@@ -424,174 +514,48 @@ class AMartinez_CustomImportExport extends Mage_Shell_Abstract
424
  }
425
  }
426
  }
427
-
428
- /**
429
- * Initialize customers export model
430
- *
431
- * @return AMartinez_CustomImportExport_Model_Export
432
- */
433
- public function initCustomersExportModel()
434
- {
435
- $customersexport = Mage::getModel('customimportexport/export');
436
- $customersexport->setEntity('customer');
437
- $customersexport->setData('file_format', 'csv');
438
-
439
- return $customersexport;
440
- }
441
-
442
- /**
443
- * Return the specified customers output file
444
- *
445
- * @return string
446
- */
447
- public function getCustomersOutputFile()
448
- {
449
- $option1 = $this->getArg('ce');
450
- $option2 = $this->getArg('customersexport');
451
- if ($option1 || $option2)
452
- {
453
- if ($option1 && $option1 != 1)
454
- {
455
- return $option1;
456
- }
457
- if ($option2 && $option2 != 1)
458
- {
459
- return $option2;
460
- }
461
- if ($default = Mage::getStoreConfig('customimportexport/customers/outputfile'))
462
- {
463
- return $default;
464
- }
465
- else
466
- {
467
- echo "No default customers output file found in config.xml\n";
468
- }
469
- }
470
- }
471
 
472
- /**
473
- * Initialize database export model
474
- *
475
- * @return AMartinez_CustomImportExport_Model_Backup
476
- */
477
- public function initDatabaseBackupModel()
478
- {
479
- $option1 = $this->getArg('db');
480
- $option2 = $this->getArg('databasebackup');
481
- if ($option1 || $option2)
482
- {
483
- $backup = Mage::getModel('customimportexport/backup')
484
- ->setType('db');
485
- if ($option1 && $option1 != 1)
486
- {
487
- $fileinfo = pathinfo($option1);
488
- if (substr($fileinfo['dirname'], 0) != DS) {
489
- $fileinfo['dirname'] = Mage::getBaseDir() . DS . $fileinfo['dirname'];
490
- }
491
- $backup->setPath($fileinfo['dirname'])
492
- ->setFile($fileinfo['basename']);
493
- return $backup;
494
- }
495
- if ($option2 && $option2 != 1)
496
- {
497
- $fileinfo = pathinfo($option2);
498
- if (substr($fileinfo['dirname'], 0) != DS) {
499
- $fileinfo['dirname'] = Mage::getBaseDir() . DS . $fileinfo['dirname'];
500
- }
501
- $backup->setPath($fileinfo['dirname'])
502
- ->setFile($fileinfo['basename']);
503
- return $backup;
504
- }
505
- $backup->setPath(Mage::getBaseDir("var") . DS . "backups")
506
- ->setFile(time() . "_" . $backup->getType() . ".gz");
507
- return $backup;
508
- }
509
- else
510
- {
511
- return false;
512
- }
513
- }
514
-
515
- /**
516
- * Split file into pieces
517
- */
518
- public function splitFile($filename, $linecount)
519
- {
520
- $extension = pathinfo($filename, PATHINFO_EXTENSION);
521
- $count = 0;
522
- $i = 0;
523
- $j = 0;
524
- $files = array();
525
- $h = fopen($filename, 'r');
526
- $header = fgets($h);
527
- while($line = fgets($h))
528
- {
529
- // first iteration / no "attr-only" line / line count has been reached
530
- if ($i == 0 || (substr($line, 0 ,1) != ',' && substr($line, 0 ,2) != '""' && substr($line, 0 ,2) != "''" && $i >= $linecount && !($linecount === true)))
531
- {
532
- if (defined('t'))
533
- {
534
- fclose($t);
535
- }
536
- $files[] = $filename . '.tmp.' . $j . '.' . $extension;
537
- $t = fopen($files[$j++], 'w');
538
- fwrite($t, $header);
539
- $i = 0;
540
- }
541
- fwrite($t, $line);
542
- $count++;
543
- $i++;
544
- }
545
- fclose($h);
546
- if (defined('t'))
547
- {
548
- fclose($t);
549
- }
550
-
551
- return $files;
552
- }
553
-
554
- /**
555
- * Unlink temp files
556
- */
557
- public function unlinkFiles($files)
558
- {
559
- foreach ($files as $file)
560
- {
561
- unlink($file);
562
- }
563
- }
564
-
565
  /**
566
  * Retrieve usage help message
567
  */
568
  public function usageHelp()
569
  {
 
 
570
  return <<<HELP
571
- AMartinez_CustomImportExport script (v. 1.5.011)
572
 
573
  NAME
574
  run.php
575
 
576
  SYNOPSIS
577
- php -f app/code/community/AMartinez/CustomImportExport/shell/run.php
578
- php -f app/code/community/AMartinez/CustomImportExport/shell/run.php [-- [OPTIONS...]]
579
 
580
  DESCRIPTION
581
  This extension can Import/Export products and customers from/to CSV file. Create categories, add attribute options, reindex, refresh cache, images and price rules automatically. In addition you can backup the entire database in SQL format.
582
 
583
  Imports:
584
  (products, customers)
585
- file.csv: multiple-row csv files
586
  (products)
587
- file.csv1: single-row csv files, with some multivalued fields ("CAT1/CAT2,CAT3","ASSOCIATED1,ASSOCIATED2"...), you can define your own multivalued column names with * prefix ("sku","name","*_category","*_associated_sku"...)
588
-
 
 
 
 
 
 
 
 
 
589
  Exports:
590
  (products, customers)
591
- file.csv: multiple-row new csv files
592
  (database)
593
  backup all tables to SQL gz-compressed file
594
-
595
  OPTIONS
596
  -h
597
  -help
@@ -603,7 +567,7 @@ OPTIONS
603
 
604
  -b
605
  -behavior
606
- set import behavior: append|delete|replace (default)
607
 
608
  -c
609
  -cleancache
@@ -620,7 +584,13 @@ OPTIONS
620
  -db [file]
621
  -databasebackup [file]
622
  output whole magento database to sql file and try to gzcompress it, if output file not specified uses time generated name
623
-
 
 
 
 
 
 
624
  -e [file]
625
  -export [file]
626
  output products to csv file, if output file not specified uses defined in config.xml
@@ -635,7 +605,7 @@ OPTIONS
635
 
636
  -l <n>
637
  -linecount <n>
638
- split import file into pieces of n lines length
639
 
640
  -p
641
  -applyrules
@@ -646,20 +616,24 @@ OPTIONS
646
  reindex data by all indexers (attributes, prices, etc)
647
 
648
  EXAMPLES
649
- ussual import
650
- php -f app/code/community/AMartinez/CustomImportExport/shell/run.php -- -all -import var/customimportexport/test_single_row_style.csv1
651
 
652
- ussual export
653
- php -f app/code/community/AMartinez/CustomImportExport/shell/run.php -- -e
654
 
655
- reindex / flush cache
656
- php -f app/code/community/AMartinez/CustomImportExport/shell/run.php -- -a
657
 
658
- backup, then import
659
- php -f app/code/community/AMartinez/CustomImportExport/shell/run.php -- -databasebackup -import -all
 
 
 
 
660
 
661
- crontab example (daily)
662
- 00 03 * * * root php -f /var/www/html/magento/store/app/code/community/AMartinez/CustomImportExport/shell/run.php -- -db -a -i /var/www/html/magento/store/var/customimportexport/products.csv1 | xargs -0 -I msg echo -e "Subject: MY STORE products daily update \n\n " msg | /usr/sbin/sendmail -f some@address.com some@address.com
663
 
664
  CREDITS
665
  I would be delighted to hear from you if you like this script. I also appreciate any donation you wish to contribute to the growth of this project (paypal: toniyecla [at] gmail [dot] com).
5
  * @category AMartinez
6
  * @package AMartinez_CustomImportExport
7
  * @author Antonio Martinez
8
+ * @copyright Copyright (c) 2011 Antonio Martinez (toniyecla [at] gmail [dot] com)
9
  * @license http://opensource.org/licenses/osl-3.0 Open Software License (OSL 3.0)
10
  */
11
 
25
  Mage::setIsDeveloperMode(true);
26
  ini_set('display_errors', 1);
27
  // ini_set("memory_limit","2048M");
28
+ echo "\n";
29
 
30
  // help
31
  if ($this->getArg('h') || $this->getArg('help') || count($this->_args) == 0)
33
  die($this->usageHelp());
34
  }
35
 
 
 
 
 
36
  // database export
37
  if ($backup = $this->initDatabaseBackupModel()) {
38
  echo "Start database output to file " . $backup->getPath() . DS . $backup->getFilename() . "\n";
40
 
41
  $backupDb = Mage::getModel('backup/db');
42
  Mage::register('backup_model', $backup);
43
+ if ($backupDb->createBackup($backup))
44
+ {
45
  echo "Done.\n";
46
  }
47
  }
48
+
49
+ // delete products
50
+ if ($this->getArg('deleteallproducts'))
51
+ {
52
+ echo "Start all products delete\n";
53
+ Mage::log("Start all products delete", Zend_Log::DEBUG);
54
+ if ($count = Mage::helper('customimportexport')->deleteAllProducts())
55
+ {
56
+ echo "Done (deleted products: " . $count . ")\n";
57
+ }
58
+ }
59
+
60
+ // delete customers
61
+ if ($this->getArg('deleteallcustomers'))
62
+ {
63
+ echo "Start all customers delete\n";
64
+ Mage::log("Start all customers delete", Zend_Log::DEBUG);
65
+ if ($count = Mage::helper('customimportexport')->deleteAllCustomers())
66
+ {
67
+ echo "Done (deleted customers: " . $count . ")\n";
68
+ }
69
+ }
70
 
71
+ // behavior
72
+ $this->behavior = ($this->getArg('b') ? $this->getArg('b') : ($this->getArg('behavior') ? $this->getArg('behavior') : 'replace'));
73
+ $this->behavior === true ? $this->behavior = 'replace': '';
74
 
75
+ // products export
76
+ if ($file = $this->getOutputFile()) {
77
+ echo "Start products output to file $file\n";
78
+ Mage::log("Start products output to file $file", Zend_Log::DEBUG);
79
+
80
+ $export = $this->initExportModel();
81
+ if ($f = fopen($file, 'w'))
82
+ {
83
+ $result = $export->export();
84
+ fwrite($f, $result);
85
+ fclose($f);
86
+ echo "Done (processed rows count: " . (substr_count($result, "\n") - 1). ")\n";
87
+ }
88
+ else
89
+ {
90
+ echo "Cannot output products to file $file\n";
91
+ };
92
+ }
93
+
94
  // products import
95
  if ($filename = $this->getSourceFile()) {
96
+ $files = Mage::helper('customimportexport')->splitFile($filename, ($this->getArg('l') ? $this->getArg('l') : ($this->getArg('linecount') ? $this->getArg('linecount') : true)));
97
 
98
  echo "Start products '$this->behavior' action from $filename\n";
99
+ Mage::log("Start products '$this->behavior' action from $filename", Zend_Log::DEBUG);
100
 
101
  $count = 0;
102
  foreach ($files as $file)
120
  }
121
 
122
  if ($message) {
123
+ Mage::helper('customimportexport')->unlinkFiles($files);
124
  Mage::throwException(sprintf("File %s contains %s corrupt records (from a total of %s)", $file, $import->getInvalidRowsCount(), $processedRowsCount) . $message);
125
  }
126
 
133
  $import->importSource();
134
  }
135
  }
136
+ Mage::helper('customimportexport')->unlinkFiles($files);
137
  echo "\nDone (processed rows count: " . $count . ")\n";
138
  }
139
+
140
+ // customers export
141
+ if ($file = $this->getCustomersOutputFile()) {
142
+ echo "Start customers output to file $file\n";
143
+ Mage::log("Start customers output to file $file", Zend_Log::DEBUG);
144
 
145
+ $customersexport = $this->initCustomersExportModel();
146
  if ($f = fopen($file, 'w'))
147
  {
148
+ $result = $customersexport->export();
149
  fwrite($f, $result);
150
  fclose($f);
151
+ echo "Done (processed rows count: " . (substr_count($result, "\n") - 1) . ")\n";
152
  }
153
  else
154
  {
155
+ echo "Cannot output customers to file $file\n";
156
  };
157
  }
158
+
159
  // customers import
160
  if ($filename = $this->getCustomersSourceFile()) {
161
+ $files = Mage::helper('customimportexport')->splitFile($filename, ($this->getArg('l') ? $this->getArg('l') : ($this->getArg('linecount') ? $this->getArg('linecount') : true)));
 
162
 
163
  echo "Start customers '$this->behavior' action from $filename\n";
164
  Mage::log("Start customers '$this->behavior' action from $filename", Zend_Log::DEBUG);
173
 
174
  if ($processedRowsCount > 0)
175
  {
176
+ // get only one field each time to prevent disruption because some line errors
177
  while (!$validationResult)
178
  {
179
+ echo "\n";
180
  $errorLines = array();
181
  foreach ($customersimport->getErrors() as $type => $lines)
182
  {
183
+ echo ":::: " . $type . " in line(s) " . implode(", ", $lines) . " ::::\n";
184
  $errorLines = array_merge($errorLines, $lines);
185
  }
186
+ echo "\n";
187
  $file_ = str_replace('tmp.', 'tmp._', $file);
188
  $files_[] = $file_;
189
  $h = fopen($file, 'r');
204
  }
205
  else
206
  {
207
+ echo ":: Line " . $i . " :: " . $line;
208
  $error = true;
209
  }
210
  }
224
  }
225
  }
226
 
227
+ Mage::helper('customimportexport')->unlinkFiles($files);
228
+ Mage::helper('customimportexport')->unlinkFiles($files_);
229
  echo "\nDone (processed rows count: " . $count . ")\n";
230
  }
231
+
232
+ // price rules
233
+ if ($this->getArg('p') || $this->getArg('applyrules') || $this->getArg('a') || $this->getArg('all'))
234
+ {
235
+ Mage::helper('customimportexport')->applyRules();
236
+ }
237
 
238
+ // image files
239
+ if ($this->getArg('f') || $this->getArg('flushimages') || $this->getArg('a') || $this->getArg('all'))
240
+ {
241
+ Mage::helper('customimportexport')->flushImages();
 
 
 
 
 
 
 
 
 
 
 
 
 
242
  }
243
 
244
  // index
245
  if ($this->getArg('r') || $this->getArg('reindex') || $this->getArg('a') || $this->getArg('all'))
246
  {
247
+ Mage::helper('customimportexport')->reindexAll();
 
 
 
 
 
248
  }
249
+
250
  // cache
251
  if ($this->getArg('c') || $this->getArg('cleancache') || $this->getArg('a') || $this->getArg('all'))
252
  {
253
+ Mage::helper('customimportexport')->cleanCache();
254
+ }
255
+ }
256
+
257
+ /**
258
+ * Initialize database export model
259
+ *
260
+ * @return AMartinez_CustomImportExport_Model_Backup
261
+ */
262
+ public function initDatabaseBackupModel()
263
+ {
264
+ $option1 = $this->getArg('db');
265
+ $option2 = $this->getArg('databasebackup');
266
+ if ($option1 || $option2)
267
+ {
268
+ $backup = Mage::getModel('customimportexport/backup')
269
+ ->setType('db');
270
+ if ($option1 && $option1 != 1)
271
  {
272
+ $fileinfo = pathinfo($option1);
273
+ if (substr($fileinfo['dirname'], 0) != DS) {
274
+ $fileinfo['dirname'] = Mage::getBaseDir() . DS . $fileinfo['dirname'];
275
+ }
276
+ $backup->setPath($fileinfo['dirname'])
277
+ ->setFile($fileinfo['basename']);
278
+ return $backup;
279
  }
280
+ if ($option2 && $option2 != 1)
 
 
 
 
 
 
 
281
  {
282
+ $fileinfo = pathinfo($option2);
283
+ if (substr($fileinfo['dirname'], 0) != DS) {
284
+ $fileinfo['dirname'] = Mage::getBaseDir() . DS . $fileinfo['dirname'];
285
+ }
286
+ $backup->setPath($fileinfo['dirname'])
287
+ ->setFile($fileinfo['basename']);
288
+ return $backup;
289
  }
290
+ $backup->setPath(Mage::getBaseDir("var") . DS . "backups")
291
+ ->setFile(time() . "_" . $backup->getType() . ".gz");
292
+ return $backup;
293
+ }
294
+ else
295
+ {
296
+ return false;
297
  }
298
+ }
299
+
300
+ /**
301
+ * Initialize products export model
302
+ *
303
+ * @return AMartinez_CustomImportExport_Model_Export
304
+ */
305
+ public function initExportModel()
306
+ {
307
+ $export = Mage::getModel('customimportexport/export');
308
+ $export->setEntity('catalog_product');
309
+ $export->setData('file_format', 'csv');
310
 
311
+ return $export;
312
+ }
313
+
314
+ /**
315
+ * Return the specified products output file
316
+ *
317
+ * @return string
318
+ */
319
+ public function getOutputFile()
320
+ {
321
+ $option1 = $this->getArg('e');
322
+ $option2 = $this->getArg('export');
323
+ if ($option1 || $option2)
324
  {
325
+ if ($option1 && $option1 != 1)
326
+ {
327
+ return $option1;
328
+ }
329
+ if ($option2 && $option2 != 1)
330
+ {
331
+ return $option2;
332
+ }
333
+ if ($default = Mage::getStoreConfig('customimportexport/products/outputfile'))
334
+ {
335
+ return $default;
336
+ }
337
+ else
338
  {
339
+ echo "No default products output file found in config.xml\n";
340
  }
 
341
  }
342
  }
343
+
344
  /**
345
  * Initialize products import model
346
  *
407
  }
408
 
409
  /**
410
+ * Initialize customers export model
411
  *
412
  * @return AMartinez_CustomImportExport_Model_Export
413
  */
414
+ public function initCustomersExportModel()
415
  {
416
+ $customersexport = Mage::getModel('customimportexport/export');
417
+ $customersexport->setEntity('customer');
418
+ $customersexport->setData('file_format', 'csv');
419
 
420
+ return $customersexport;
421
  }
422
 
423
  /**
424
+ * Return the specified customers output file
425
  *
426
  * @return string
427
  */
428
+ public function getCustomersOutputFile()
429
  {
430
+ $option1 = $this->getArg('ce');
431
+ $option2 = $this->getArg('customersexport');
432
  if ($option1 || $option2)
433
  {
434
  if ($option1 && $option1 != 1)
439
  {
440
  return $option2;
441
  }
442
+ if ($default = Mage::getStoreConfig('customimportexport/customers/outputfile'))
443
  {
444
  return $default;
445
  }
446
  else
447
  {
448
+ echo "No default customers output file found in config.xml\n";
449
  }
450
  }
451
  }
452
+
453
  /**
454
  * Initialize customers import model
455
  *
514
  }
515
  }
516
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
517
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
518
  /**
519
  * Retrieve usage help message
520
  */
521
  public function usageHelp()
522
  {
523
+ $tmp_folder = substr(Mage::getConfig()->getOptions()->getTmpDir(), strlen(Mage::getConfig()->getOptions()->getBaseDir()) + 1);
524
+
525
  return <<<HELP
526
+ AMartinez_CustomImportExport script (v. 1.5.013)
527
 
528
  NAME
529
  run.php
530
 
531
  SYNOPSIS
532
+ php -f amartinez_customimportexport.php
533
+ php -f amartinez_customimportexport.php [-- [OPTIONS...]]
534
 
535
  DESCRIPTION
536
  This extension can Import/Export products and customers from/to CSV file. Create categories, add attribute options, reindex, refresh cache, images and price rules automatically. In addition you can backup the entire database in SQL format.
537
 
538
  Imports:
539
  (products, customers)
540
+ file.csv: multiple-row csv files, supports multiselect fields
541
  (products)
542
+ file.csv1: single-row csv files, supports multiselect and multivalued fields
543
+
544
+ Multivalued fields:
545
+ You can define your own multivalued column names simply by putting an asterisk as a prefix, ie:
546
+ sku ,*_category ,*_associated_sku
547
+ TEST,"CAT1/CAT2,CAT3","ASSOCIATED1,ASSOCIATED2"
548
+
549
+ Multiselect fields:
550
+ Use commas to separate values, but make sure not to put asterisks in column header, ie:
551
+ sku ,*_category ,color
552
+ TEST,"CAT1/CAT2,CAT3","red,yellow"
553
  Exports:
554
  (products, customers)
555
+ file.csv: multiple-row new csv files (no support for multiselect)
556
  (database)
557
  backup all tables to SQL gz-compressed file
558
+
559
  OPTIONS
560
  -h
561
  -help
567
 
568
  -b
569
  -behavior
570
+ set import behavior for csv file: append|delete|replace (default)
571
 
572
  -c
573
  -cleancache
584
  -db [file]
585
  -databasebackup [file]
586
  output whole magento database to sql file and try to gzcompress it, if output file not specified uses time generated name
587
+
588
+ -deleteallcustomers
589
+ delete all customers (NOT from csv, entire magento database!)
590
+
591
+ -deleteallproducts
592
+ delete all products and non-root categories (NOT from csv, entire magento database!)
593
+
594
  -e [file]
595
  -export [file]
596
  output products to csv file, if output file not specified uses defined in config.xml
605
 
606
  -l <n>
607
  -linecount <n>
608
+ split import file into pieces of n lines length ($tmp_folder must be writable)
609
 
610
  -p
611
  -applyrules
616
  reindex data by all indexers (attributes, prices, etc)
617
 
618
  EXAMPLES
619
+ import
620
+ php -f amartinez_customimportexport.php -- -all -import var/customimportexport/test_single_row_style.csv1
621
 
622
+ export
623
+ php -f amartinez_customimportexport.php -- -e
624
 
625
+ reindex
626
+ php -f amartinez_customimportexport.php -- -a
627
 
628
+ backup, import, reindex
629
+ php -f amartinez_customimportexport.php -- -databasebackup -import -all
630
+
631
+ CRONTAB EXAMPLES
632
+ # do tasks and send results by email
633
+ 00 03 * * * root php -f /magento_base_dir/amartinez_customimportexport.php -- -db -a -i /magento_base_dir/var/customimportexport/products.csv1 2>&1 | xargs -0 -I msg echo -e "Subject: MY STORE products daily update \\n\\n " msg | /usr/sbin/sendmail -f some@address.com some@address.com
634
 
635
+ # do tasks, append output to log file and send last results by email
636
+ 00 05 * * * root php -f /magento_base_dir/amartinez_customimportexport.php -- -db -a -i /magento_base_dir/var/customimportexport/products.csv1 2>&1 | tee -a /var/log/amartinez_customimportexport.log | echo -e "Subject: MY STORE products daily update \\n\\n `cat`" | /usr/sbin/sendmail -f some@address.com foo@address.com,bar@address.com
637
 
638
  CREDITS
639
  I would be delighted to hear from you if you like this script. I also appreciate any donation you wish to contribute to the growth of this project (paypal: toniyecla [at] gmail [dot] com).
package.xml CHANGED
@@ -1,34 +1,34 @@
1
  <?xml version="1.0"?>
2
  <package>
3
  <name>AMartinez_CustomImportExport</name>
4
- <version>1.5.011</version>
5
  <stability>stable</stability>
6
  <license uri="http://opensource.org/licenses/osl-3.0">OSL v3.0</license>
7
  <channel>community</channel>
8
  <extends/>
9
  <summary>This extension can Import/Export products and customers from/to CSV file. Create categories, add attribute options, reindex, refresh cache, images and price rules automatically. In addition you can backup the entire database in SQL format.</summary>
10
- <description>This extension can Import/Export products and customers from/to CSV file. Create categories, add attribute options, reindex, refresh cache, images and price rules automatically. In addition you can backup the entire database in SQL format.&#xD;
11
- &#xD;
12
- It extends Mage_ImportExport class, so it is the most SCALABLE, SAFER and FASTER method exists.&#xD;
13
- &#xD;
14
- Imports:&#xD;
15
- (products, customers)&#xD;
16
- file.csv: multiple-row new csv files&#xD;
17
- (products)&#xD;
18
- file.csv1: single-row csv files, with some multivalued fields ("CAT1/CAT2,CAT3","ASSOCIATED1,ASSOCIATED2"...), you can define your own multivalued column names with * prefix ("sku","name","*_category","*_associated_sku"...)&#xD;
19
- &#xD;
20
- Exports:&#xD;
21
- (products, customers)&#xD;
22
- file.csv: multiple-row new csv files&#xD;
23
- (database)&#xD;
24
- backup all tables to SQL gz-compressed file&#xD;
25
- &#xD;
26
- To daily automatize imports, you must call "run.php" via crontab or similar.&#xD;
27
- &#xD;
28
- USE:&#xD;
29
- php -f app/code/community/AMartinez/CustomImportExport/shell/run.php&#xD;
30
- &#xD;
31
- php -f app/code/community/AMartinez/CustomImportExport/shell/run.php [-- [OPTIONS...]]&#xD;
32
  &#xD;
33
  OPTIONS&#xD;
34
  -h&#xD;
@@ -37,11 +37,11 @@ OPTIONS&#xD;
37
  &#xD;
38
  -a&#xD;
39
  -all&#xD;
40
- same as -c -f -p -r&#xD;
41
  &#xD;
42
  -b&#xD;
43
  -behavior&#xD;
44
- set import behavior: append|delete|replace (default)&#xD;
45
  &#xD;
46
  -c&#xD;
47
  -cleancache&#xD;
@@ -57,15 +57,21 @@ OPTIONS&#xD;
57
  &#xD;
58
  -db [file]&#xD;
59
  -databasebackup [file]&#xD;
60
- output whole magento database to sql file and try to gzcompress it, if output file not specified uses time generated name.&#xD;
61
- &#xD;
 
 
 
 
 
 
62
  -e [file]&#xD;
63
  -export [file]&#xD;
64
  output products to csv file, if output file not specified uses defined in config.xml&#xD;
65
  &#xD;
66
  -i [file]&#xD;
67
  -import [file]&#xD;
68
- import products from csv file, if source file not specified or not found uses defined in config.xml&#xD;
69
  &#xD;
70
  -f&#xD;
71
  -flushimages&#xD;
@@ -73,7 +79,7 @@ OPTIONS&#xD;
73
  &#xD;
74
  -l &lt;n&gt;&#xD;
75
  -linecount &lt;n&gt;&#xD;
76
- split import file into pieces of n lines length&#xD;
77
  &#xD;
78
  -p&#xD;
79
  -applyrules&#xD;
@@ -84,20 +90,32 @@ OPTIONS&#xD;
84
  reindex data by all indexers (attributes, prices, etc)&#xD;
85
  &#xD;
86
  EXAMPLES&#xD;
87
- php -f app/code/community/AMartinez/CustomImportExport/shell/run.php -- -import var/importexport/products.csv&#xD;
88
- php -f app/code/community/AMartinez/CustomImportExport/shell/run.php -- -all&#xD;
89
- php -f app/code/community/AMartinez/CustomImportExport/shell/run.php -- -a -i var/importexport/products.csv&#xD;
90
- php -f app/code/community/AMartinez/CustomImportExport/shell/run.php -- -e var/importexport/products.csv&#xD;
91
- php -f app/code/community/AMartinez/CustomImportExport/shell/run.php -- -databasebackup -import -all&#xD;
92
- &#xD;
 
 
 
 
 
 
 
 
 
 
 
 
 
93
  CREDITS&#xD;
94
- I would be delighted to hear from you if you like this script. I also appreciate any donation you wish to contribute to the growth of this project (paypal: toniyecla [at] gmail [dot] com).&#xD;
95
- </description>
96
  <notes>Magento 1.5 version.</notes>
97
  <authors><author><name>Antonio Martinez</name><user>amartinez</user><email>toniyecla@gmail.com</email></author></authors>
98
- <date>2011-05-24</date>
99
- <time>09:10:30</time>
100
- <contents><target name="magecommunity"><dir name="AMartinez"><dir name="CustomImportExport"><dir name="Helper"><file name="Data.php" hash="798c6c9b7adc8e5a66c8d00d7d475485"/></dir><dir name="Model"><file name="Backup.php" hash="0e673d6ab8a39f33bd1185b6627fb742"/><file name="Export.php" hash="252ef36d1b5e93e9f38e8d45dd72b030"/><dir name="Import"><dir name="Adapter"><file name="Csv1.php" hash="0f3cd525811041fedeaf1234719d9485"/></dir><file name="Adapter.php" hash="b2ddc64699cab599061789ff066faf11"/><dir name="Entity"><dir name="Customer"><file name="Address.php" hash="e06e286e132d4d2ec8548ebc66f257e1"/></dir><file name="Customer.php" hash="555a87242f1a613629c5d14bde5d23b8"/><dir name="Product"><dir name="Type"><file name="Configurable.php" hash="88c4c1db1c38ad8ae5a310ee19c87eee"/><file name="Grouped.php" hash="cfebd1d4520c25776ea02d2f3b980a82"/><file name="Simple.php" hash="a58046af6ab03b3a10f0ae575abf3a27"/></dir></dir><file name="Product.php" hash="4fa62cf9a2206d161f8135cf1908e305"/></dir></dir><file name="Import.php" hash="6d182eb456ea8785d0571f640efbdaac"/></dir><dir name="etc"><file name="config.xml" hash="da233e3a255d676f364f41605a67d837"/></dir><dir name="shell"><file name="run.php" hash="4501bd199a6097ca3a29b442cb8f03d0"/></dir></dir></dir></target><target name="mageetc"><dir name="modules"><file name="AMartinez_CustomImportExport.xml" hash="75ba4fbc265d1cf2b6ab61b8f3a3b95e"/></dir></target><target name="mage"><dir name="var"><dir name="customimportexport"><file name="test_configurable.csv" hash="d0447d047ef94f2f65a9fd375348cd39"/><file name="test_grouped.csv" hash="9c76b71b05c8e2b52efae4725f4119a4"/><file name="test_multiple_stores.csv1" hash="72c5977fcac5ce7ae433cf2f4f09c6d2"/><file name="test_single_row_style.csv1" hash="ac873b64867a36641fdd84297897dff5"/></dir></dir></target></contents>
101
  <compatible/>
102
  <dependencies><required><php><min>5.2.0</min><max>6.0.0</max></php></required></dependencies>
103
  </package>
1
  <?xml version="1.0"?>
2
  <package>
3
  <name>AMartinez_CustomImportExport</name>
4
+ <version>1.5.013</version>
5
  <stability>stable</stability>
6
  <license uri="http://opensource.org/licenses/osl-3.0">OSL v3.0</license>
7
  <channel>community</channel>
8
  <extends/>
9
  <summary>This extension can Import/Export products and customers from/to CSV file. Create categories, add attribute options, reindex, refresh cache, images and price rules automatically. In addition you can backup the entire database in SQL format.</summary>
10
+ <description> This extension can Import/Export products and customers from/to CSV file. Create categories, add attribute options, reindex, refresh cache, images and price rules automatically. In addition you can backup the entire database in SQL format.&#xD;
11
+ &#xD;
12
+ Imports:&#xD;
13
+ (products, customers)&#xD;
14
+ file.csv: multiple-row csv files, supports multiselect fields&#xD;
15
+ (products)&#xD;
16
+ file.csv1: single-row csv files, supports multiselect and multivalued fields&#xD;
17
+ &#xD;
18
+ Multivalued fields:&#xD;
19
+ You can define your own multivalued column names simply by putting an asterisk as a prefix, ie:&#xD;
20
+ sku ,*_category ,*_associated_sku&#xD;
21
+ TEST,"CAT1/CAT2,CAT3","ASSOCIATED1,ASSOCIATED2"&#xD;
22
+ &#xD;
23
+ Multiselect fields:&#xD;
24
+ Use commas to separate values, but make sure not to put asterisks in column header, ie:&#xD;
25
+ sku ,*_category ,color&#xD;
26
+ TEST,"CAT1/CAT2,CAT3","red,yellow"&#xD;
27
+ Exports:&#xD;
28
+ (products, customers)&#xD;
29
+ file.csv: multiple-row new csv files (no support for multiselect)&#xD;
30
+ (database)&#xD;
31
+ backup all tables to SQL gz-compressed file&#xD;
32
  &#xD;
33
  OPTIONS&#xD;
34
  -h&#xD;
37
  &#xD;
38
  -a&#xD;
39
  -all&#xD;
40
+ same as -c -f -p -r options&#xD;
41
  &#xD;
42
  -b&#xD;
43
  -behavior&#xD;
44
+ set import behavior for csv file: append|delete|replace (default)&#xD;
45
  &#xD;
46
  -c&#xD;
47
  -cleancache&#xD;
57
  &#xD;
58
  -db [file]&#xD;
59
  -databasebackup [file]&#xD;
60
+ output whole magento database to sql file and try to gzcompress it, if output file not specified uses time generated name&#xD;
61
+ &#xD;
62
+ -deleteallcustomers&#xD;
63
+ delete all customers (NOT from csv, entire magento database!)&#xD;
64
+ &#xD;
65
+ -deleteallproducts&#xD;
66
+ delete all products and non-root categories (NOT from csv, entire magento database!)&#xD;
67
+ &#xD;
68
  -e [file]&#xD;
69
  -export [file]&#xD;
70
  output products to csv file, if output file not specified uses defined in config.xml&#xD;
71
  &#xD;
72
  -i [file]&#xD;
73
  -import [file]&#xD;
74
+ import products from csv or csv1 file, if source file not specified or not found uses defined in config.xml. &#xD;
75
  &#xD;
76
  -f&#xD;
77
  -flushimages&#xD;
79
  &#xD;
80
  -l &lt;n&gt;&#xD;
81
  -linecount &lt;n&gt;&#xD;
82
+ split import file into pieces of n lines length ($tmp_folder must be writable)&#xD;
83
  &#xD;
84
  -p&#xD;
85
  -applyrules&#xD;
90
  reindex data by all indexers (attributes, prices, etc)&#xD;
91
  &#xD;
92
  EXAMPLES&#xD;
93
+ import&#xD;
94
+ php -f amartinez_customimportexport.php -- -all -import var/customimportexport/test_single_row_style.csv1&#xD;
95
+ &#xD;
96
+ export&#xD;
97
+ php -f amartinez_customimportexport.php -- -e &#xD;
98
+ &#xD;
99
+ reindex&#xD;
100
+ php -f amartinez_customimportexport.php -- -a&#xD;
101
+ &#xD;
102
+ backup, import, reindex&#xD;
103
+ php -f amartinez_customimportexport.php -- -databasebackup -import -all&#xD;
104
+ &#xD;
105
+ CRONTAB EXAMPLES&#xD;
106
+ # do tasks and send results by email&#xD;
107
+ 00 03 * * * root php -f /magento_base_dir/amartinez_customimportexport.php -- -db -a -i /magento_base_dir/var/customimportexport/products.csv1 2&gt;&amp;1 | xargs -0 -I msg echo -e "Subject: MY STORE products daily update \n\n " msg | /usr/sbin/sendmail -f some@address.com some@address.com&#xD;
108
+ &#xD;
109
+ # do tasks, append output to log file and send last results by email&#xD;
110
+ 00 05 * * * root php -f /magento_base_dir/amartinez_customimportexport.php -- -db -a -i /magento_base_dir/var/customimportexport/products.csv1 2&gt;&amp;1 | tee -a /var/log/amartinez_customimportexport.log | echo -e "Subject: MY STORE products daily update \n\n `cat`" | /usr/sbin/sendmail -f some@address.com foo@address.com,bar@address.com&#xD;
111
+ &#xD;
112
  CREDITS&#xD;
113
+ I would be delighted to hear from you if you like this script. I also appreciate any donation you wish to contribute to the growth of this project (paypal: toniyecla [at] gmail [dot] com).</description>
 
114
  <notes>Magento 1.5 version.</notes>
115
  <authors><author><name>Antonio Martinez</name><user>amartinez</user><email>toniyecla@gmail.com</email></author></authors>
116
+ <date>2011-06-29</date>
117
+ <time>11:10:13</time>
118
+ <contents><target name="magecommunity"><dir name="AMartinez"><dir name="CustomImportExport"><dir name="Helper"><file name="Data.php" hash="6a1c6b826659a6d9cfb5d5a1b3c85168"/></dir><dir name="Model"><file name="Backup.php" hash="a0f769bb010e38ba451f11ca90899e74"/><file name="Export.php" hash="012bef83aaf5c4e62de927aa7b8acbf5"/><dir name="Import"><dir name="Adapter"><file name="Csv1.php" hash="b39232d43c219b6a901c55a8d2dc4c7b"/></dir><file name="Adapter.php" hash="6a8c87e2f4554330292ae7b93b4f66af"/><dir name="Entity"><dir name="Customer"><file name="Address.php" hash="3d571fbb70d1c35a8ac11868bcb8b8e8"/></dir><file name="Customer.php" hash="91816741837b21528d5ccf11c8fd8647"/><dir name="Product"><dir name="Type"><file name="Configurable.php" hash="3de72a7db302db953a3ebbc7b7eb22e6"/><file name="Grouped.php" hash="2cf1c2454ab6a56100c60c8e892f9c36"/><file name="Simple.php" hash="c13ca8e9fdad8c7d4e9dfd68124da5da"/></dir></dir><file name="Product.php" hash="0af9523ad1cdd2784b108f47f4a06c1d"/></dir></dir><file name="Import.php" hash="26b08f6309d05645f136f72c4066f3ca"/></dir><dir name="etc"><file name="config.xml" hash="6db55f42d732e3df48c2c8e8f37f487b"/></dir><dir name="shell"><file name="run.php" hash="f95b52132581b2985f49a0c296e99761"/></dir></dir></dir></target><target name="mageetc"><dir name="modules"><file name="AMartinez_CustomImportExport.xml" hash="75ba4fbc265d1cf2b6ab61b8f3a3b95e"/></dir></target><target name="mage"><dir name="var"><dir name="customimportexport"><file name="customers.csv" hash="684ec06e60c1e189e6f1e00e94f121b1"/><file name="test_configurable.csv" hash="d0447d047ef94f2f65a9fd375348cd39"/><file name="test_grouped.csv" hash="9c76b71b05c8e2b52efae4725f4119a4"/><file name="test_multiple_stores.csv1" hash="72c5977fcac5ce7ae433cf2f4f09c6d2"/><file name="test_multiselect.csv" hash="ab0a1407c4d91cfe38366fbe838349af"/><file name="test_single_row_style.csv1" hash="ac873b64867a36641fdd84297897dff5"/></dir></dir><dir name="."><file name="amartinez_customimportexport.php" hash="8ff31d32cd08a888178b2aa5112d4ed2"/></dir></target></contents>
119
  <compatible/>
120
  <dependencies><required><php><min>5.2.0</min><max>6.0.0</max></php></required></dependencies>
121
  </package>
var/customimportexport/customers.csv ADDED
@@ -0,0 +1 @@
 
1
+ email,_website,_store,website_id,store_id,created_in,prefix,firstname,middlename,lastname,suffix,group_id,dob,password_hash,taxvat,confirmation,created_at,gender,g2k_cliente,g2k_tercero,g2k_tarifa,g2k_agrupacion,password,_address_city,_address_company,_address_country_id,_address_fax,_address_firstname,_address_lastname,_address_middlename,_address_postcode,_address_prefix,_address_region,_address_street,_address_suffix,_address_telephone,_address_default_billing_,_address_default_shipping_
var/customimportexport/test_multiselect.csv ADDED
@@ -0,0 +1,29 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ "sku", "_type", "_product_websites", "_attribute_set", "news_from_date", "tipo_articulo", "_category", "status", "visibility", "weight", "is_in_stock", "qty", "color", "price", "delivery_date", "tax_class_id", "name", "short_description", "description", "_associated_sku", "image"
2
+ "TEST1-S1-35","simple","base","Default","2011-4-8","Shoes","TEST COLLECTION","1","1","1.10","1","999","white","43.90","1899-12-31","2","TEST1-S1 (35)","TEST COLLECTION","TEST COLLECTION",,
3
+ "TEST1-S1-36","simple","base","Default","2011-4-8","Shoes","TEST COLLECTION","1","1","1.10","1","999","white","43.90","1899-12-31","2","TEST1-S1 (36)","TEST COLLECTION","TEST COLLECTION",,
4
+ "TEST1-S1-37","simple","base","Default","2011-4-8","Shoes","TEST COLLECTION","1","1","1.10","1","999","white","43.90","1899-12-31","2","TEST1-S1 (37)","TEST COLLECTION","TEST COLLECTION",,
5
+ "TEST1-S1-38","simple","base","Default","2011-4-8","Shoes","TEST COLLECTION","1","1","1.10","1","999","white","43.90","1899-12-31","2","TEST1-S1 (38)","TEST COLLECTION","TEST COLLECTION",,
6
+ "TEST1-S1-39","simple","base","Default","2011-4-8","Shoes","TEST COLLECTION","1","1","1.10","1","999","white","43.90","1899-12-31","2","TEST1-S1 (39)","TEST COLLECTION","TEST COLLECTION",,
7
+ "TEST1-S1-40","simple","base","Default","2011-4-8","Shoes","TEST COLLECTION","1","1","1.10","1","999","black","43.90","1899-12-31","2","TEST1-S1 (40)","TEST COLLECTION","TEST COLLECTION",,
8
+ "TEST1-S1-41","simple","base","Default","2011-4-8","Shoes","TEST COLLECTION","1","1","1.10","1","999","blue","43.90","1899-12-31","2","TEST1-S1 (41)","TEST COLLECTION","TEST COLLECTION",,
9
+ "TEST1-S1-42","simple","base","Default","2011-4-8","Shoes","TEST COLLECTION","1","1","1.10","1","999","white,black,blue","43.90","1899-12-31","2","TEST1-S1 (42)","TEST COLLECTION","TEST COLLECTION",,
10
+ "TEST1-S1-43","simple","base","Default","2011-4-8","Shoes","TEST COLLECTION","1","1","1.10","1","999","white,black,blue","43.90","1899-12-31","2","TEST1-S1 (43)","TEST COLLECTION","TEST COLLECTION",,
11
+ "TEST1-S1-44","simple","base","Default","2011-4-8","Shoes","TEST COLLECTION","1","1","1.10","1","999","white,black,blue","43.90","1899-12-31","2","TEST1-S1 (44)","TEST COLLECTION","TEST COLLECTION",,
12
+ "TEST1-S1-45","simple","base","Default","2011-4-8","Shoes","TEST COLLECTION","1","1","1.10","1","999","white,black,blue","43.90","1899-12-31","2","TEST1-S1 (45)","TEST COLLECTION","TEST COLLECTION",,
13
+ "TEST1-S1-46","simple","base","Default","2011-4-8","Shoes","TEST COLLECTION","1","1","1.10","1","999","white","43.90","1899-12-31","2","TEST1-S1 (46)","TEST COLLECTION","TEST COLLECTION",,
14
+ "TEST1-S1-47","simple","base","Default","2011-4-8","Shoes","TEST COLLECTION","1","1","1.10","1","999","black","43.90","1899-12-31","2","TEST1-S1 (47)","TEST COLLECTION","TEST COLLECTION",,
15
+ "TEST1-S1-48","simple","base","Default","2011-4-8","Shoes","TEST COLLECTION","1","1","1.10","1","999","blue","43.90","1899-12-31","2","TEST1-S1 (48)","TEST COLLECTION","TEST COLLECTION",,
16
+ "TEST1-S1","grouped","base","Default","2011-4-8","Shoes","TEST COLLECTION","1","4","1.10","1","13986","white,black,blue","43.90","1899-12-31","2","TEST 1 ANTIK NEGRO, PISO TEST (WITH ZIP)","TEST COLLECTION","TEST COLLECTION","TEST1-S1-35","/img_articulos/TEST1-S1.jpg"
17
+ ,,,,,,"MALICIA",,,,,,,,,,,,,"TEST1-S1-36",
18
+ ,,,,,,,,,,,,,,,,,,,"TEST1-S1-37",
19
+ ,,,,,,,,,,,,,,,,,,,"TEST1-S1-38",
20
+ ,,,,,,,,,,,,,,,,,,,"TEST1-S1-39",
21
+ ,,,,,,,,,,,,,,,,,,,"TEST1-S1-40",
22
+ ,,,,,,,,,,,,,,,,,,,"TEST1-S1-41",
23
+ ,,,,,,,,,,,,,,,,,,,"TEST1-S1-42",
24
+ ,,,,,,,,,,,,,,,,,,,"TEST1-S1-43",
25
+ ,,,,,,,,,,,,,,,,,,,"TEST1-S1-44",
26
+ ,,,,,,,,,,,,,,,,,,,"TEST1-S1-45",
27
+ ,,,,,,,,,,,,,,,,,,,"TEST1-S1-46",
28
+ ,,,,,,,,,,,,,,,,,,,"TEST1-S1-47",
29
+ ,,,,,,,,,,,,,,,,,,,"TEST1-S1-48",