#Imported products out of stock

46 messages · Page 1 of 1 (latest)

gusty fulcrum
#

I'm using a CSV to automatically import products to my Medusa back-end.

The import appears to work fine but the products are showing as "Out of stock" even though there are positive values in the "Variant Inventory Quantity" column for each product/variant.

If I manually add a product in Medusa the product shows as In stock on the store front.

Anyone encountered this issue and know the fix?

silent shadow
#

Can you show the response for this product

gusty fulcrum
#

Sure @silent shadow — here's what I get in the logs when I have console.log(product); in the code:

#

@silent shadow I think I just found the issue.

I had "Allow back order" set to "True" in my CSV for my imported products.

I set it to "False" and re-imported them and now they are showing as in stock and I can add them to my cart.

Think I found a bug here or perhaps I got something else wrong with my import?

#

And to add a a bit more info — if I manually swith the "Allow backorders" on and try to save I get a "property stock_location should not exist" error.

silent shadow
#

I don't know, but this is not the full log Why are you console logging from the backend? Is this some custom route?

gusty fulcrum
#

@silent shadow sorry I'm not really sure what you meant by "Can you show the response for this product"

Where can I find that?

rich ibex
#

I see the same behavior, enabling backorders makes the product unavailable

gusty fulcrum
#

@rich ibex good to know. Feels like a bug perhaps.

rich ibex
#

this is storefront shit

gusty fulcrum
#

Ah OK

rich ibex
#

/src/modules/products/components/product-actions/index.tsx

#

can you search here for const inStock

#

and share the code

#

i managed to make it work 🙂

gusty fulcrum
#

Do you also see the "property stock_location should not exist" error in the back-end if you try to set a product to allow backorders?

rich ibex
#

nope

gusty fulcrum
#

OK. I installed then removed these plugins:

  • @medusajs/inventory
  • @medusajs/stock-location

Maybe that causes that error for me.

Here's the code I have in : /src/modules/products/components/product-actions/index.tsx

// check if the selected variant is in stock
const inStock = useMemo(() => {
if (variant && !variant.inventory_quantity) {
return false
}

if (variant && variant.allow_backorder === false) {
  return true
}

}, [variant])

rich ibex
#

use markdown please

gusty fulcrum
#

``
// check if the selected variant is in stock
const inStock = useMemo(() => {
if (variant && !variant.inventory_quantity) {
return false
}

if (variant && variant.allow_backorder === false) {
  return true
}

}, [variant])
``

rich ibex
#

error: property stock_location should not exist

#

i got this now

#

and cannot save

#

lol

gusty fulcrum
#

Right OK.

#

Have you ran npm update recently?

rich ibex
#

no

#

so I managed to get rid of the error

#
  const inStock = useMemo(() => {
    if ((variant && variant.inventory_quantity) || (variant && variant.allow_backorder === true)) {
      return true
    }

    if (variant && !variant.inventory_quantity) {
      return false
    }

  }, [variant])
#

update the product action

#

and this will enable the variant if backorder is enabled

#

to get rid of the error

#

go the db

#

product variant

#

remove the backorder and add inv quantity 11

#

on the admin set quantity to 0

#

and reenable the backorder

rich ibex
#

@gusty fulcrum did you manage?

gusty fulcrum
#

Sorry @rich ibex I missed your message.

I will give it a try ASAP — I expect I'll be able to look in a few hrs. I'll report back.

gusty fulcrum
#

@rich ibex I just went through the steps you outlined and the error is gone. Thank you — amazing!

rich ibex
#

and you update the storefront as well?

gusty fulcrum
#

Yep

#

But something I'm not sure if is correct or not.

I have a product set to 0 in stock and available on back-order.

It can be added to the cart (correct).

But there's nothing on the page saying it's only available as back-order.

I guess I can add my own logic for this but wondered if that's something the storefront should handle already (and thus maybe something is wrong).

Do you know?

rich ibex
#

Ah we can do that easily

gusty fulcrum
#

Cool — I guessed so. Just wasn't sure if it was already done (and my storefront had a problem) or if I needed to do it.

rich ibex
#

You probably need to