Skip to content

Commit

Permalink
Set weight on products
Browse files Browse the repository at this point in the history
  • Loading branch information
loevgaard committed Aug 29, 2024
1 parent 34df2e7 commit 3d0d2a2
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions src/DataMapper/Product/ProductDataMapper.php
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
}
}

0 comments on commit 3d0d2a2

Please sign in to comment.