... | ... |
@@ -32,6 +32,10 @@ class ShopwareMappings |
32 | 32 |
{ |
33 | 33 |
$this->mappings['units'] = System::getContainer()->getParameter('vonrotenberg_shopware_api.mappings.units'); |
34 | 34 |
} |
35 |
+ if (!isset($this->mappings['currencies'])) |
|
36 |
+ { |
|
37 |
+ $this->mappings['currencies'] = System::getContainer()->getParameter('vonrotenberg_shopware_api.mappings.currencies'); |
|
38 |
+ } |
|
35 | 39 |
|
36 | 40 |
return $this->mappings; |
37 | 41 |
} |
... | ... |
@@ -79,4 +83,17 @@ class ShopwareMappings |
79 | 83 |
|
80 | 84 |
return $unitId; |
81 | 85 |
} |
86 |
+ |
|
87 |
+ public function getCurrencyIdByName(string $name): ?string |
|
88 |
+ { |
|
89 |
+ $mappings = $this->getMappings(); |
|
90 |
+ $currencyId = null; |
|
91 |
+ |
|
92 |
+ if (($currency = array_search($name, $mappings['currencies'])) !== false) |
|
93 |
+ { |
|
94 |
+ $currencyId = $currency; |
|
95 |
+ } |
|
96 |
+ |
|
97 |
+ return $currencyId; |
|
98 |
+ } |
|
82 | 99 |
} |
1 | 1 |
new file mode 100644 |
... | ... |
@@ -0,0 +1,82 @@ |
1 |
+<?php |
|
2 |
+ |
|
3 |
+declare(strict_types=1); |
|
4 |
+ |
|
5 |
+/* |
|
6 |
+ * This file is part of vonRotenberg Shopware API Bundle. |
|
7 |
+ * |
|
8 |
+ * (c) vonRotenberg |
|
9 |
+ * |
|
10 |
+ * @license proprietary |
|
11 |
+ */ |
|
12 |
+ |
|
13 |
+namespace vonRotenberg\ShopwareApiBundle\Helper; |
|
14 |
+ |
|
15 |
+use Contao\System; |
|
16 |
+ |
|
17 |
+class ShopwareMappings |
|
18 |
+{ |
|
19 |
+ protected $mappings = []; |
|
20 |
+ |
|
21 |
+ protected function getMappings() |
|
22 |
+ { |
|
23 |
+ if (!isset($this->mappings['properties'])) |
|
24 |
+ { |
|
25 |
+ $this->mappings['properties'] = System::getContainer()->getParameter('vonrotenberg_shopware_api.mappings.properties'); |
|
26 |
+ } |
|
27 |
+ if (!isset($this->mappings['property_groups'])) |
|
28 |
+ { |
|
29 |
+ $this->mappings['property_groups'] = System::getContainer()->getParameter('vonrotenberg_shopware_api.mappings.property_groups'); |
|
30 |
+ } |
|
31 |
+ if (!isset($this->mappings['units'])) |
|
32 |
+ { |
|
33 |
+ $this->mappings['units'] = System::getContainer()->getParameter('vonrotenberg_shopware_api.mappings.units'); |
|
34 |
+ } |
|
35 |
+ |
|
36 |
+ return $this->mappings; |
|
37 |
+ } |
|
38 |
+ |
|
39 |
+ public function getPropertyIdByNameAndGroup(string $name, string $group, bool $useGroupUuid = false): ?string |
|
40 |
+ { |
|
41 |
+ $mappings = $this->getMappings(); |
|
42 |
+ $propertyId = null; |
|
43 |
+ |
|
44 |
+ if (!$useGroupUuid) |
|
45 |
+ { |
|
46 |
+ $group = array_search($group, $mappings['property_groups']); |
|
47 |
+ } |
|
48 |
+ |
|
49 |
+ if ($group !== false && ($property = array_search($name, $mappings['properties'][$group])) !== false) |
|
50 |
+ { |
|
51 |
+ $propertyId = $property; |
|
52 |
+ } |
|
53 |
+ |
|
54 |
+ return $propertyId; |
|
55 |
+ } |
|
56 |
+ |
|
57 |
+ public function getPropertyGroupIdByName(string $name): ?string |
|
58 |
+ { |
|
59 |
+ $mappings = $this->getMappings(); |
|
60 |
+ $groupId = null; |
|
61 |
+ |
|
62 |
+ if (($group = array_search($name, $mappings['property_groups'])) !== false) |
|
63 |
+ { |
|
64 |
+ $groupId = $group; |
|
65 |
+ } |
|
66 |
+ |
|
67 |
+ return $groupId; |
|
68 |
+ } |
|
69 |
+ |
|
70 |
+ public function getUnitIdByName(string $name): ?string |
|
71 |
+ { |
|
72 |
+ $mappings = $this->getMappings(); |
|
73 |
+ $unitId = null; |
|
74 |
+ |
|
75 |
+ if (($unit = array_search($name, $mappings['units'])) !== false) |
|
76 |
+ { |
|
77 |
+ $unitId = $unit; |
|
78 |
+ } |
|
79 |
+ |
|
80 |
+ return $unitId; |
|
81 |
+ } |
|
82 |
+} |