Skip to content

feature / pagination-info-get-by-ids-must-be-respected#35

Merged
tomas862 merged 1 commit into
mainfrom
feature/pagination-info-get-by-ids-must-be-respected
Dec 17, 2025
Merged

feature / pagination-info-get-by-ids-must-be-respected#35
tomas862 merged 1 commit into
mainfrom
feature/pagination-info-get-by-ids-must-be-respected

Conversation

@tomas862

Copy link
Copy Markdown
Member

we cant trust our chunking by ids logic. Therefore we must implement pagination

@gemini-code-assist

Copy link
Copy Markdown

Summary of Changes

Hello @tomas862, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!

This pull request introduces robust pagination capabilities to the getByIdsQuery method, addressing previous limitations with unreliable chunking logic when retrieving products by their IDs. By integrating pageSize and currentPage parameters, the change enables more efficient and controlled data fetching from the Magento API, ensuring that large product datasets can be retrieved reliably and without issues.

Highlights

  • Pagination Support for getByIdsQuery: The getByIdsQuery method now officially supports pagination, allowing users to specify pageSize and currentPage parameters when fetching products by their IDs.
  • GraphQL Query Update: The underlying GraphQL query for GetProductsByIds has been modified to accept and utilize the pageSize and currentPage arguments, ensuring that the Magento API returns paginated results.
  • Documentation Updates: Both the src/Adapters/README.md and the PHPDoc for MagentoProductQuery.php have been updated to reflect the new pagination capabilities and provide examples of their usage.
Using Gemini Code Assist

The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.

Invoking Gemini

You can request assistance from Gemini at any point by creating a comment using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in pull request comments and review comments.
Help /gemini help Displays a list of available commands.

Customization

To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.

Limitations & Feedback

Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here.

You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension.

Footnotes

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Code Review

This pull request adds pagination support to the getByIdsQuery for Magento products. The changes correctly update the GraphQL query and the corresponding documentation. However, the current implementation for getByIdsQuery uses a specific $ids variable, which is inconsistent with other queries like getDefaultQuery that use a generic $filter variable. This inconsistency prevents the use of getByIdsQuery with the existing MagentoQueryBuilder and MagentoPaginatedFetcher, which could be a significant limitation. My review includes a suggestion to refactor buildByIdsQuery to use the $filter variable, which would improve consistency and integration with the rest of the SDK. I've also included related suggestions to update the documentation to match this proposed change.

Comment on lines +220 to +221
query GetProductsByIds(\$ids: [String!], \$pageSize: Int, \$currentPage: Int) {
products(filter: { entity_id: { in: \$ids } }, pageSize: \$pageSize, currentPage: \$currentPage) {

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

high

For better consistency with other queries like getDefaultQuery and to ensure compatibility with MagentoQueryBuilder and MagentoPaginatedFetcher, I suggest changing this query to accept a generic $filter variable instead of a specific $ids variable. This would make it possible to use the paginated fetcher for fetching products by IDs. The query name GetProductsByIds can be kept to distinguish it from GetProducts.

With this change, the caller would be responsible for building the filter, e.g., ['filter' => ['entity_id' => ['in' => $ids]]]. This aligns with how other filters are used in the SDK.

query GetProductsByIds(\$filter: ProductAttributeFilterInput, \$pageSize: Int, \$currentPage: Int) {
    products(filter: \$filter, pageSize: \$pageSize, currentPage: \$currentPage) {

Comment thread src/Adapters/README.md
Comment on lines +395 to +399
$variables = [
'ids' => ['325465', '1924192', '1924190'],
'pageSize' => 100,
'currentPage' => 1
];

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

medium

If you apply the suggestion to use a $filter variable in buildByIdsQuery, this example should be updated to show how to use the $filter variable to specify product IDs.

Suggested change
$variables = [
'ids' => ['325465', '1924192', '1924190'],
'pageSize' => 100,
'currentPage' => 1
];
$variables = [
'filter' => ['entity_id' => ['in' => ['325465', '1924192', '1924190']]],
'pageSize' => 100,
'currentPage' => 1
];

Comment thread src/Adapters/README.md
|--------|-----------|-------------|----------|
| `getDefaultQuery()` | `$filter`, `$pageSize`, `$currentPage` | Full (all fields) | Standard product sync |
| `getByIdsQuery()` | `$ids: [String!]` | Full (all fields) | Fetch specific products by ID |
| `getByIdsQuery()` | `$ids: [String!]`, `$pageSize`, `$currentPage` | Full (all fields) | Fetch specific products by ID |

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

medium

If you apply the suggestion to use a $filter variable in buildByIdsQuery, this part of the documentation should be updated to reflect that the query uses $filter instead of $ids.

Suggested change
| `getByIdsQuery()` | `$ids: [String!]`, `$pageSize`, `$currentPage` | Full (all fields) | Fetch specific products by ID |
| `getByIdsQuery()` | `$filter`, `$pageSize`, `$currentPage` | Full (all fields) | Fetch specific products by ID |

Comment on lines +37 to +41
* $variables = [
* 'ids' => ['325465', '1924192', '1924190'],
* 'pageSize' => 100,
* 'currentPage' => 1
* ];

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

medium

If you apply the suggestion to use a $filter variable in buildByIdsQuery, this example should be updated to show how to use the $filter variable to specify product IDs.

 * $variables = [
 *     'filter' => ['entity_id' => ['in' => ['325465', '1924192', '1924190']]],
 *     'pageSize' => 100,
 *     'currentPage' => 1
 * ];

Comment on lines 157 to +159
* - $ids: [String!] (e.g., ["325465", "1924192", "1924190"])
* - $pageSize: Int (e.g., 100)
* - $currentPage: Int (e.g., 1)

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

medium

If you apply the suggestion to use a $filter variable in buildByIdsQuery, this documentation should be updated to reflect that. The primary variable for filtering would be $filter.

     * - $filter: ProductAttributeFilterInput (e.g., {"entity_id": {"in": ["325465", "1924192"]}})
     * - $pageSize: Int (e.g., 100)
     * - $currentPage: Int (e.g., 1)

@tomas862 tomas862 merged commit 3b13ecc into main Dec 17, 2025
6 of 7 checks passed
@tomas862 tomas862 deleted the feature/pagination-info-get-by-ids-must-be-respected branch December 17, 2025 10:33
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant