Skip to content

SQL query improvement to check active products#41

Merged
jf-viguier merged 3 commits intoPrestaShop:devfrom
Prestaplugins:Prestaplugins-ps_viewedproduct-1
Feb 10, 2026
Merged

SQL query improvement to check active products#41
jf-viguier merged 3 commits intoPrestaShop:devfrom
Prestaplugins:Prestaplugins-ps_viewedproduct-1

Conversation

@Prestaplugins
Copy link
Contributor

@Prestaplugins Prestaplugins commented Jan 26, 2026

Questions Answers
Description? SQL query optimization, so "active" flag is only checked on viewed products instead of the whole catalog.
Type? improvement
BC breaks? no
Deprecations? no
Fixed ticket?
How to test? See beelow
Related Pr #37

How to test :
Activate the "Viewed product" module
Turn debug profiling ON
Enter a product page
Then go to another one
Check the query in the debug profiling, it must contains "AND p.id_product IN ( .... )" with a small number of rows returned.

@ps-jarvis

This comment was marked as off-topic.

@github-project-automation github-project-automation bot moved this to Ready for review in PR Dashboard Jan 26, 2026
jf-viguier
jf-viguier previously approved these changes Jan 26, 2026
@mohaidoss
Copy link

Perhaps it's better to keep the same method name, and the same default behavior which is a select without condition.

And only fair to co-author @joshjackson 😀

@Touxten
Copy link
Contributor

Touxten commented Jan 27, 2026

The addSqlRestriction method: accepts the first parameter as false only since 8.0.0. You must modify these files for the tests to work.

https://github.com/PrestaShop/ps_viewedproduct/tree/dev/tests/phpstan

- '#Parameter \#1 \$share of static method ShopCore::addSqlRestriction\(\) expects int, false given.#'

@mohaidoss

Perhaps it's better to keep the same method name

The method is private no problem but i aggree you. If someone has overridden the private method, their override will no longer work.

the same default behavior which is a select without condition.

The shop condition optilmize the request

@Touxten Touxten dismissed jf-viguier’s stale review January 27, 2026 08:16

Change on tests

The SQL query must use "product_shop" table, not "product"

Fix Test

Fiix PHPstan before PS 8.0.0

Keep the old name of the method
@Touxten Touxten force-pushed the Prestaplugins-ps_viewedproduct-1 branch from 31d5ec1 to 536c267 Compare January 27, 2026 09:00
@jf-viguier
Copy link
Contributor

@PrestaShop/qa-functional can we have your eyes here ? it's an easy one.

@mohaidoss
Copy link

Up voted

@SiraDIOP SiraDIOP self-assigned this Feb 4, 2026
Copy link

@SiraDIOP SiraDIOP left a comment

Choose a reason for hiding this comment

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

Hello @Prestaplugins,

Thanks for your PR,

I tested it and it's good for me

Enregistrement.de.l.ecran.2026-02-04.a.17.28.51.mov
Image

Thank you

@jf-viguier jf-viguier added this to the 1.2.6 milestone Feb 10, 2026
@jf-viguier jf-viguier merged commit 35df9c0 into PrestaShop:dev Feb 10, 2026
24 of 26 checks passed
@github-project-automation github-project-automation bot moved this from Ready for review to Merged in PR Dashboard Feb 10, 2026
@Progi1984 Progi1984 linked an issue Feb 10, 2026 that may be closed by this pull request
2 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

Archived in project

Development

Successfully merging this pull request may close these issues.

SQL query improvement to check active products

8 participants