-
Notifications
You must be signed in to change notification settings - Fork 0
/
example_export_all_products.php
69 lines (50 loc) · 1.29 KB
/
example_export_all_products.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
<?php
require_once 'query_builder.php';
# have no html output
header('Content-Type: text/plain');
require_once 'db.php';
# select db
mysql_select_db('magento');
# create object with the mangento model and the storeId
$builder = new QueryBuilder('catalog/product', array(0,1));
# load all attributes
$builder->loadAllAttributes();
# select attributes
$attr = array(
"entity_id",
"sku",
"name",
"price",
"url_path",
"url_key",
"attribute_set",
"category_ids",
"status",
"created_at",
"updated_at"
);
$builder->selectAttributes( $attr );
# manual override for a select attribute
$builder->setAttrQuery( "category_ids", "select
group_concat(category_id separator \",\")
from
catalog_category_product_index cat
where
cat.product_id=a.entity_id and
cat.store_id=1
group by cat.product_id");
# set condetions for the select statement
//$builder->setCond( 'type_id', '=', '"downloadable"');
# return the query
$query = $builder->getQuery();
//var_dump($query); die();
$result = mysql_query($query, $link);
if (!$result) {
die('Invalid query: ' . mysql_error());
}
echo '"'.implode('";"',$attr)."\"\n";
while ($row = mysql_fetch_assoc($result)) {
echo '"'.implode('";"',$row).'"';
echo "\n";
}
?>