Skip to content

Add "IsSaleable" special attribute for optimizers#2637

Open
vseager wants to merge 9 commits into
Smile-SA:2.10.xfrom
vseager:2.10.x
Open

Add "IsSaleable" special attribute for optimizers#2637
vseager wants to merge 9 commits into
Smile-SA:2.10.xfrom
vseager:2.10.x

Conversation

@vseager

@vseager vseager commented Jul 13, 2022

Copy link
Copy Markdown
Contributor

Resolves #2618 .

Currently if you use the "Only in stock products" rule in an optimizer when you have backorders enabled, you don't get the expected results.

To be able to backorder a product it needs to be set to "In Stock" even if the quantity is 0.

This means that products which are available to order but not physically in stock are currently prioritised in the optimizer and there is no way to prioritise ONLY product which are physically in stock and ready to ship.

This PR achieves two things:

  • Modify IsInStock special attribute to return products which are both set to "In Stock" and have a qty greater than 0.
  • Add new IsSaleable special attribute which returns all "In Stock" products regardless of qty.

Screenshot from 2022-07-13 20-26-05

@romainruaud romainruaud added the safe to test PR can be tested label Jul 19, 2022
@romainruaud

Copy link
Copy Markdown
Collaborator

Hi @vseager

Please see my comments. I don't really understand the point of doing this like that.

Your "is saleable" is equivalent to our "only in stock products" => we should keep our legacy as is.

I dont think "stock.qty > 0 and stock.is_in_stock=true" should be a dedicated special attribute.

I'd rather go with introducing a new special attribute based only on stock.qty.

However, it will not work for configurable products as their stock.qty is always 0 (thanks to Magento for this).

@vseager

vseager commented Jul 20, 2022

Copy link
Copy Markdown
Contributor Author

@romainruaud Thanks for your comments.

Your "is saleable" is equivalent to our "only in stock products" => we should keep our legacy as is.

This is correct, it was really down to the terminology being understandable by the user. as "In Stock Products" to most administrators (not programmers) would imply the item is physically in stock, on the shelf (and doesn't require backorder).
Therefore, "Only in stock products" = products that are in stock, on the shelf, ready to ship, and "Only saleable products" = available to purchase but not necessarily ready to ship yet (for example if backorders are enabled).

I dont think "stock.qty > 0 and stock.is_in_stock=true" should be a dedicated special attribute.
I'd rather go with introducing a new special attribute based only on stock.qty.

A stock.qty option is of course a perfectly good alternative solution.

@Nuranto

Nuranto commented May 19, 2023

Copy link
Copy Markdown
Contributor

A product with stock.qty > 0 and stock.is_in_stock=true can be backorderable, if min_sale_qty or qty_increments is greater than 1 and stock.qty = 1 for example.
With this in mind, that special attribute idea could be legitimate.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

safe to test PR can be tested

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Optimizer "Only in stock products" with backorders

3 participants