Version Notes
Magento 1.5+ version.
Download this release
Release Info
Developer | Antonio Martinez |
Extension | AMartinez_CustomImportExport |
Version | 1.5.014 |
Comparing to | |
See all releases |
Code changes from version 1.5.013 to 1.5.014
- app/code/community/AMartinez/CustomImportExport/Model/Import/Adapter/Csv1.php +2 -2
- app/code/community/AMartinez/CustomImportExport/Model/Import/Entity/Product.php +244 -1
- app/code/community/AMartinez/CustomImportExport/Model/Observer.php +24 -0
- app/code/community/AMartinez/CustomImportExport/etc/config.xml +10 -1
- app/code/community/AMartinez/CustomImportExport/shell/run.php +18 -5
- package.xml +21 -10
- var/customimportexport/test_media_gallery.csv1 +5 -0
- var/customimportexport/test_media_gallery_and_base_image.csv1 +5 -0
app/code/community/AMartinez/CustomImportExport/Model/Import/Adapter/Csv1.php
CHANGED
@@ -36,7 +36,7 @@ class AMartinez_CustomImportExport_Model_Import_Adapter_Csv1 extends Mage_Import
|
|
36 |
*/
|
37 |
protected $_fileHandler;
|
38 |
|
39 |
-
protected $_multiValuedColNames = array('_store', 'visibility', '_category', '_associated_sku');
|
40 |
protected $_values = array();
|
41 |
protected $_currentOffsetKey = 0;
|
42 |
protected $_maxOffsetKey = 0;
|
@@ -62,7 +62,7 @@ class AMartinez_CustomImportExport_Model_Import_Adapter_Csv1 extends Mage_Import
|
|
62 |
{
|
63 |
$this->_fileHandler = fopen($this->_source, 'r');
|
64 |
$this->rewind();
|
65 |
-
//echo ":::: " . Mage::helper('importexport')->__("Multivalued column names: ") . implode(',', $this->_multiValuedColNames) . " ::::\n";
|
66 |
|
67 |
return $this;
|
68 |
}
|
36 |
*/
|
37 |
protected $_fileHandler;
|
38 |
|
39 |
+
protected $_multiValuedColNames = array('_store', 'visibility', '_category', '_associated_sku', '_media_image', '_media_attribute_id', '_media_label', '_media_position', '_media_is_disabled');
|
40 |
protected $_values = array();
|
41 |
protected $_currentOffsetKey = 0;
|
42 |
protected $_maxOffsetKey = 0;
|
62 |
{
|
63 |
$this->_fileHandler = fopen($this->_source, 'r');
|
64 |
$this->rewind();
|
65 |
+
// echo ":::: " . Mage::helper('importexport')->__("Multivalued column names: ") . implode(',', $this->_multiValuedColNames) . " ::::\n";
|
66 |
|
67 |
return $this;
|
68 |
}
|
app/code/community/AMartinez/CustomImportExport/Model/Import/Entity/Product.php
CHANGED
@@ -90,7 +90,250 @@ class AMartinez_CustomImportExport_Model_Import_Entity_Product extends Mage_Impo
|
|
90 |
|
91 |
protected $entity_type_id;
|
92 |
protected $eav_entity_setup;
|
93 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
94 |
/**
|
95 |
* Add attribute option
|
96 |
*
|
90 |
|
91 |
protected $entity_type_id;
|
92 |
protected $eav_entity_setup;
|
93 |
+
|
94 |
+
protected $_particularAttributes = array(
|
95 |
+
'_store', '_attribute_set', '_type', '_category', '_product_websites', '_tier_price_website',
|
96 |
+
'_tier_price_customer_group', '_tier_price_qty', '_tier_price_price', '_links_related_sku',
|
97 |
+
'_links_related_position', '_links_crosssell_sku', '_links_crosssell_position', '_links_upsell_sku',
|
98 |
+
'_links_upsell_position', '_custom_option_store', '_custom_option_type', '_custom_option_title',
|
99 |
+
'_custom_option_is_required', '_custom_option_price', '_custom_option_sku', '_custom_option_max_characters',
|
100 |
+
'_custom_option_sort_order', '_custom_option_file_extension', '_custom_option_image_size_x',
|
101 |
+
'_custom_option_image_size_y', '_custom_option_row_title', '_custom_option_row_price',
|
102 |
+
'_custom_option_row_sku', '_custom_option_row_sort', '_media_image', '_media_attribute_id', '_media_label',
|
103 |
+
'_media_position', '_media_is_disabled'
|
104 |
+
);
|
105 |
+
|
106 |
+
// , 'image', 'small_image', 'thumbnail'
|
107 |
+
protected $_imagesArrayKeys = array(
|
108 |
+
'_media_image', 'image', 'small_image', 'thumbnail'
|
109 |
+
);
|
110 |
+
|
111 |
+
/**
|
112 |
+
* Save product media gallery.
|
113 |
+
*/
|
114 |
+
protected function _saveMediaGallery(array $mediaGalleryData)
|
115 |
+
{
|
116 |
+
if (empty($mediaGalleryData)) {
|
117 |
+
return $this;
|
118 |
+
}
|
119 |
+
|
120 |
+
static $mediaGalleryTableName = null;
|
121 |
+
static $mediaValueTableName = null;
|
122 |
+
static $productId = null;
|
123 |
+
|
124 |
+
if (!$mediaGalleryTableName) {
|
125 |
+
$mediaGalleryTableName = Mage::getModel('importexport/import_proxy_product_resource')
|
126 |
+
->getTable('catalog/product_attribute_media_gallery');
|
127 |
+
}
|
128 |
+
|
129 |
+
if (!$mediaValueTableName) {
|
130 |
+
$mediaValueTableName = Mage::getModel('importexport/import_proxy_product_resource')
|
131 |
+
->getTable('catalog/product_attribute_media_gallery_value');
|
132 |
+
}
|
133 |
+
|
134 |
+
foreach ($mediaGalleryData as $productSku => $mediaGalleryRows) {
|
135 |
+
$productId = $this->_newSku[$productSku]['entity_id'];
|
136 |
+
$insertedGalleryImgs = array();
|
137 |
+
|
138 |
+
if (Mage_ImportExport_Model_Import::BEHAVIOR_APPEND != $this->getBehavior()) {
|
139 |
+
$this->_connection->delete(
|
140 |
+
$mediaGalleryTableName,
|
141 |
+
$this->_connection->quoteInto('entity_id IN (?)', $productId)
|
142 |
+
);
|
143 |
+
}
|
144 |
+
|
145 |
+
foreach ($mediaGalleryRows as $insertValue) {
|
146 |
+
|
147 |
+
if (!in_array($insertValue['value'], $insertedGalleryImgs)) {
|
148 |
+
$valueArr = array(
|
149 |
+
'attribute_id' => $insertValue['attribute_id'],
|
150 |
+
'entity_id' => $productId,
|
151 |
+
'value' => $insertValue['value']
|
152 |
+
);
|
153 |
+
|
154 |
+
$this->_connection
|
155 |
+
->insertOnDuplicate($mediaGalleryTableName, $valueArr, array('entity_id'));
|
156 |
+
|
157 |
+
$insertedGalleryImgs[] = $insertValue['value'];
|
158 |
+
}
|
159 |
+
|
160 |
+
$newMediaValues = $this->_connection->fetchPairs($this->_connection->select()
|
161 |
+
->from($mediaGalleryTableName, array('value', 'value_id'))
|
162 |
+
->where('entity_id IN (?)', $productId)
|
163 |
+
);
|
164 |
+
|
165 |
+
if (array_key_exists($insertValue['value'], $newMediaValues)) {
|
166 |
+
$insertValue['value_id'] = $newMediaValues[$insertValue['value']];
|
167 |
+
}
|
168 |
+
|
169 |
+
$valueArr = array(
|
170 |
+
'value_id' => $insertValue['value_id'],
|
171 |
+
'store_id' => Mage_Catalog_Model_Abstract::DEFAULT_STORE_ID,
|
172 |
+
'label' => $insertValue['label'],
|
173 |
+
'position' => $insertValue['position'],
|
174 |
+
'disabled' => $insertValue['disabled']
|
175 |
+
);
|
176 |
+
|
177 |
+
try {
|
178 |
+
$this->_connection
|
179 |
+
->insertOnDuplicate($mediaValueTableName, $valueArr, array('value_id'));
|
180 |
+
} catch (Exception $e) {
|
181 |
+
$this->_connection->delete(
|
182 |
+
$mediaGalleryTableName, $this->_connection->quoteInto('value_id IN (?)', $newMediaValues)
|
183 |
+
);
|
184 |
+
}
|
185 |
+
}
|
186 |
+
}
|
187 |
+
|
188 |
+
return $this;
|
189 |
+
}
|
190 |
+
|
191 |
+
/**
|
192 |
+
* Gather and save information about product entities.
|
193 |
+
*/
|
194 |
+
protected function _saveProducts()
|
195 |
+
{
|
196 |
+
/** @var $resource Mage_ImportExport_Model_Import_Proxy_Product_Resource */
|
197 |
+
$resource = Mage::getModel('importexport/import_proxy_product_resource');
|
198 |
+
$priceIsGlobal = Mage::helper('catalog')->isPriceGlobal();
|
199 |
+
$strftimeFormat = Varien_Date::convertZendToStrftime(Varien_Date::DATETIME_INTERNAL_FORMAT, true, true);
|
200 |
+
$productLimit = null;
|
201 |
+
$productsQty = null;
|
202 |
+
|
203 |
+
while ($bunch = $this->_dataSourceModel->getNextBunch()) {
|
204 |
+
$entityRowsIn = array();
|
205 |
+
$entityRowsUp = array();
|
206 |
+
$attributes = array();
|
207 |
+
$websites = array();
|
208 |
+
$categories = array();
|
209 |
+
$tierPrices = array();
|
210 |
+
$mediaGallery = array();
|
211 |
+
$uploadedGalleryFiles = array();
|
212 |
+
|
213 |
+
foreach ($bunch as $rowNum => $rowData) {
|
214 |
+
if (!$this->validateRow($rowData, $rowNum)) {
|
215 |
+
continue;
|
216 |
+
}
|
217 |
+
$rowScope = $this->getRowScope($rowData);
|
218 |
+
|
219 |
+
if (self::SCOPE_DEFAULT == $rowScope) {
|
220 |
+
$rowSku = $rowData[self::COL_SKU];
|
221 |
+
|
222 |
+
// 1. Entity phase
|
223 |
+
if (isset($this->_oldSku[$rowSku])) { // existing row
|
224 |
+
$entityRowsUp[] = array(
|
225 |
+
'updated_at' => now(),
|
226 |
+
'entity_id' => $this->_oldSku[$rowSku]['entity_id']
|
227 |
+
);
|
228 |
+
} else { // new row
|
229 |
+
if (!$productLimit || $productsQty < $productLimit) {
|
230 |
+
$entityRowsIn[$rowSku] = array(
|
231 |
+
'entity_type_id' => $this->_entityTypeId,
|
232 |
+
'attribute_set_id' => $this->_newSku[$rowSku]['attr_set_id'],
|
233 |
+
'type_id' => $this->_newSku[$rowSku]['type_id'],
|
234 |
+
'sku' => $rowSku,
|
235 |
+
'created_at' => now(),
|
236 |
+
'updated_at' => now()
|
237 |
+
);
|
238 |
+
$productsQty++;
|
239 |
+
} else {
|
240 |
+
$rowSku = null; // sign for child rows to be skipped
|
241 |
+
$this->_rowsToSkip[$rowNum] = true;
|
242 |
+
continue;
|
243 |
+
}
|
244 |
+
}
|
245 |
+
} elseif (null === $rowSku) {
|
246 |
+
$this->_rowsToSkip[$rowNum] = true;
|
247 |
+
continue; // skip rows when SKU is NULL
|
248 |
+
} elseif (self::SCOPE_STORE == $rowScope) { // set necessary data from SCOPE_DEFAULT row
|
249 |
+
$rowData[self::COL_TYPE] = $this->_newSku[$rowSku]['type_id'];
|
250 |
+
$rowData['attribute_set_id'] = $this->_newSku[$rowSku]['attr_set_id'];
|
251 |
+
$rowData[self::COL_ATTR_SET] = $this->_newSku[$rowSku]['attr_set_code'];
|
252 |
+
}
|
253 |
+
if (!empty($rowData['_product_websites'])) { // 2. Product-to-Website phase
|
254 |
+
$websites[$rowSku][$this->_websiteCodeToId[$rowData['_product_websites']]] = true;
|
255 |
+
}
|
256 |
+
if (!empty($rowData[self::COL_CATEGORY])) { // 3. Categories phase
|
257 |
+
$categories[$rowSku][$this->_categories[$rowData[self::COL_CATEGORY]]] = true;
|
258 |
+
}
|
259 |
+
if (!empty($rowData['_tier_price_website'])) { // 4. Tier prices phase
|
260 |
+
$tierPrices[$rowSku][] = array(
|
261 |
+
'all_groups' => $rowData['_tier_price_customer_group'] == self::VALUE_ALL,
|
262 |
+
'customer_group_id' => $rowData['_tier_price_customer_group'] == self::VALUE_ALL ?
|
263 |
+
0 : $rowData['_tier_price_customer_group'],
|
264 |
+
'qty' => $rowData['_tier_price_qty'],
|
265 |
+
'value' => $rowData['_tier_price_price'],
|
266 |
+
'website_id' => self::VALUE_ALL == $rowData['_tier_price_website'] || $priceIsGlobal ?
|
267 |
+
0 : $this->_websiteCodeToId[$rowData['_tier_price_website']]
|
268 |
+
);
|
269 |
+
}
|
270 |
+
// Media gallery phase
|
271 |
+
foreach ($this->_imagesArrayKeys as $imageCol) {
|
272 |
+
if (!empty($rowData[$imageCol])) {
|
273 |
+
if (!array_key_exists($rowData[$imageCol], $uploadedGalleryFiles)) {
|
274 |
+
// Mage::getConfig()->getOptions()->getMediaDir() . '/catalog/product' .
|
275 |
+
$uploadedGalleryFiles[$rowData[$imageCol]] = $rowData[$imageCol];
|
276 |
+
}
|
277 |
+
$rowData[$imageCol] = $uploadedGalleryFiles[$rowData[$imageCol]];
|
278 |
+
}
|
279 |
+
}
|
280 |
+
|
281 |
+
if (!empty($rowData['_media_image'])) {
|
282 |
+
$mediaGallery[$rowSku][] = array(
|
283 |
+
'attribute_id' => $rowData['_media_attribute_id'],
|
284 |
+
'label' => $rowData['_media_label'],
|
285 |
+
'position' => $rowData['_media_position'],
|
286 |
+
'disabled' => $rowData['_media_is_disabled'],
|
287 |
+
'value' => $rowData['_media_image']
|
288 |
+
);
|
289 |
+
}
|
290 |
+
// 5. Attributes phase
|
291 |
+
if (self::SCOPE_NULL == $rowScope) {
|
292 |
+
continue; // skip attribute processing for SCOPE_NULL rows
|
293 |
+
}
|
294 |
+
$rowStore = self::SCOPE_STORE == $rowScope ? $this->_storeCodeToId[$rowData[self::COL_STORE]] : 0;
|
295 |
+
$rowData = $this->_productTypeModels[$rowData[self::COL_TYPE]]->prepareAttributesForSave($rowData);
|
296 |
+
$product = Mage::getModel('importexport/import_proxy_product', $rowData);
|
297 |
+
|
298 |
+
foreach ($rowData as $attrCode => $attrValue) {
|
299 |
+
$attribute = $resource->getAttribute($attrCode);
|
300 |
+
$attrId = $attribute->getId();
|
301 |
+
$backModel = $attribute->getBackendModel();
|
302 |
+
$attrTable = $attribute->getBackend()->getTable();
|
303 |
+
$storeIds = array(0);
|
304 |
+
|
305 |
+
if ('datetime' == $attribute->getBackendType()) {
|
306 |
+
$attrValue = gmstrftime($strftimeFormat, strtotime($attrValue));
|
307 |
+
} elseif ($backModel) {
|
308 |
+
$attribute->getBackend()->beforeSave($product);
|
309 |
+
$attrValue = $product->getData($attribute->getAttributeCode());
|
310 |
+
}
|
311 |
+
if (self::SCOPE_STORE == $rowScope) {
|
312 |
+
if (self::SCOPE_WEBSITE == $attribute->getIsGlobal()) {
|
313 |
+
// check website defaults already set
|
314 |
+
if (!isset($attributes[$attrTable][$rowSku][$attrId][$rowStore])) {
|
315 |
+
$storeIds = $this->_storeIdToWebsiteStoreIds[$rowStore];
|
316 |
+
}
|
317 |
+
} elseif (self::SCOPE_STORE == $attribute->getIsGlobal()) {
|
318 |
+
$storeIds = array($rowStore);
|
319 |
+
}
|
320 |
+
}
|
321 |
+
foreach ($storeIds as $storeId) {
|
322 |
+
$attributes[$attrTable][$rowSku][$attrId][$storeId] = $attrValue;
|
323 |
+
}
|
324 |
+
$attribute->setBackendModel($backModel); // restore 'backend_model' to avoid 'default' setting
|
325 |
+
}
|
326 |
+
}
|
327 |
+
$this->_saveProductEntity($entityRowsIn, $entityRowsUp)
|
328 |
+
->_saveProductWebsites($websites)
|
329 |
+
->_saveProductCategories($categories)
|
330 |
+
->_saveProductTierPrices($tierPrices)
|
331 |
+
->_saveMediaGallery($mediaGallery)
|
332 |
+
->_saveProductAttributes($attributes);
|
333 |
+
}
|
334 |
+
return $this;
|
335 |
+
}
|
336 |
+
|
337 |
/**
|
338 |
* Add attribute option
|
339 |
*
|
app/code/community/AMartinez/CustomImportExport/Model/Observer.php
ADDED
@@ -0,0 +1,24 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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 |
+
class AMartinez_CustomImportExport_Model_Observer
|
13 |
+
{
|
14 |
+
public function dispatch($schedule)
|
15 |
+
{
|
16 |
+
// print_r($schedule['executed_at']);
|
17 |
+
|
18 |
+
// $_SERVER['argv'] = array('-c', '-p', '-r', '-l', '5000', '-i', '/var/www/html/newrockworld/store/var/customimportexport/productos.csv1');
|
19 |
+
// $_SERVER['argv'] = array('-f');
|
20 |
+
// require_once 'app/code/community/AMartinez/CustomImportExport/shell/run.php';
|
21 |
+
|
22 |
+
return $this;
|
23 |
+
}
|
24 |
+
}
|
app/code/community/AMartinez/CustomImportExport/etc/config.xml
CHANGED
@@ -14,7 +14,7 @@
|
|
14 |
|
15 |
<modules>
|
16 |
<AMartinez_CustomImportExport>
|
17 |
-
<version>1.5.
|
18 |
<depends>
|
19 |
<!-- no dependencies -->
|
20 |
</depends>
|
@@ -55,6 +55,15 @@
|
|
55 |
</importexport>
|
56 |
</global>
|
57 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
58 |
<default>
|
59 |
<customimportexport>
|
60 |
<products>
|
14 |
|
15 |
<modules>
|
16 |
<AMartinez_CustomImportExport>
|
17 |
+
<version>1.5.014</version>
|
18 |
<depends>
|
19 |
<!-- no dependencies -->
|
20 |
</depends>
|
55 |
</importexport>
|
56 |
</global>
|
57 |
|
58 |
+
<crontab>
|
59 |
+
<jobs>
|
60 |
+
<amartinez_customimportexport>
|
61 |
+
<schedule><cron_expr>0,30 * * * *</cron_expr></schedule>
|
62 |
+
<run><model>customimportexport/observer::dispatch</model></run>
|
63 |
+
</amartinez_customimportexport>
|
64 |
+
</jobs>
|
65 |
+
</crontab>
|
66 |
+
|
67 |
<default>
|
68 |
<customimportexport>
|
69 |
<products>
|
app/code/community/AMartinez/CustomImportExport/shell/run.php
CHANGED
@@ -24,13 +24,13 @@ class AMartinez_CustomImportExport extends Mage_Shell_Abstract
|
|
24 |
{
|
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)
|
32 |
{
|
33 |
-
|
|
|
34 |
}
|
35 |
|
36 |
// database export
|
@@ -252,6 +252,8 @@ class AMartinez_CustomImportExport extends Mage_Shell_Abstract
|
|
252 |
{
|
253 |
Mage::helper('customimportexport')->cleanCache();
|
254 |
}
|
|
|
|
|
255 |
}
|
256 |
|
257 |
/**
|
@@ -523,7 +525,7 @@ class AMartinez_CustomImportExport extends Mage_Shell_Abstract
|
|
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.
|
527 |
|
528 |
NAME
|
529 |
run.php
|
@@ -533,7 +535,7 @@ SYNOPSIS
|
|
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,
|
537 |
|
538 |
Imports:
|
539 |
(products, customers)
|
@@ -542,7 +544,17 @@ DESCRIPTION
|
|
542 |
file.csv1: single-row csv files, supports multiselect and multivalued fields
|
543 |
|
544 |
Multivalued fields:
|
545 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
546 |
sku ,*_category ,*_associated_sku
|
547 |
TEST,"CAT1/CAT2,CAT3","ASSOCIATED1,ASSOCIATED2"
|
548 |
|
@@ -550,6 +562,7 @@ DESCRIPTION
|
|
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)
|
24 |
{
|
25 |
Mage::setIsDeveloperMode(true);
|
26 |
ini_set('display_errors', 1);
|
|
|
27 |
echo "\n";
|
28 |
|
29 |
// help
|
30 |
if ($this->getArg('h') || $this->getArg('help') || count($this->_args) == 0)
|
31 |
{
|
32 |
+
echo $this->usageHelp();
|
33 |
+
return 1;
|
34 |
}
|
35 |
|
36 |
// database export
|
252 |
{
|
253 |
Mage::helper('customimportexport')->cleanCache();
|
254 |
}
|
255 |
+
|
256 |
+
return 0;
|
257 |
}
|
258 |
|
259 |
/**
|
525 |
$tmp_folder = substr(Mage::getConfig()->getOptions()->getTmpDir(), strlen(Mage::getConfig()->getOptions()->getBaseDir()) + 1);
|
526 |
|
527 |
return <<<HELP
|
528 |
+
AMartinez_CustomImportExport script (v. 1.5.014)
|
529 |
|
530 |
NAME
|
531 |
run.php
|
535 |
php -f amartinez_customimportexport.php [-- [OPTIONS...]]
|
536 |
|
537 |
DESCRIPTION
|
538 |
+
This extension can Import/Export products and customers from/to CSV file. Create categories, add attribute options, import images and media galleries, reindex, refresh cache, media and price rules automatically. In addition you can backup the entire database in SQL format
|
539 |
|
540 |
Imports:
|
541 |
(products, customers)
|
544 |
file.csv1: single-row csv files, supports multiselect and multivalued fields
|
545 |
|
546 |
Multivalued fields:
|
547 |
+
Only with CSV1 files, these fields are automatically processed as multivalued:
|
548 |
+
_store
|
549 |
+
visibility
|
550 |
+
_category
|
551 |
+
_associated_sku
|
552 |
+
_media_image
|
553 |
+
_media_attribute_id
|
554 |
+
_media_label
|
555 |
+
_media_position
|
556 |
+
_media_is_disabled
|
557 |
+
To define your own ones, use * (this overrides default values)
|
558 |
sku ,*_category ,*_associated_sku
|
559 |
TEST,"CAT1/CAT2,CAT3","ASSOCIATED1,ASSOCIATED2"
|
560 |
|
562 |
Use commas to separate values, but make sure not to put asterisks in column header, ie:
|
563 |
sku ,*_category ,color
|
564 |
TEST,"CAT1/CAT2,CAT3","red,yellow"
|
565 |
+
|
566 |
Exports:
|
567 |
(products, customers)
|
568 |
file.csv: multiple-row new csv files (no support for multiselect)
|
package.xml
CHANGED
@@ -1,13 +1,13 @@
|
|
1 |
<?xml version="1.0"?>
|
2 |
<package>
|
3 |
<name>AMartinez_CustomImportExport</name>
|
4 |
-
<version>1.5.
|
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>
|
10 |
-
<description> This extension can Import/Export products and customers from/to CSV file. Create categories, add attribute options, reindex, refresh cache,
|
11 |

|
12 |
Imports:
|
13 |
(products, customers)
|
@@ -16,7 +16,17 @@
|
|
16 |
file.csv1: single-row csv files, supports multiselect and multivalued fields
|
17 |

|
18 |
Multivalued fields:
|
19 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
20 |
sku ,*_category ,*_associated_sku
|
21 |
TEST,"CAT1/CAT2,CAT3","ASSOCIATED1,ASSOCIATED2"
|
22 |

|
@@ -24,6 +34,7 @@
|
|
24 |
Use commas to separate values, but make sure not to put asterisks in column header, ie:
|
25 |
sku ,*_category ,color
|
26 |
TEST,"CAT1/CAT2,CAT3","red,yellow"
|
|
|
27 |
Exports:
|
28 |
(products, customers)
|
29 |
file.csv: multiple-row new csv files (no support for multiselect)
|
@@ -104,18 +115,18 @@ EXAMPLES
|
|
104 |

|
105 |
CRONTAB EXAMPLES
|
106 |
# do tasks and send results by email
|
107 |
-
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
|
108 |

|
109 |
# do tasks, append output to log file and send last results by email
|
110 |
-
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
|
111 |

|
112 |
CREDITS
|
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-
|
117 |
-
<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="
|
119 |
<compatible/>
|
120 |
<dependencies><required><php><min>5.2.0</min><max>6.0.0</max></php></required></dependencies>
|
121 |
</package>
|
1 |
<?xml version="1.0"?>
|
2 |
<package>
|
3 |
<name>AMartinez_CustomImportExport</name>
|
4 |
+
<version>1.5.014</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>Import/Export products/customers from/to CSV file. Create categories, add attribute options, import images and media galleries, reindex, refresh cache, media 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, import images and media galleries, reindex, refresh cache, media and price rules automatically. In addition you can backup the entire database in SQL format
|
11 |

|
12 |
Imports:
|
13 |
(products, customers)
|
16 |
file.csv1: single-row csv files, supports multiselect and multivalued fields
|
17 |

|
18 |
Multivalued fields:
|
19 |
+
Only with CSV1 files, these fields are automatically processed as multivalued:
|
20 |
+
_store
|
21 |
+
visibility
|
22 |
+
_category
|
23 |
+
_associated_sku
|
24 |
+
_media_image
|
25 |
+
_media_attribute_id
|
26 |
+
_media_label
|
27 |
+
_media_position
|
28 |
+
_media_is_disabled
|
29 |
+
To define your own ones, use * (this overrides default values)
|
30 |
sku ,*_category ,*_associated_sku
|
31 |
TEST,"CAT1/CAT2,CAT3","ASSOCIATED1,ASSOCIATED2"
|
32 |

|
34 |
Use commas to separate values, but make sure not to put asterisks in column header, ie:
|
35 |
sku ,*_category ,color
|
36 |
TEST,"CAT1/CAT2,CAT3","red,yellow"
|
37 |
+

|
38 |
Exports:
|
39 |
(products, customers)
|
40 |
file.csv: multiple-row new csv files (no support for multiselect)
|
115 |

|
116 |
CRONTAB EXAMPLES
|
117 |
# do tasks and send results by email
|
118 |
+
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
|
119 |

|
120 |
# do tasks, append output to log file and send last results by email
|
121 |
+
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
|
122 |

|
123 |
CREDITS
|
124 |
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>
|
125 |
+
<notes>Magento 1.5+ version.</notes>
|
126 |
<authors><author><name>Antonio Martinez</name><user>amartinez</user><email>toniyecla@gmail.com</email></author></authors>
|
127 |
+
<date>2011-07-07</date>
|
128 |
+
<time>17:03:47</time>
|
129 |
+
<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="e3b90832370f3b06887ab21eb56dd31c"/></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="38ee5b54a6f2a1ca96fd1647202a58e0"/></dir></dir><file name="Import.php" hash="26b08f6309d05645f136f72c4066f3ca"/><file name="Observer.php" hash="2d492e96eab67dc3f9165b6229c71ff4"/></dir><dir name="etc"><file name="config.xml" hash="7e1f6273b775425763bab04cbc0a475e"/></dir><dir name="shell"><file name="run.php" hash="4a168a408926a5484a16f064c9d419e1"/></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_media_gallery.csv1" hash="dfcff5065f6c51fec8f00a40a7527fd7"/><file name="test_media_gallery_and_base_image.csv1" hash="0ee58ee5d04db59b9853691622ecf59a"/><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>
|
130 |
<compatible/>
|
131 |
<dependencies><required><php><min>5.2.0</min><max>6.0.0</max></php></required></dependencies>
|
132 |
</package>
|
var/customimportexport/test_media_gallery.csv1
ADDED
@@ -0,0 +1,5 @@
|
|
|
|
|
|
|
|
|
|
|
1 |
+
"sku", "_store", "_type", "_product_websites", "_attribute_set", "news_from_date", "tipo_articulo", "_category", "status", "visibility", "weight", "is_in_stock", "qty", "size", "price", "delivery_date", "tax_class_id", "name", "short_description", "description", "_associated_sku", "image", "small_image", "thumbnail", "_media_image", "_media_attribute_id", "_media_label", "_media_position", "_media_is_disabled"
|
2 |
+
"TEST1-S1-35",,"simple","base","Default","2011-4-8","Shoes","TEST COLLECTION","1","1","1.10","1","999","35","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","36","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","37","43.90","1899-12-31","2","TEST1-S1 (37)","TEST COLLECTION","TEST COLLECTION",,,,,,,,,
|
5 |
+
"TEST1-S1",,"grouped","base","Default","2011-4-8","Shoes","TEST COLLECTION/SUBTEST,MALICIA","1","4","1.10","1","13986","","43.90","1899-12-31","2","TEST 1 ANTIK NEGRO, PISO TEST test","TEST COLLECTION","TEST COLLECTION","TEST1-S1-35,TEST1-S1-36,TEST1-S1-37","/img_articulos/TEST1-S1.jpg","/img_articulos/TEST1-S1.jpg","/img_articulos/TEST1-S1.jpg","/img_articulos/TEST1-S2.jpg,/img_articulos/TEST1-S3.jpg,/img_articulos/TEST1-S4.jpg","77,77,77",,,
|
var/customimportexport/test_media_gallery_and_base_image.csv1
ADDED
@@ -0,0 +1,5 @@
|
|
|
|
|
|
|
|
|
|
|
1 |
+
"sku", "_store", "_type", "_product_websites", "_attribute_set", "news_from_date", "tipo_articulo", "_category", "status", "visibility", "weight", "is_in_stock", "qty", "size", "price", "delivery_date", "tax_class_id", "name", "short_description", "description", "_associated_sku", "image", "small_image", "thumbnail", "_media_image", "_media_attribute_id", "_media_label", "_media_position", "_media_is_disabled"
|
2 |
+
"TEST1-S1-35",,"simple","base","Default","2011-4-8","Shoes","TEST COLLECTION","1","1","1.10","1","999","35","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","36","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","37","43.90","1899-12-31","2","TEST1-S1 (37)","TEST COLLECTION","TEST COLLECTION",,,,,,,,,
|
5 |
+
"TEST1-S1",,"grouped","base","Default","2011-4-8","Shoes","TEST COLLECTION/SUBTEST,MALICIA","1","4","1.10","1","13986","","43.90","1899-12-31","2","TEST 1 ANTIK NEGRO, PISO TEST test","TEST COLLECTION","TEST COLLECTION","TEST1-S1-35,TEST1-S1-36,TEST1-S1-37","/img_articulos/TEST1-S1.jpg","/img_articulos/TEST1-S1.jpg","/img_articulos/TEST1-S1.jpg","/img_articulos/TEST1-S1.jpg,/img_articulos/TEST1-S2.jpg,/img_articulos/TEST1-S3.jpg,/img_articulos/TEST1-S4.jpg","77,77,77,77",,,
|