Benjamin Roth authored on11/11/2024 10:47:55
Showing3 changed files
... ...
@@ -13,3 +13,6 @@ services:
13 13
 
14 14
     vonRotenberg\WmfgoCevisioBundle\Cron\ShopwareImportProductsJob:
15 15
         public: true
16
+
17
+    Contao\CoreBundle\InsertTag\InsertTagParser:
18
+        public: true
... ...
@@ -110,14 +110,14 @@ class ShopwareImportProductsJob extends AbstractController
110 110
                     'productNumber' => $Product->getSku(),
111 111
                     'taxId' => '018e65c0485071508949c072f8dc18bd',
112 112
                     'stock' => 999999,
113
-                    'name' => 'vrImport2__'.$Product->getName(),
114
-                    'active' => (bool) $Product->getPublished(),
113
+                    'name' => $Product->getName(),
115 114
                     'isCloseout' => true,
116 115
                     'purchaseUnit' => (float) $Product->getBaseprice(),
117 116
                     'referenceUnit' => 1,
118 117
                     'unitId' => $this->mappings->getUnitIdByName('Liter')
119 118
                 ];
120 119
 
120
+                if ($Product->getPublished() == '1' || $Product->getPublished() == '0') $arrData['active'] = (bool) $Product->getPublished() ;
121 121
                 if ($Product->getEan()) $arrData['ean'] = $Product->getEan();
122 122
                 if ($Product->getShipping_weight()) $arrData['weight'] = $Product->getShipping_weight();
123 123
                 if ($Product->getBesonderheit()) $arrData['description'] = $Product->getBesonderheit();
... ...
@@ -261,29 +261,35 @@ class ShopwareImportProductsJob extends AbstractController
261 261
                     $arrData['properties'] = $arrProperties;
262 262
                 }
263 263
 
264
+                // Price handling
265
+                if (($price = $Product->getPreis())) {
266
+                    $arrPrice = [
267
+                        'currencyId' => $this->mappings->getCurrencyIdByName('Euro'),
268
+                        'gross' => $price,
269
+                        'net' => $price/119*100,
270
+                        'linked' => true
271
+                    ];
264 272
 
265
-/*
266
-                    'ean' => $Product->getEan(),
267
-                    'price' => [
268
-                        [
269
-                            'currencyId' => 'b7d2554b0ce847cd82f3ac9bd1c0dfca',
270
-                            'gross' => $Product->getPreis(),
271
-                            'net' => $Product->getPreis()/119*100,
273
+                    if (($listprice = $Product->getPreis_uvp())) {
274
+                        $arrPrice['listPrice'] = [
275
+                            'currencyId' => $this->mappings->getCurrencyIdByName('Euro'),
276
+                            'gross' => $listprice,
277
+                            'net' => $listprice/119*100,
272 278
                             'linked' => true
273
-                        ]
274
-                    ],
275
-                    'customFields' => [
276
-                        'custom_wine_attributes_jahrgang' => $Product->getJahrgang()
277
-                    ],
278
-                    'properties' => [
279
-                        [
280
-                            'id' => $this->mappings->getPropertyIdByNameAndGroup($Product->getLage(),'Einzellage'),
281
-                            'groupId' => $this->mappings->getPropertyGroupIdByName('Einzellage'),
282
-                            'name' => $Product->getLage()
283
-                        ]
284
-                    ]
285
-                ];
286
-*/
279
+                        ];
280
+                    } else {
281
+                        $arrPrice['listPrice'] = [
282
+                            'currencyId' => $this->mappings->getCurrencyIdByName('Euro'),
283
+                            'gross' => 0,
284
+                            'net' => 0,
285
+                            'linked' => true
286
+                        ];
287
+                    }
288
+
289
+                    $arrData['price'] = [$arrPrice];
290
+                }
291
+
292
+
287 293
                 if (!$this->shopware->addOrUpdateProductBySku($Product->getSku(), $arrData))
288 294
                 {
289 295
                     if ($isCli) $io->error('Could not update/import Product ' . $Product->getSku());
... ...
@@ -294,7 +300,7 @@ class ShopwareImportProductsJob extends AbstractController
294 300
                 {
295 301
                     $io->progressAdvance();
296 302
                 }
297
-                return;
303
+//                return;
298 304
             }
299 305
             if ($isCli) $io->progressFinish();
300 306
         }
... ...
@@ -12,6 +12,9 @@ declare(strict_types=1);
12 12
 
13 13
 namespace vonRotenberg\WmfgoCevisioBundle\Model\Import;
14 14
 
15
+use Contao\CoreBundle\InsertTag\InsertTagParser;
16
+use Contao\System;
17
+
15 18
 class ProductModel
16 19
 {
17 20
     /**
... ...
@@ -49,7 +52,8 @@ class ProductModel
49 52
     {
50 53
         if (isset($this->arrData[$name]))
51 54
         {
52
-            return $this->arrData[$name];
55
+            $insertTagParser = System::getContainer()->get(InsertTagParser::class);
56
+            return $insertTagParser->replace($this->arrData[$name]);
53 57
         }
54 58
 
55 59
         return null;