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

New optional feature - display out of stock products last #12441

Closed
wants to merge 18 commits into from
Closed

New optional feature - display out of stock products last #12441

wants to merge 18 commits into from

Conversation

gadnis
Copy link

@gadnis gadnis commented Feb 5, 2019

Questions Answers
Branch? develop
Description? This PR adds a button in BO-> Shop Parameters -> Product Settings -> Pagination TAB, an option to display out of stock products last. If this feature enabled, than products goes in this order: 1. inStock, 2. OutOfStock & Available for order, 3. OutOfStock. Affected pages: category, best-sales, new-products, price-drop. It doesn't rearrange products if FO user sorts by: name or sales, cause it would be not logical. A lot of people has thousands of products in database and thousands of them is with quantity 0 but allowed to order. Before this feature, these "available to order" products went to the end of product list, with this feature it will go after the "available" products and out-of-stock products will be the last products.
Type? new feature
Category? FO
BC breaks? no
Deprecations? no
Fixed ticket? "Fixes #9956". Or atleast one issue mentioned in comments.
How to test? Turn off module: ps_facetedsearch (cause it overrides native functions for category pages). Go to: BO-> Shop Parameters -> Product Settings -> Pagination TAB. Switch "Display out-of-stock products last" to ON. Go to FO pages: any category, new-products, prices-drop, best-sales. Choose to sort by price, data added. You will see products sorted in the chunks: 1. inStock, 2. OutOfStock & Available for order, 3. OutOfStock.

Here is some pictures to help you understand what PR does:

BO: feature switch added:
screen shot 2019-02-05 at 22 58 29

FO: sort by Price examples:
In category pages:
screen shot 2019-02-05 at 22 59 42

In best-sales page:
screen shot 2019-02-05 at 23 02 07

In prices-drop page:
screen shot 2019-02-05 at 23 02 54

In new-product page:
screen shot 2019-02-05 at 23 01 26

Sort by Date added in new-product page:
screen shot 2019-02-05 at 23 03 47


This change is Reviewable

gadnis and others added 7 commits July 16, 2018 16:12
When user adjust quantity in cart summary and wanted quantity is more than 'in-stock', than error notification shown, but with this improvement user knows maximum product quantity he can buy.
@prestonBot
Copy link
Collaborator

Hello @gadnis!

This is your first pull request on the PrestaShop project. Thank you, and welcome to this Open Source community!

@prestonBot prestonBot added Feature Type: New Feature Waiting for wording Status: action required, waiting for wording labels Feb 5, 2019
@matks
Copy link
Contributor

matks commented Feb 6, 2019

@colinegin This is a new feature, what do you think 😉 ?

@matks matks added the Waiting for PM Status: action required, waiting for product feedback label Feb 6, 2019
@prestonBot prestonBot added the develop Branch label Feb 6, 2019
@MatShir MatShir added PM ✔️ Status: check done, behavior approved and removed Waiting for PM Status: action required, waiting for product feedback labels Apr 12, 2019
@@ -47,6 +47,11 @@
{{ form_errors(paginationForm.default_order_way) }}
{{ form_widget(paginationForm.default_order_way) }}
</div>
<div class="form-group">
{{ ps.label_with_help(('Display out-of-stock products last'|trans), ('If enabled, products will be in this order: 1. in-stock, 2. available for order but quantity is 0, 3. out-of-stock. This does not apply when ordering by name & sales'|trans({}, 'Admin.Shopparameters.Help'))) }}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hello, can you explain the "ordering by name & sales" please? Also, I would write If enabled, products will be displayed in this order: 1. in-stock, 2. available for order but quantity is 0, 3. out-of-stock. Note that it does not apply when ordering by name or sales. instead, what do you think?

@LouiseBonnard LouiseBonnard added the Waiting for author Status: action required, waiting for author feedback label Apr 15, 2019
@marionf
Copy link
Contributor

marionf commented Aug 1, 2019

Hello @gadnis

In BO > Shop parameters > Products settings, you can already choose to filter by quantity by default

capture d'écran_1844

