medusajs / medusa

Building blocks for digital commerce
https://medusajs.com
MIT License
24.32k stars 2.38k forks source link

Variant prices alone not storing into the db `@medusajs/product:0.3.12` #7604

Open ramumanavalan opened 2 months ago

ramumanavalan commented 2 months ago

Hi,

Using standalone experimental product module @medusajs/product 0.3.12 variant prices alone not storing into the db. Rest of all other informations are getting into the db except the variant prices

Even on the npm module @medusajs/product following /dist/models folder doesn't have the money_amount.js model.

Here is my code

const { initialize:initializeProductModule } = require("@medusajs/product");

module.exports = async function () {
    const productService = await initializeProductModule();
    await productService.create([{
        "title": "Sample Product",
        "description": "full descripton of the product.",
        "status": "draft",
        "external_id": "126187555",
        "images": [ { "url": "https://cloudfront.com/testimg.jpg" } ],
        "thumbnail": "https://cloudfront.com/testimg.jpg",
        "tags": [],
        "variants": [
          {
            "title": "varient 1",
            "inventory_quantity": 100,
            "metadata": { "external_id": "3679039063886273" },

            // THIS VARIANT PRICES NOT STORING INTO DB
            "prices": [ 
              { "amount": 8500, "currency_code": "USD" }
            ]         
          }
        ],
        "metadata": { "merchant_id": 10003 }
      }]);
}
adrien2p commented 2 months ago

The pricing are handled by a separate module (pricing module) and the workflows are in charge to orchestrate the data flow and logic as well as linking the variants and prices. Are you sure you are using all the modules correctly ?

Ps: just re read your code, the prices would need to be sent to the pricing module and then creating a link between the two. Medusa will ship all of that and a proper documentation around those concepts