Info:
Ik ben voor een osCommerce winkel een aantal dingen aan het testen... je kent het wel
Ik heb me ff geregistreerd bij ICEcat.biz. Dit is een website waar je gemakkelijk hele product informatie pagina's kunt vinden voor het gebruik in bijvoorbeeld osCommerce. Nu heeft het bedrijf bInTime(.com) een leuk open source "ICEcat connector" gereleased. Hiermee kunnen gemakkelijk alle producten uit de database van ICEcat dmv. bijvoorbeeld (in dit geval) een xml pagina in osCommerce worden gezet.
Dit leek mij wel leuk en wou ik dus ff proberen
Probleem:
het script stopt na op het beeld "parsing" weer te geven. (aka. echo "<br />parsing\n";)
Vraag:
Wie weet hoe dit komt? Het script download namelijk wel gewoon de refs.xml file naar de server toe alleen als die bij het "parsen" komt dan stopt die ermee... Hoe kan dit en hoe kan ik zorgen dat het hele script gewoon doorloopt??
Script:
Resultaat nu:
En daar stopt die dus
Link om zelf te kijken:
http://www.vipmaurice.com/winkel2/icecat/icecat_import.php
Ik ben voor een osCommerce winkel een aantal dingen aan het testen... je kent het wel
Ik heb me ff geregistreerd bij ICEcat.biz. Dit is een website waar je gemakkelijk hele product informatie pagina's kunt vinden voor het gebruik in bijvoorbeeld osCommerce. Nu heeft het bedrijf bInTime(.com) een leuk open source "ICEcat connector" gereleased. Hiermee kunnen gemakkelijk alle producten uit de database van ICEcat dmv. bijvoorbeeld (in dit geval) een xml pagina in osCommerce worden gezet.
Dit leek mij wel leuk en wou ik dus ff proberen
Probleem:
het script stopt na op het beeld "parsing" weer te geven. (aka. echo "<br />parsing\n";)
Vraag:
Wie weet hoe dit komt? Het script download namelijk wel gewoon de refs.xml file naar de server toe alleen als die bij het "parsen" komt dan stopt die ermee... Hoe kan dit en hoe kan ik zorgen dat het hele script gewoon doorloopt??
Script:
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
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
| # ICEcat connector # (c) 2007 bInTime.com http://www.bintime.com # URLs import routine <?php if (version_compare(PHP_VERSION,'5','>=')) require_once('../includes/domxml-php4-to-php5.php'); require '../includes/configure.php'; require '../'.DIR_WS_FUNCTIONS.'database.php'; require '../includes/database_tables.php'; $icecat_product_list = 'data.icecat.biz/export/freexml.int/INT/files.index.csv'; $icecat_refs_xml = 'data.icecat.biz/export/freexml.int/refs.xml'; echo "\n"; tep_db_connect() or die('<br>Unable to connect to database server!'); $product_list = DIR_FS_DOWNLOAD.'product.list'; echo "<br />wgetting \n".'http://'.ICECAT_LOGIN.':'.ICECAT_PASSWORD.'@'.$icecat_product_list."\n"; copy('http://'.ICECAT_LOGIN.':'.ICECAT_PASSWORD.'@'.$icecat_product_list, $product_list) or die( "\n<br />failed to copy product list exiting...\n"); echo "<br />products list downloaded\n"; echo "<br />loading data to database\n"; tep_db_query("DROP TABLE IF EXISTS temp_ice_product_list"); tep_db_query(" CREATE TABLE temp_ice_product_list( path varchar(255), product_id int(11), updated date, quality varchar(15), supplier_id int(11), products_model varchar(255), catid int(11), m_prod_id varchar(255), KEY (supplier_id) )"); tep_db_query("LOAD DATA LOCAL INFILE '".$product_list."' INTO TABLE temp_ice_product_list"); tep_db_query("ALTER TABLE temp_ice_product_list DROP COLUMN path"); tep_db_query("ALTER TABLE temp_ice_product_list DROP COLUMN updated"); tep_db_query("ALTER TABLE temp_ice_product_list DROP COLUMN quality"); tep_db_query("ALTER TABLE temp_ice_product_list DROP COLUMN catid"); tep_db_query("ALTER TABLE temp_ice_product_list DROP COLUMN product_id"); tep_db_query("ALTER TABLE temp_ice_product_list DROP COLUMN m_prod_id"); tep_db_query("ALTER TABLE temp_ice_product_list ADD COLUMN manufacturers_name varchar(255)"); echo "<br />loaded\n"; ################################################ # # processing refs.xml # echo "<br />Wgetting supplier list\n"; $refs_xml = DIR_FS_DOWNLOAD.'refs.xml'; echo '<br />http://'.ICECAT_LOGIN.':'.ICECAT_PASSWORD.'@'.$icecat_refs_xml."\n"; copy('http://'.ICECAT_LOGIN.':'.ICECAT_PASSWORD.'@'.$icecat_refs_xml, $refs_xml) or die( "\n<br />failed to copy $refs_xml ...\n"); echo "<br />parsing\n"; if(!$dom = domxml_open_file($refs_xml)){ die("\n!!:: error parsing $refs_xml \n!!:: exiting\n"); echo "<br />dom-xml open file completed\n"; } $root = $dom->document_element(); if(!$root){ die("\n!!:: error parsing(root) $refs_xml \n!!:: exiting\n"); } echo "<br />Processing suppliers\n"; $supp_list = $root->get_elements_by_tagname('SuppliersList'); $supp_list = $supp_list[0]; $suppliers = $supp_list->get_elements_by_tagname('Supplier'); $supplirs_dump = DIR_FS_DOWNLOAD.'suppliers_dump.csv'; $file_handle = fopen($supplirs_dump,"a") or die(" error opening - $supplirs_dump \n"); foreach($suppliers as $supp){ if($supp->has_attribute('ID')) { $supp_id = $supp->get_attribute('ID'); } if($supp->has_attribute('Name')) { $supp_name = $supp->get_attribute('Name'); } fwrite($file_handle,"$supp_id\t$supp_name\n"); } unset($suppliers); fclose($file_handle) or die(" error closing $supplirs_dump"); echo "<br />inloading suppliers to database\n"; tep_db_query("DROP TABLE IF EXISTS temp_ice_supplier"); tep_db_query("CREATE TABLE temp_ice_supplier( icecat_supplier_id int(11) primary key, supplier_name varchar(255) not null default '', KEY (icecat_supplier_id))"); tep_db_query("LOAD DATA LOCAL INFILE '$supplirs_dump' INTO TABLE temp_ice_supplier"); echo "<br />updating supplier info\n"; tep_db_query("UPDATE temp_ice_product_list tp , temp_ice_supplier ts SET tp.manufacturers_name = ts.supplier_name WHERE tp.supplier_id = ts.icecat_supplier_id"); tep_db_query("DROP TABLE IF EXISTS temp_ice_supplier"); tep_db_query("ALTER TABLE temp_ice_product_list DROP COLUMN supplier_id"); tep_db_query("DELETE FROM temp_ice_product_list WHERE manufacturers_name IS NULL"); tep_db_query("DROP TABLE IF EXISTS ".ICECAT_AVALIABLE_PRODUCTS); tep_db_query("ALTER TABLE temp_ice_product_list RENAME TO ".ICECAT_AVALIABLE_PRODUCTS); ?> |
Resultaat nu:
code:
1
2
3
4
5
6
7
8
| # (c) 2007 bInTime.com http://www.bintime.com # URLs import routine wgetting http://testje:jPn3iF@data.icecat.biz/export/freexml.int/INT/files.index.csv products list downloaded loading data to database loaded Wgetting supplier list http://testje:jPn3iF@data.icecat.biz/export/freexml.int/refs.xml parsing |
En daar stopt die dus
Link om zelf te kijken:
http://www.vipmaurice.com/winkel2/icecat/icecat_import.php