Skip to content

[Discounts] Search overview #2773

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

Merged
merged 4 commits into from
Jun 11, 2025
Merged

[Discounts] Search overview #2773

merged 4 commits into from
Jun 11, 2025

Conversation

mnocon
Copy link
Contributor

@mnocon mnocon commented Jun 9, 2025

@mnocon mnocon force-pushed the discounts-search branch from afb0703 to 6b4511a Compare June 9, 2025 15:03
@mnocon mnocon force-pushed the discounts-search branch from 6b4511a to 307428e Compare June 9, 2025 15:07
Copy link

github-actions bot commented Jun 9, 2025

@mnocon mnocon marked this pull request as ready for review June 9, 2025 16:10
@mnocon mnocon requested review from Steveb-p and konradoboza June 9, 2025 16:10
Copy link
Contributor

@konradoboza konradoboza left a comment

Choose a reason for hiding this comment

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

One fundamental issue I was able to spot:

@mnocon
Copy link
Contributor Author

mnocon commented Jun 9, 2025

@konradoboza Your comment made me realise that I've presented it in a potentially confusing way.

When discounts are prioritized, cart discounts are applied before catalog discounts:
https://github.com/ibexa/discounts/blob/main/src/lib/DiscountPrioritizationStrategy.php#L24C17-L24C21

So in "prioritization" sense, cart ranks higher than catalog - as you write.

But the "Type" sort clause uses the ascending order by default - so if cart is returned first, then cart ranks lower than catalog, in "sort clause sorting" sense.

In my head I have an example like this:

  • cart - value 0
  • catalog - value 1

When sorting ascending, cart is returned before catalog - and catalog ranks "higher" than cart.
Lower ranks are returned first when sorting ascending - cart is returned before catalog.

I think this is where the confusion comes from - that the "prioritization" and "sort clause" rankings are inverted, thank for you for spotting how confusing it can be 😄

I've reworded it in bcc88ab , I hope it's better

@mnocon mnocon requested a review from konradoboza June 9, 2025 20:36
Copy link

github-actions bot commented Jun 9, 2025

code_samples/ change report

Before (on target branch)After (in current PR)

code_samples/discounts/src/Query/Search.php


code_samples/discounts/src/Query/Search.php

docs/search/discounts_search_reference/discounts_criteria.md@32:```php hl_lines="13-20"
docs/search/discounts_search_reference/discounts_criteria.md@33:[[= include_file('code_samples/discounts/src/Query/Search.php') =]]
docs/search/discounts_search_reference/discounts_criteria.md@34:```

001⫶<?php
002⫶
003⫶declare(strict_types=1);
004⫶
005⫶use Ibexa\Contracts\CoreSearch\Values\Query\Criterion\FieldValueCriterion;
006⫶use Ibexa\Contracts\Discounts\Value\Query\Criterion;
007⫶use Ibexa\Contracts\Discounts\Value\Query\DiscountQuery;
008⫶use Ibexa\Contracts\Discounts\Value\Query\SortClause;
009⫶
010⫶$now = new DateTimeImmutable();
011⫶
012⫶$query = new DiscountQuery(
013❇️ new Criterion\LogicalAnd(
014❇️ new Criterion\IsEnabledCriterion(),
015❇️ new Criterion\StartDateCriterion($now, FieldValueCriterion::COMPARISON_LTE),
016❇️ new Criterion\LogicalOr(
017❇️ new Criterion\EndDateCriterion($now, FieldValueCriterion::COMPARISON_GTE),
018❇️ new Criterion\EndDateCriterion(null, FieldValueCriterion::COMPARISON_EQ)
019❇️ ),
020❇️ ),
021⫶ [
022⫶ new SortClause\Type(),
023⫶ new SortClause\Priority(),
024⫶ new SortClause\CreatedAt(),
025⫶ ]
026⫶);
027⫶
028⫶/** @var \Ibexa\Contracts\Discounts\DiscountServiceInterface $discountService */
029⫶$results = $discountService->findDiscounts($query);

