-
Notifications
You must be signed in to change notification settings - Fork 19
Expand file tree
/
Copy pathimport.php
More file actions
114 lines (86 loc) · 3.11 KB
/
import.php
File metadata and controls
114 lines (86 loc) · 3.11 KB
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
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
<?php
require_once 'bootstrap.php';
require_once 'import_arrtibute.php';
require_once 'import_arrtibute_set.php';
if (!Arguments::hasArgs()) {
echo "No arugmets given !!!! [--set --attr ] \n";
exit(0);
}
/*
|--------------------------------------------------------------------------
| Attribute set Delete
|--------------------------------------------------------------------------
*/
/*
$resource = Mage::getSingleton('core/resource');
$db_read = $resource->getConnection('core_read');
$attribute_sets = $db_read->fetchCol("SELECT attribute_set_id FROM " . $resource->getTableName("eav_attribute_set") . " WHERE attribute_set_id<> 4 AND entity_type_id=4");
foreach ($attribute_sets as $attribute_set_id) {
try {
Mage::getModel("eav/entity_attribute_set")->load($attribute_set_id)->delete();
} catch (Exception $e) {
echo $e->getMessage() . "\n";
}
}
*/
/*
|--------------------------------------------------------------------------
| Attribute Delete
|--------------------------------------------------------------------------
| To delete attributes just create a csv file with name oldAttributes and
| uncomment the below section and run it.
|
*/
/*
$fileName = MAGENTO . '/var/oldAttributes.csv';
$file = fopen($fileName,"r");
$oldCode = array();
while(!feof($file)){
$tmpCode = fgetcsv($file, 0, ',');
if(is_array($tmpCode)){
$oldCode[] = $tmpCode[0];
}
}
fclose($file);
$attrCollection = Mage::getResourceModel('catalog/product_attribute_collection')
->addFilter('is_user_defined','1')
->addFieldToFilter('main_table.attribute_code', array('in' => $oldCode));
foreach($attrCollection as $_attibute) {
if ($_attibute->getIsUserDefined()) {
try {
$_attibute->delete();
} catch (Exception $e) {
echo $_attibute->getAttributeCode()." -- ".$e->getMessage() .'\n';
}
}
}
*/
/*
|--------------------------------------------------------------------------
| Attribute Import
|--------------------------------------------------------------------------
*/
if (Arguments::getArg('attr')) {
echo "Creating Attribute. \n";
$fileName = MAGENTO . '/var/importAttribute.csv';
$importer = new ArrtibuteImporter();
$importer->import($fileName);
unset($importer);
echo "\nMEMORY USED : ".convert(memory_get_usage(true)) . "\n\n";
}
/*
|--------------------------------------------------------------------------
| Attribute Set Import
|--------------------------------------------------------------------------
*/
if (Arguments::getArg('set')) {
echo "Creating Attribute Sets. \n";
$fileName = MAGENTO . '/var/importAttributeSet.csv';
$importer = new ArrtibuteSetImporter();
$writeConnection = Mage::getSingleton('core/resource')->getConnection('core_write');
$writeConnection->query("SET FOREIGN_KEY_CHECKS = 0");
$importer->import($fileName);
$writeConnection->query("SET FOREIGN_KEY_CHECKS = 1");
unset($importer);
echo "\nMEMORY USED : ".convert(memory_get_usage(true)) . "\n\n";
}