Basically i want to update price based on currency and exchange rate via cron job and custom service.
I created product and product variant with price.
Then I created custom service and custom scheduled job.
Here is method from custom service i created:
import { ProductService, ProductVariant, TransactionBaseService } from "@medusajs/medusa"
async updateProducts() {
let products = await this.productService.list({})
let variants = await Promise.all(
products.map(async ({ id }) => {
return await this.productService.retrieveVariants(id)
})
)
console.log("variants", variants)
}```
and here is what i get
[
ProductVariant {
id: 'variant_01J47MS5M3NC202MQZDRG8S2R9',
created_at: 2024-08-01T18:56:03.195Z,
updated_at: 2024-08-01T18:56:03.195Z,
deleted_at: null,
title: '5m2',
product_id: 'prod_01J47MQM0J0Z458VXSA26AJF5V',
sku: null,
barcode: null,
ean: null,
upc: null,
variant_rank: 0,
inventory_quantity: 0,
allow_backorder: false,
manage_inventory: false,
hs_code: null,
origin_country: null,
mid_code: null,
material: null,
weight: null,
length: null,
height: null,
width: null,
metadata: {}
}
]
1. why there is no prices field? in Admin UI i see this field
2. how do i retrieve prices for each product variant?
3. can i update prices field when i want via this service?