-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathProductCustomBusinessTransformer.php
More file actions
43 lines (33 loc) · 1.41 KB
/
ProductCustomBusinessTransformer.php
File metadata and controls
43 lines (33 loc) · 1.41 KB
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
<?php
declare(strict_types=1);
namespace Ergonode\IntegrationShopware\Transformer;
use Ergonode\IntegrationShopware\DTO\ProductTransformationDTO;
use Ergonode\IntegrationShopware\Service\ConfigService;
use Shopware\Core\Defaults;
use Shopware\Core\Framework\Context;
class ProductCustomBusinessTransformer implements ProductDataTransformerInterface {
private ConfigService $configService;
public function __construct(ConfigService $configService) {
$this->configService = $configService;
}
public function transform(ProductTransformationDTO $productData, Context $context): ProductTransformationDTO {
$swData = $productData->getShopwareData();
$ergonodeData = $productData->getErgonodeData();
$sku = $ergonodeData->getSku();
if (preg_match('/^V[0-9]+_.+$/', $sku)) { // handle for good parts
// inherit from a parent
$swData->setName('');
$swData->setTax(null);
$swData->setPrice(null);
$swData->setData('isCloseout', null);
$swData->setData('shippingFree', null);
$swData->setData('markAsTopseller', null);
$swData->setData('minPurchase', null);
$swData->setData('purchaseSteps', null);
$swData->setData('active', null);
$swData->setProperties([]);
}
$productData->setShopwareData($swData);
return $productData;
}
}