-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathexporter_example.php
48 lines (41 loc) · 1.5 KB
/
exporter_example.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
<?php
require_once __DIR__.'/bootstrap.php';
use \OxidEsales\Eshop\Core\Registry;
use \OxidEsales\Eshop\Core\DatabaseProvider;
use \IvobaOxid\Exporter\Query\ChildProducts;
use \IvobaOxid\Exporter\Entity\Config;
use \IvobaOxid\Exporter\Entry\EntryMaker;
use \IvobaOxid\Exporter\Exporter;
use \IvobaOxid\Exporter\Query\ParentProducts;
use \IvobaOxid\Exporter\Query\Products;
use \IvobaOxid\Exporter\Resolver\Image;
use \IvobaOxid\Exporter\Resolver\StaticValue;
use \IvobaOxid\Exporter\Resolver\TitleWithVariant;
$langParams = Registry::getConfig()->getConfigParam('aLanguageParams');
$shopUrl = Registry::get("oxConfigFile")->getVar('sShopURL');
$config = new Config(__DIR__.'/export/example.csv', $shopUrl, $langParams['de']['baseId']);
$config->setDebug(true)
->setFields(explode(';', 'Product_id;Product_name;Image_URL'))
->setImgPath('/out/pictures/generated/product/1/380_340_75/');
$db = DatabaseProvider::getDb(DatabaseProvider::FETCH_MODE_ASSOC);
$queries = [
new Products(
new ParentProducts($db, $config),
new ChildProducts($db, $config)
),
];
$titleResolver = new TitleWithVariant($db, 'Product_name');
$idResolver = new FieldResolver('OXID', 'Product_id');
$imageResolver = new Image($config, 'Image_URL');
$entryMaker = new EntryMaker(
$config,
[],
[
$idResolver,
$titleResolver,
$imageResolver,
new StaticValue('', 'empty'),
]
);
$exporter = new Exporter($config, $queries, $entryMaker);
$exporter->export();