From 3d0d2a2cfed7afe21978604a5a00f2d149295fac Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Joachim=20L=C3=B8vgaard?= Date: Thu, 29 Aug 2024 20:58:51 +0200 Subject: [PATCH] Set weight on products --- src/DataMapper/Product/ProductDataMapper.php | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/DataMapper/Product/ProductDataMapper.php b/src/DataMapper/Product/ProductDataMapper.php index 5c07566..86364d6 100644 --- a/src/DataMapper/Product/ProductDataMapper.php +++ b/src/DataMapper/Product/ProductDataMapper.php @@ -15,5 +15,11 @@ public function map(ProductVariantInterface $productVariant, Product $product): $product->variantId = $productVariant->getCode(); $product->itemNumber = $productVariant->getCode(); $product->description = $productVariant->getProduct()?->getName(); + + // This presumes that the product variant's weight is in kilograms + $weight = $productVariant->getWeight(); + if (null !== $weight) { + $product->weight = (int) round(1000 * $weight); + } } }