docs/search/discounts_search_reference/discounts_sort_clauses.md@25:```php hl_lines="22-24"
docs/search/discounts_search_reference/discounts_sort_clauses.md@26:[[= include_file('code_samples/discounts/src/Query/Search.php') =]]
docs/search/discounts_search_reference/discounts_sort_clauses.md@27:```

001⫶<?php
002⫶
003⫶declare(strict_types=1);
004⫶
005⫶use Ibexa\Contracts\CoreSearch\Values\Query\Criterion\FieldValueCriterion;
006⫶use Ibexa\Contracts\Discounts\Value\Query\Criterion;
007⫶use Ibexa\Contracts\Discounts\Value\Query\DiscountQuery;
008⫶use Ibexa\Contracts\Discounts\Value\Query\SortClause;
009⫶
010⫶$now = new DateTimeImmutable();
011⫶
012⫶$query = new DiscountQuery(
013⫶ new Criterion\LogicalAnd(
014⫶ new Criterion\IsEnabledCriterion(),
015⫶ new Criterion\StartDateCriterion($now, FieldValueCriterion::COMPARISON_LTE),
016⫶ new Criterion\LogicalOr(
017⫶ new Criterion\EndDateCriterion($now, FieldValueCriterion::COMPARISON_GTE),
018⫶ new Criterion\EndDateCriterion(null, FieldValueCriterion::COMPARISON_EQ)
019⫶ ),
020⫶ ),
021⫶ [
022❇️ new SortClause\Type(),
023❇️ new SortClause\Priority(),
024❇️ new SortClause\CreatedAt(),
025⫶ ]
026⫶);
027⫶
028⫶/** @var \Ibexa\Contracts\Discounts\DiscountServiceInterface $discountService */
029⫶$results = $discountService->findDiscounts($query);

Download colorized diff

@mnocon mnocon requested a review from a team June 10, 2025 06:56
@ezrobot ezrobot requested review from adriendupuis, dabrt and julitafalcondusza and removed request for a team June 10, 2025 06:56
Copy link
Contributor

@julitafalcondusza julitafalcondusza left a comment

Choose a reason for hiding this comment

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

Just a small remark.

Co-authored-by: julitafalcondusza <117284672+julitafalcondusza@users.noreply.github.com>
@mnocon mnocon merged commit 5a7a5cc into discounts Jun 11, 2025
4 of 6 checks passed
@mnocon mnocon deleted the discounts-search branch June 11, 2025 07:09
mnocon added a commit that referenced this pull request Jun 11, 2025
* [Discounts] Search overview

* Fixes before review

* Reworded Type sort clause

* Update docs/search/discounts_search_reference/discounts_sort_clauses.md

Co-authored-by: julitafalcondusza <117284672+julitafalcondusza@users.noreply.github.com>

---------

Co-authored-by: julitafalcondusza <117284672+julitafalcondusza@users.noreply.github.com>
mnocon added a commit that referenced this pull request Jun 11, 2025
* [Discounts] Search overview

* Fixes before review

* Reworded Type sort clause

* Update docs/search/discounts_search_reference/discounts_sort_clauses.md

Co-authored-by: julitafalcondusza <117284672+julitafalcondusza@users.noreply.github.com>

---------

