forked from avstudnitz/AvS_FastSimpleImport
-
Notifications
You must be signed in to change notification settings - Fork 0
/
test.php
77 lines (66 loc) · 1.92 KB
/
test.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
<?php
function getUniqueCode($length = "")
{
$code = md5(uniqid(rand(), true));
if ($length != "") return substr($code, 0, $length);
else return $code;
}
require_once 'src/app/Mage.php';
umask(0);
Mage::app()->setCurrentStore(Mage_Core_Model_App::ADMIN_STORE_ID);
ini_set('display_errors', 1);
ini_set('max_execution_time', 600);
/*
// Delete Products
$data = array();
for ($i = 1; $i <= 10; $i++) {
$data[] = array(
'sku' => $i,
);
}
$time = microtime(true);
Mage::getModel('fastsimpleimport/import')
->setPartialIndexing(true)
->setBehavior(Mage_ImportExport_Model_Import::BEHAVIOR_DELETE)
->processProductImport($data);
echo 'Elapsed time: ' . round(microtime(true) - $time, 2) . 's' . "\n";
*/
// Create/Update products
$data = array();
for ($i = 1; $i <= 10; $i++) {
$randomString = getUniqueCode(20);
$data[] = array(
'sku' => $i,
'_type' => 'simple',
'_attribute_set' => 'Default',
'_product_websites' => 'base',
'_category' => array(1, 3),
'name' => $randomString,
'price' => 0.99,
'special_price' => 0.90,
'cost' => 0.50,
'description' => 'Default',
'short_description' => 'Default',
'meta_title' => 'Default',
'meta_description' => 'Default',
'meta_keyword' => 'Default',
'weight' => 11,
'status' => 1,
'visibility' => 4,
'tax_class_id' => 2,
'qty' => 0,
'is_in_stock' => 0,
'enable_googlecheckout' => '1',
'gift_message_available' => '0',
'url_key' => strtolower($randomString),
);
}
$time = microtime(true);
try {
/** @var $import AvS_FastSimpleImport_Model_Import */
$import = Mage::getModel('fastsimpleimport/import');
$import->processProductImport($data);
} catch (Exception $e) {
print_r($import->getErrorMessages());
}
echo 'Elapsed time: ' . round(microtime(true) - $time, 2) . 's' . "\n";