-
Notifications
You must be signed in to change notification settings - Fork 0
/
Sale.php
70 lines (64 loc) · 1.94 KB
/
Sale.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
<?php
require_once(__DIR__."/vendor/autoload.php");
require_once __DIR__.'/config.php';
$api = new Datatrics\API\Client($apiKey, $projectId);
$faker = Faker\Factory::create();
$faker->seed(0);
$sale = [
"projectid" => $projectId,
"conversionid" => "conversion-0",
"objecttype" => "conversion",
"source" => "MyWebshop",
"conversion" => [
"profileid" => "profile-0",
"total" => $faker->randomNumber(2),
"status" => "orderstate",
"created" => date('Y-m-d H:i:s', $faker->unixTime),
"updated" => date('Y-m-d H:i:s'),
"items" => [
[
"itemid" => "content-0",
"sku" => $faker->word,
"name" => $faker->sentence,
"quantity" => $faker->randomDigitNotNull,
"price" => $faker->randomNumber(2),
"total" => $faker->randomNumber(2)
]
]
]
];
$sale = $api->Sale->Create($sale);
echo "<pre>";
print_r($sale);
echo "</pre>";
$sales = [];
for ($i=1;$i<=10;$i++) {
$faker->seed($i);
$sales[] = [
"projectid" => $projectId,
"conversionid" => "conversion-".$i,
"objecttype" => "conversion",
"source" => "MyWebshop",
"conversion" => [
"profileid" => "profile-".$i,
"total" => $faker->randomNumber(2),
"status" => "orderstate",
"created" => date('Y-m-d H:i:s', $faker->unixTime),
"updated" => date('Y-m-d H:i:s'),
"items" => [
[
"itemid" => "content-".$i,
"sku" => $faker->word,
"name" => $faker->sentence,
"quantity" => $faker->randomDigitNotNull,
"price" => $faker->randomNumber(2),
"total" => $faker->randomNumber(2)
]
]
]
];
}
$sales = $api->Sale->Bulk($sales);
echo "<pre>";
print_r($sales);
echo "</pre>";