Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to set out of stock threshold for backorders ? #42

Closed
jchirschy opened this issue Apr 30, 2021 · 4 comments
Closed

How to set out of stock threshold for backorders ? #42

jchirschy opened this issue Apr 30, 2021 · 4 comments

Comments

@jchirschy
Copy link

Hello,

I'm trying to use the importer to set the Out-of-Stock Threshold field. Actually, I'm trying to set a negative value per product.
I know there is something like :

$stock = $product->defaultStockItem();
$stock->setBackorders(ProductStockItem::BACKORDERS_ALLOW_QTY_BELOW_0);
$stock->setUseConfigBackorders(false);

But I didn't see anything concerning this special use case.
Did I miss something or could you indicate me how to accomplish this ?

By the way, what does $stock->setUseConfigBackorders exactly do ?

Thanks in advance for you help.

@patrick-bigbridge
Copy link
Contributor

Hi,

Yes this is not very clear. What you need to use for Out of stock threshold is

$stock->setMinimumQuantity(-10);

"minimum quantity" is the internal name of the field (min_qty).

setUseConfigBackorders tells the system whether it should use the system's generic config value or not. Only if this field is set to false, will the product specific value be used.

@jchirschy
Copy link
Author

Thanks @patrick-bigbridge ,

Actually, when you look at csv import file from the dashboard, there are two fields out_of_stock_qty and allow_backorders. Does $stock->setMinimumQuantity(-10); set the same field as the csv out_of_stock_qty one ?

Thanks.

@garfix
Copy link
Collaborator

garfix commented May 1, 2021

@jchirschy
Copy link
Author

thanks @garfix

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants