Browse code

Add currencies to mappings and configuration

Benjamin Roth authored on12/11/2024 15:20:56
Showing2 changed files
... ...
@@ -66,6 +66,13 @@ class Configuration implements ConfigurationInterface
66 66
                                ->cannotBeEmpty()
67 67
                            ->end()
68 68
                         ->end()
69
+                        ->arrayNode('currencies')
70
+                            ->info('Shopware currencies (SWUUID: ext. value)')
71
+                            ->defaultValue([])
72
+                            ->scalarPrototype()
73
+                               ->cannotBeEmpty()
74
+                           ->end()
75
+                        ->end()
69 76
                     ->end()
70 77
                 ->end()
71 78
             ->end()
... ...
@@ -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
 }