Co-authored-by: julitafalcondusza <117284672+julitafalcondusza@users.noreply.github.com>
mnocon added a commit that referenced this pull request Jun 11, 2025
* [PHP API] Discounts (#2763)

* [PHP API REF] Added Discount packages

* Generated PHP API for Discounts

* Discount product guide

* Fixed links and navigation

* Removed nav

* Fixed links

* Fixed typo

* Fixed badges

* Removed whitespace

* Fixes before review

* After review fixes

* Currency remark

* Discount migrations (#2768)

* [Discounts] Added migration doc

* Added files

* Update docs/content_management/data_migration/importing_data.md

* Applied suggestions from code review (#2767)

Co-authored-by: julitafalcondusza <117284672+julitafalcondusza@users.noreply.github.com>

* [Discounts] Search overview (#2773)

* [Discounts] Search overview

* Fixes before review

* Reworded Type sort clause

* Update docs/search/discounts_search_reference/discounts_sort_clauses.md

Co-authored-by: julitafalcondusza <117284672+julitafalcondusza@users.noreply.github.com>

---------

Co-authored-by: julitafalcondusza <117284672+julitafalcondusza@users.noreply.github.com>

* [Discounts] Event reference (#2776)

* [Discounts] Added event reference

* Fixed links

* Fixes before review

* Removed column

* [Discounts] Mentioned discounts in pricing and customer groups (#2775)

* Mentioned discounts in pricing and customer groups

* Before review fixes

* Added mention to the PIM guide

* [Discounts] Discount policies (#2771)

* Permissions

* Build fixes

* Fixed links

* Fixed last links

* Removed link

* Apply suggestions from code review

Co-authored-by: julitafalcondusza <117284672+julitafalcondusza@users.noreply.github.com>

---------

Co-authored-by: julitafalcondusza <117284672+julitafalcondusza@users.noreply.github.com>

* Discounts update (#2774)

* Added update instructions

* Fixed link

---------

Co-authored-by: julitafalcondusza <117284672+julitafalcondusza@users.noreply.github.com>
mnocon added a commit that referenced this pull request Jun 11, 2025
* [PHP API] Discounts (#2763)

* [PHP API REF] Added Discount packages

* Generated PHP API for Discounts

* Discount product guide

* Fixed links and navigation

* Removed nav

* Fixed links

* Fixed typo

* Fixed badges

* Removed whitespace

* Fixes before review

* After review fixes

* Currency remark

* Discount migrations (#2768)

* [Discounts] Added migration doc

* Added files

* Update docs/content_management/data_migration/importing_data.md

* Applied suggestions from code review (#2767)

Co-authored-by: julitafalcondusza <117284672+julitafalcondusza@users.noreply.github.com>

* [Discounts] Search overview (#2773)

* [Discounts] Search overview

* Fixes before review

* Reworded Type sort clause

* Update docs/search/discounts_search_reference/discounts_sort_clauses.md

Co-authored-by: julitafalcondusza <117284672+julitafalcondusza@users.noreply.github.com>

---------

Co-authored-by: julitafalcondusza <117284672+julitafalcondusza@users.noreply.github.com>

* [Discounts] Event reference (#2776)

* [Discounts] Added event reference

* Fixed links

* Fixes before review

* Removed column

* [Discounts] Mentioned discounts in pricing and customer groups (#2775)

* Mentioned discounts in pricing and customer groups

* Before review fixes

* Added mention to the PIM guide

* [Discounts] Discount policies (#2771)

* Permissions

* Build fixes

* Fixed links

* Fixed last links

* Removed link

* Apply suggestions from code review

Co-authored-by: julitafalcondusza <117284672+julitafalcondusza@users.noreply.github.com>

---------

Co-authored-by: julitafalcondusza <117284672+julitafalcondusza@users.noreply.github.com>

* Discounts update (#2774)

* Added update instructions

* Fixed link

---------

Co-authored-by: julitafalcondusza <117284672+julitafalcondusza@users.noreply.github.com>
mnocon added a commit that referenced this pull request Jun 13, 2025
* [PHP API] Discounts (#2763)

* [PHP API REF] Added Discount packages

* Generated PHP API for Discounts

* Discount product guide

* Fixed links and navigation

* Removed nav

* Fixed links

* Fixed typo

* Fixed badges

* Removed whitespace

* Fixes before review

* After review fixes

* Currency remark

* Discount migrations (#2768)

* [Discounts] Added migration doc

* Added files

* Update docs/content_management/data_migration/importing_data.md

* Applied suggestions from code review (#2767)

Co-authored-by: julitafalcondusza <117284672+julitafalcondusza@users.noreply.github.com>

* [Discounts] Search overview (#2773)

* [Discounts] Search overview

* Fixes before review

* Reworded Type sort clause

* Update docs/search/discounts_search_reference/discounts_sort_clauses.md

Co-authored-by: julitafalcondusza <117284672+julitafalcondusza@users.noreply.github.com>

---------

Co-authored-by: julitafalcondusza <117284672+julitafalcondusza@users.noreply.github.com>

* [Discounts] Event reference (#2776)

* [Discounts] Added event reference

* Fixed links

* Fixes before review

* Removed column

* [Discounts] Mentioned discounts in pricing and customer groups (#2775)

* Mentioned discounts in pricing and customer groups

* Before review fixes

* Added mention to the PIM guide

* [Discounts] Discount policies (#2771)

* Permissions

* Build fixes

* Fixed links

* Fixed last links

* Removed link

* Apply suggestions from code review

Co-authored-by: julitafalcondusza <117284672+julitafalcondusza@users.noreply.github.com>

---------

Co-authored-by: julitafalcondusza <117284672+julitafalcondusza@users.noreply.github.com>

* Discounts update (#2774)

* Added update instructions

* Fixed link

* [Discounts] Described Twig Components

---------

Co-authored-by: julitafalcondusza <117284672+julitafalcondusza@users.noreply.github.com>
mnocon added a commit that referenced this pull request Jun 13, 2025
* [PHP API] Discounts (#2763)

* [PHP API REF] Added Discount packages

* Generated PHP API for Discounts

* Discount product guide

* Fixed links and navigation

* Removed nav

* Fixed links

* Fixed typo

* Fixed badges

* Removed whitespace

* Fixes before review

* After review fixes

* Currency remark

* Discount migrations (#2768)

* [Discounts] Added migration doc

* Added files

* Update docs/content_management/data_migration/importing_data.md

* Applied suggestions from code review (#2767)

Co-authored-by: julitafalcondusza <117284672+julitafalcondusza@users.noreply.github.com>

* [Discounts] Search overview (#2773)

* [Discounts] Search overview

* Fixes before review

* Reworded Type sort clause

* Update docs/search/discounts_search_reference/discounts_sort_clauses.md

Co-authored-by: julitafalcondusza <117284672+julitafalcondusza@users.noreply.github.com>

---------

Co-authored-by: julitafalcondusza <117284672+julitafalcondusza@users.noreply.github.com>

* [Discounts] Event reference (#2776)

* [Discounts] Added event reference

* Fixed links

* Fixes before review

* Removed column

* [Discounts] Mentioned discounts in pricing and customer groups (#2775)

* Mentioned discounts in pricing and customer groups

* Before review fixes

* Added mention to the PIM guide

* [Discounts] Discount policies (#2771)

* Permissions

* Build fixes

* Fixed links

* Fixed last links

* Removed link

* Apply suggestions from code review

Co-authored-by: julitafalcondusza <117284672+julitafalcondusza@users.noreply.github.com>

---------

Co-authored-by: julitafalcondusza <117284672+julitafalcondusza@users.noreply.github.com>

* Discounts update (#2774)

* Added update instructions

* Fixed link

* [Discounts] Added Twig reference

* Self review

* Apply suggestions from code review

Co-authored-by: julitafalcondusza <117284672+julitafalcondusza@users.noreply.github.com>

---------

Co-authored-by: julitafalcondusza <117284672+julitafalcondusza@users.noreply.github.com>
mnocon added a commit that referenced this pull request Jun 13, 2025
* [PHP API] Discounts (#2763)

* [PHP API REF] Added Discount packages

* Generated PHP API for Discounts

* Discount product guide

* Fixed links and navigation

* Removed nav

* Fixed links

* Fixed typo

* Fixed badges

* Removed whitespace

* Fixes before review

* After review fixes

* Currency remark

* Discount migrations (#2768)

* [Discounts] Added migration doc

* Added files

* Update docs/content_management/data_migration/importing_data.md

* Applied suggestions from code review (#2767)

Co-authored-by: julitafalcondusza <117284672+julitafalcondusza@users.noreply.github.com>

* [Discounts] Search overview (#2773)

* [Discounts] Search overview

* Fixes before review

* Reworded Type sort clause

* Update docs/search/discounts_search_reference/discounts_sort_clauses.md

Co-authored-by: julitafalcondusza <117284672+julitafalcondusza@users.noreply.github.com>

---------

Co-authored-by: julitafalcondusza <117284672+julitafalcondusza@users.noreply.github.com>

* [Discounts] Event reference (#2776)

* [Discounts] Added event reference

* Fixed links

* Fixes before review

* Removed column

* [Discounts] Mentioned discounts in pricing and customer groups (#2775)

* Mentioned discounts in pricing and customer groups

* Before review fixes

* Added mention to the PIM guide

* [Discounts] Discount policies (#2771)

* Permissions

* Build fixes

* Fixed links

* Fixed last links

* Removed link

* Apply suggestions from code review

Co-authored-by: julitafalcondusza <117284672+julitafalcondusza@users.noreply.github.com>

---------

Co-authored-by: julitafalcondusza <117284672+julitafalcondusza@users.noreply.github.com>

* Discounts update (#2774)

* Added update instructions

* Fixed link

* [Discounts] Added Twig reference

* Self review

* [Discounts] Release notes

* Added mention about the update

---------

Co-authored-by: julitafalcondusza <117284672+julitafalcondusza@users.noreply.github.com>
mnocon added a commit that referenced this pull request Jun 13, 2025
* [PHP API] Discounts (#2763)

* [PHP API REF] Added Discount packages

* Generated PHP API for Discounts

* Discount product guide

* Fixed links and navigation

* Removed nav

* Fixed links

* Fixed typo

* Fixed badges

* Removed whitespace

* Fixes before review

* After review fixes

* Currency remark

* Discount migrations (#2768)

* [Discounts] Added migration doc

* Added files

* Update docs/content_management/data_migration/importing_data.md

* Applied suggestions from code review (#2767)

Co-authored-by: julitafalcondusza <117284672+julitafalcondusza@users.noreply.github.com>

* [Discounts] Search overview (#2773)

* [Discounts] Search overview

* Fixes before review

* Reworded Type sort clause

* Update docs/search/discounts_search_reference/discounts_sort_clauses.md

Co-authored-by: julitafalcondusza <117284672+julitafalcondusza@users.noreply.github.com>

---------

Co-authored-by: julitafalcondusza <117284672+julitafalcondusza@users.noreply.github.com>

* [Discounts] Event reference (#2776)

* [Discounts] Added event reference

* Fixed links

* Fixes before review

* Removed column

* [Discounts] Mentioned discounts in pricing and customer groups (#2775)

* Mentioned discounts in pricing and customer groups

* Before review fixes

* Added mention to the PIM guide

* [Discounts] Discount policies (#2771)

* Permissions

* Build fixes

* Fixed links

* Fixed last links

* Removed link

* Apply suggestions from code review

Co-authored-by: julitafalcondusza <117284672+julitafalcondusza@users.noreply.github.com>

---------

Co-authored-by: julitafalcondusza <117284672+julitafalcondusza@users.noreply.github.com>

* Discounts update (#2774)

* Added update instructions

* Fixed link

* [Discounts] Described Twig Components

---------

Co-authored-by: julitafalcondusza <117284672+julitafalcondusza@users.noreply.github.com>
mnocon added a commit that referenced this pull request Jun 13, 2025
* [PHP API] Discounts (#2763)

* [PHP API REF] Added Discount packages

* Generated PHP API for Discounts

* Discount product guide

* Fixed links and navigation

* Removed nav

* Fixed links

* Fixed typo

* Fixed badges

* Removed whitespace

* Fixes before review

* After review fixes

* Currency remark

* Discount migrations (#2768)

* [Discounts] Added migration doc

* Added files

* Update docs/content_management/data_migration/importing_data.md

* Applied suggestions from code review (#2767)

Co-authored-by: julitafalcondusza <117284672+julitafalcondusza@users.noreply.github.com>

* [Discounts] Search overview (#2773)

* [Discounts] Search overview

* Fixes before review

* Reworded Type sort clause

* Update docs/search/discounts_search_reference/discounts_sort_clauses.md

Co-authored-by: julitafalcondusza <117284672+julitafalcondusza@users.noreply.github.com>

---------

Co-authored-by: julitafalcondusza <117284672+julitafalcondusza@users.noreply.github.com>

* [Discounts] Event reference (#2776)

* [Discounts] Added event reference

* Fixed links

* Fixes before review

* Removed column

* [Discounts] Mentioned discounts in pricing and customer groups (#2775)

* Mentioned discounts in pricing and customer groups

* Before review fixes

* Added mention to the PIM guide

* [Discounts] Discount policies (#2771)

* Permissions

* Build fixes

* Fixed links

* Fixed last links

* Removed link

* Apply suggestions from code review

Co-authored-by: julitafalcondusza <117284672+julitafalcondusza@users.noreply.github.com>

---------

Co-authored-by: julitafalcondusza <117284672+julitafalcondusza@users.noreply.github.com>

* Discounts update (#2774)

* Added update instructions

* Fixed link

* [Discounts] Added Twig reference

* Self review

* Apply suggestions from code review

Co-authored-by: julitafalcondusza <117284672+julitafalcondusza@users.noreply.github.com>

---------

Co-authored-by: julitafalcondusza <117284672+julitafalcondusza@users.noreply.github.com>
mnocon added a commit that referenced this pull request Jun 13, 2025
* [PHP API] Discounts (#2763)

* [PHP API REF] Added Discount packages

* Generated PHP API for Discounts

* Discount product guide

* Fixed links and navigation

* Removed nav

* Fixed links

* Fixed typo

* Fixed badges

* Removed whitespace

* Fixes before review

* After review fixes

* Currency remark

* Discount migrations (#2768)

* [Discounts] Added migration doc

* Added files

* Update docs/content_management/data_migration/importing_data.md

* Applied suggestions from code review (#2767)

Co-authored-by: julitafalcondusza <117284672+julitafalcondusza@users.noreply.github.com>

* [Discounts] Search overview (#2773)

* [Discounts] Search overview

* Fixes before review

* Reworded Type sort clause

* Update docs/search/discounts_search_reference/discounts_sort_clauses.md

Co-authored-by: julitafalcondusza <117284672+julitafalcondusza@users.noreply.github.com>

---------

Co-authored-by: julitafalcondusza <117284672+julitafalcondusza@users.noreply.github.com>

* [Discounts] Event reference (#2776)

* [Discounts] Added event reference

* Fixed links

* Fixes before review

* Removed column

* [Discounts] Mentioned discounts in pricing and customer groups (#2775)

* Mentioned discounts in pricing and customer groups

* Before review fixes

* Added mention to the PIM guide

* [Discounts] Discount policies (#2771)

* Permissions

* Build fixes

* Fixed links

* Fixed last links

* Removed link

* Apply suggestions from code review

Co-authored-by: julitafalcondusza <117284672+julitafalcondusza@users.noreply.github.com>

---------

Co-authored-by: julitafalcondusza <117284672+julitafalcondusza@users.noreply.github.com>

* Discounts update (#2774)

* Added update instructions

* Fixed link

* [Discounts] Added Twig reference

* Self review

* [Discounts] Release notes

* Added mention about the update

---------

Co-authored-by: julitafalcondusza <117284672+julitafalcondusza@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants