forked from dschreck/php-eav-example
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathconfig.php
More file actions
executable file
·37 lines (32 loc) · 718 Bytes
/
config.php
File metadata and controls
executable file
·37 lines (32 loc) · 718 Bytes
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
<?php
define('MYSQL_USER','root');
define('MYSQL_PASS','');
define('MYSQL_HOST','localhost');
define('MYSQL_DB','eav');
function getData($path) {
$output = array();
if(file_exists($path))
{
$entities = simplexml_load_file($path);
foreach($entities->entity as $entity)
{
if((string)$entity['category'] == 'car')
{
$carData = array();
foreach($entity->attribute as $attribute)
{
$rowData = array();
$rowData['attribute'] = (string)$attribute['name'];
$rowData['value'] = (string)$attribute['value'];
$carData[] = $rowData;
}
$output[(string)$entity['sku']] = $carData;
}
}
}
else
{
error_log('Unable to load '.$path);
}
return $output;
}