Skip to content

BRD-913#54

Merged
tomas862 merged 10 commits intomainfrom
BRD-913-1
Apr 2, 2026
Merged

BRD-913#54
tomas862 merged 10 commits intomainfrom
BRD-913-1

Conversation

@PauliusInvertus
Copy link
Copy Markdown
Contributor

@PauliusInvertus PauliusInvertus commented Mar 25, 2026

BRD-913

ShopifyAdapter now transforms Shopify product data into locale-suffixed fields (e.g. name_en-US, name_lt-LT) with real translations for title, description, and product type. Brand is replicated across locales (not translatable in Shopify). Without
locales, output stays backward compatible with plain field names. Variant attributes are keyed by locale when locales are present. Added filterConfig support to SearchSettingsRequestBuilder. Full declarative refactor using PHP 8.4 array functions. Comprehensive test coverage added.

@gemini-code-assist
Copy link
Copy Markdown

Summary of Changes

Hello, 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 significantly enhances the ShopifyAdapter by introducing robust multi-locale support for product data transformation, enabling the system to handle and present localized product information more effectively. It also extends the search settings functionality with a new filter configuration option, providing greater control over data filtering. These changes aim to improve the adaptability and feature set of the SDK, backed by modernized PHP practices and thorough testing.

Highlights

  • Multi-Locale Product Transformation: The ShopifyAdapter now transforms product data into locale-suffixed fields (e.g., name_en-US, name_lt-LT) with real translations for title, description, and product type, ensuring localized content delivery.
  • Brand and Product URL Handling: Brand information is replicated across all locales as it is not translatable in Shopify, and product URLs are also duplicated across locales when present.
  • Variant Attribute Localization: Variant attributes are now keyed by locale when locale information is provided, allowing for localized variant data.
  • Filter Configuration Support: Added support for an optional filterConfig parameter to the SearchSettingsRequest and SearchSettingsRequestBuilder for enhanced flexibility in search configurations.
  • Code Modernization and Testing: The codebase underwent a declarative refactor utilizing PHP 8.4 array functions, and comprehensive test coverage was added for the new and modified functionalities.

🧠 New Feature in Public Preview: You can now enable Memory to help Gemini Code Assist learn from your team's feedback. This makes future code reviews more consistent and personalized to your project's style. Click here to enable Memory in your admin console.

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.

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.

Copy link
Copy Markdown

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

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 significantly enhances the ShopifyAdapter by introducing comprehensive support for product localization, allowing for locale-specific names, descriptions, and product types. This involved refactoring the transformProduct method and adding several new private helper methods to manage locale-suffixed fields and translations. Additionally, the SearchSettingsRequest and SearchSettingsRequestBuilder classes were updated to incorporate a new filterConfig property, providing more flexible filtering options. New unit tests were added to cover both the ShopifyAdapter's localization features and the SearchSettings' filterConfig. A critical issue was identified where non-standard PHP functions (array_find and array_any) are used in the ShopifyAdapter without being defined, which will cause fatal errors.

@PauliusInvertus
Copy link
Copy Markdown
Contributor Author

@claude review

@claude
Copy link
Copy Markdown

claude bot commented Mar 25, 2026

Claude encountered an error —— View job


I'll analyze this and get back to you.

@PauliusInvertus
Copy link
Copy Markdown
Contributor Author

@claude review

@claude
Copy link
Copy Markdown

claude bot commented Mar 26, 2026

Claude finished @PauliusInvertus's task in 2m 6s —— View job


Code Review

  • Gather context
  • Read changed files
  • Analyze code
  • Post review feedback

Overall this is a well-structured PR with good test coverage. One piece of Gemini's review needs correcting, plus a few real issues below.

Gemini's "Critical" Issues Are Not Issues

Gemini flagged array_find (line 232) and array_any (line 382) as non-standard — this is incorrect. Both were introduced as standard PHP 8.4 functions. Since this codebase targets PHP 8.4+, the usage is correct and intentional (as the PR description also states: "Full declarative refactor using PHP 8.4 array functions").


Real Issues Found

1. Redundant double normalization — src/Adapters/ShopifyAdapter.php:48-51

LocaleNormalizer::normalizeAll($locales) is called twice for the same input:

$normalizedLocales = ! empty($locales) ? LocaleNormalizer::normalizeAll($locales) : [];
$localeMap = ! empty($locales)
    ? array_combine(LocaleNormalizer::normalizeAll($locales), $locales)  // ← redundant
    : [];

The second call can reuse $normalizedLocales:

$localeMap = ! empty($locales) ? array_combine($normalizedLocales, $locales) : [];

Fix this →

2. Duplicate locales not guarded — src/Adapters/ShopifyAdapter.php:50

array_combine with duplicate keys silently drops entries. If a caller passes ['en', 'en'], the locale map would have a single 'en-US' entry and the second variant would be lost silently. Consider deduplicating before building the map:

$locales = array_values(array_unique($locales));

3. description_{$locale} can be empty string in locale mode — src/Adapters/ShopifyAdapter.php:160-163

In non-locale mode (buildPlainFields), an empty description is omitted (null → filtered out). In locale mode, $fields["description_{$locale}"] is always set, even as an empty string. This asymmetry may cause downstream consumers to receive an empty description_en-US field where they'd receive nothing without locales.

Consider: $fields["description_{$locale}"] = ($translatedDesc !== null ? strip_tags($translatedDesc) : $description) ?: null; and skip setting it if null. Fix this →

4. Missing withFilterConfig() wither method — src/V2/ValueObjects/SearchSettings/SearchSettingsRequest.php

The class has withAppId(), withSearchConfig(), withScoringConfig(), and withResponseConfig() — but no withFilterConfig(). Without it, callers cannot use the immutable update pattern to add a filter config to an existing request.

Fix this →


Minor Notes

  • extractImages with one image (src/Adapters/ShopifyAdapter.php:413): When there's exactly one image, medium and small both resolve to the same URL (floor(1/2) == 0). Not a bug, but worth a comment explaining the intention.

  • transformVariants throwing ValidationException for missing IDs (line 433): This bubbles up as a transformation_error for the whole product (caught at line 73), not just the variant. A malformed variant SKUs out the entire product rather than being individually skipped. Consider whether variant-level errors should be collected separately.

  • Test helper makeShopifyResponse: Passes primaryLocale to $data['locales']['primary'] but leaves it as null in $data when not provided. The fallback at ShopifyAdapter:53 works correctly for this case — just noting it for clarity.


Summary

The feature itself is solid: locale-suffix field generation, clean fallback to primary locale, brand non-translatability, backward compatibility, and good test coverage. The filterConfig addition to the builder/request is clean. Resolve the 4 real issues above before merging.

tomas862
tomas862 previously approved these changes Apr 2, 2026
@tomas862 tomas862 merged commit ee05f48 into main Apr 2, 2026
3 checks passed
@tomas862 tomas862 deleted the BRD-913-1 branch April 2, 2026 08:52
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.

2 participants