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

Unite price can't be used as sorting method #27171

Open
2 of 6 tasks
vincent-dp opened this issue Jan 3, 2022 · 5 comments
Open
2 of 6 tasks

Unite price can't be used as sorting method #27171

vincent-dp opened this issue Jan 3, 2022 · 5 comments
Labels
Feature Type: New Feature FO Category: Front Office Needs Specs Status: issue needs to be specified Old Products Page Concerns the old product page Taxes and Prices Component: Which BO section is concerned

Comments

@vincent-dp
Copy link

vincent-dp commented Jan 3, 2022

Prerequisites

Is your feature request related to a problem?

Hello,

We cannot chose to sort product by its unite price.

Describe the solution you'd like

To be able to sort product by their unite price

image

Alternatives you've considered

I have tried to find/modify the method for a client, and I'm not able to follow the trace that leads to a sql query and I drown myself into the functions that build the search. So even if I wanted to add a column myself, the documentation is too rich/too poor to give me the oportunity to find a solution about productSearchQuery

Additional context

No response

Do you plan to work on this feature?

  • I'm willing to contribute a formal specification.
  • I'm willing to provide any wireframes or design assets required for this feature.
  • I'm willing to submit a Pull Request that implements this feature.
  • I'm willing to help verify that the implemented feature works as intended and produces no unintended side effects.
@vincent-dp vincent-dp added the Feature Type: New Feature label Jan 3, 2022
@hibatallahAouadni
Copy link
Contributor

Hello @vincent-dp

Thank you for your suggestion. The Product Team will take it into consideration for future developments.
Please be aware that there is no guarantee that this feature will be developed anytime soon. If this is important to you, we strongly suggest you consider hiring a specialist to help you create it.

If you are willing to implement this feature into PrestaShop as a Pull Request, the teams will be happy to help you by ensuring that it is appropriate and coherent with the rest of the project. If that is the case, please let us know!

Thank you

@hibatallahAouadni hibatallahAouadni added FO Category: Front Office Needs Specs Status: issue needs to be specified Old Products Page Concerns the old product page Taxes and Prices Component: Which BO section is concerned labels Jan 3, 2022
@MatShir
Copy link
Contributor

MatShir commented Jan 3, 2022

Now the unit price will be stored in the database with this PR #26762 for the next version. So after this PR is merged, we could rename this feature request 'can't sort with unit price' ;)

@vincent-dp vincent-dp changed the title Unite price are not stored and can't be used as sorting method Unite price can't be used as sorting method Jan 4, 2022
@vincent-dp
Copy link
Author

Thank you, I have edited my request and the title

@jolelievre
Copy link
Contributor

Hi @vincent-dp

as @MatShir told you we are introducing this unit price column in 8.0.0 However if you need it in your module for prior versions of PrestaShop you should be able to compute it in your SQL request. Similarly to what was done here for upgrade scripts PrestaShop/autoupgrade#441

You should be able to request something like this:

SELECT p.*, IF (`unit_price_ratio` != 0, `price` / `unit_price_ratio`, 0) AS unit_price FROM product p ORDER BY unit_price;

That's just a simple example (because you should also consider values from the product_shop table used for multishop, but that's the idea. Maybe it can help you in the meantime, if not you'll have to wait for the next 8.0.0 version to use this new column. You can test the develop branch once the #26762 is merged, and we'll add the Unit price field in the product page settings as soon as it's available.

@jolelievre jolelievre self-assigned this Jan 4, 2022
@vincent-dp
Copy link
Author

Thank you very much for answering.

Yes after reading the whole #26762 I was able to reproduce on an old release (1.7.5+) since it is pretty much straight forward.

About the sorting method,
the main problem of unite price (so far) is that it is not impacted by discounts (not directly as you made it into the db). For example, the price, when a discount is applied, get a value stored in ps_specific_price. This is very important because that's how the sorting method can adress the right numbers. otherwise, the sort by unite-price will be totally wrong if only based on the main ps_product table or even the ps_product_lang

I don't think I can make a module to make this sorting method works, since my client use another module for filtering search/catalog and it will be really messy to make all these works. So I think I have to wait for a release

@jolelievre jolelievre removed their assignment Mar 22, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Feature Type: New Feature FO Category: Front Office Needs Specs Status: issue needs to be specified Old Products Page Concerns the old product page Taxes and Prices Component: Which BO section is concerned
Projects
None yet
Development

No branches or pull requests

4 participants