This way, when your customer arrives on a category page, "Relevance" is selected and your products are sorted by quantity.

The problem is that this option only takes into account the quantity and not if out of stock products can be ordered or not.

So, we would like to take this into account when quantity is selected as default order by.
Without adding a new switch option

What dou think about that ?

@marionf marionf self-assigned this Aug 1, 2019
@gadnis
Copy link
Author

gadnis commented Aug 1, 2019

Hi @marionf ! It's kind of good idea but not really.. If people would choose to order by name, I understand that they want to see product in A-Z or Z-A order. But when day choose to order by price, they aspect to see lets say cheapest products first and hope that the seller has those products in stock, cause why else order by price.. unless to spy or investigate product prices, which is not that offen the case to order by price. I Would add a switch (ON, OFF option) to show out-of-stock products last.

@marionf marionf added Waiting for PM Status: action required, waiting for product feedback and removed PM ✔️ Status: check done, behavior approved labels Aug 1, 2019
@marionf
Copy link
Contributor

marionf commented Aug 2, 2019

Thank you for your answer @gadnis

I would like to test your PR and maybe suggest some improvements but there are some conflicting files and this generates errors
Could you please resolve conflicts ?

@gadnis
Copy link
Author

gadnis commented Aug 2, 2019

Ok, @marionf, I will try to do that in the next week ;)

@marionf marionf removed the Waiting for PM Status: action required, waiting for product feedback label Sep 11, 2019
Adding switch to enable or disable the feature
@gadnis gadnis requested a review from a team as a code owner December 4, 2019 16:49
Adding SwitchType to a Form. To be able switch off|on this feature
Adding configuration field 'display_out_of_stock_last'. It will be used to either enable or disable the feature
This one is not related to the feature. I'm not sure why it is in this PR. But it is useful.
Adding two methods: orderByOOSP and sqlOrderByOOSP
There is All "facets" where we allow to sort out-of-stock last in method sqlOrderByOOSP 
And method orderByOOSP helps to do that later
changes marked with comment: ORDER BY out-of-stock products last
Allowing order products as described in PR
Changes marked with comment: ORDER BY out-of-stock products last
Copy link
Author

@gadnis gadnis left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code is now compatible with PS 1.7.6.2

@gadnis
Copy link
Author

gadnis commented Dec 4, 2019

Thank you for your answer @gadnis

I would like to test your PR and maybe suggest some improvements but there are some conflicting files and this generates errors
Could you please resolve conflicts ?

Hi, @marionf , finally I updated our shop to the latest, and now I had to put back my code there. So I change the code in this PR also. Please review and merge it 😁

Now I will go to find out how to do the same feature on ps_facetedsearch module, cause it was refactored and my code is no fit in there...

@@ -55,7 +55,13 @@
{{ form_widget(paginationForm.default_order_way) }}
</div>
</div>

<div class="form-group row">
{{ ps.label_with_help(('Display out-of-stock products last'|trans), ('If enabled, products will be displayed in this order: 1. in-stock, 2. available for order but quantity is 0, 3. out-of-stock. Note that it apply only when ordering by quantity, price or dates'|trans({}, 'Admin.Shopparameters.Help'))) }}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would not use the word 'reordering' here, it can be ambiguous. What about Note that it only applies when filtering by quantity, price or date. instead?

…eters/Blocks/product_preferences_pagination.html.twig

Co-Authored-By: LouiseBonnard <32565890+LouiseBonnard@users.noreply.github.com>
@LouiseBonnard LouiseBonnard added Wording ✔️ Status: check done, wording approved and removed Waiting for wording Status: action required, waiting for wording labels Dec 5, 2019
@PierreRambaud
Copy link
Contributor

Hi @gadnis ,

Since we had no news from you for more than 30 days, I'll close this pull request. Feel free to reopen or open another one if you think it's still relevant.

Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
develop Branch Feature Type: New Feature Waiting for author Status: action required, waiting for author feedback Wording ✔️ Status: check done, wording approved
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[BOOM-3373] "Default order by" doesn't work for all options
7 participants