Thanks to visit codestin.com
Credit goes to Github.com

Skip to content

Conversation

@amitraj2203
Copy link
Contributor

@amitraj2203 amitraj2203 commented Jan 15, 2026

Submission Review Guidelines:

Changes proposed in this Pull Request:

Closes #62368

Screenshots or screen recordings:

Screen.Recording.2026-01-15.at.7.06.19.PM.mov

How to test the changes in this Pull Request:

Using the WooCommerce Testing Instructions Guide, include your detailed testing instructions:

  1. Create a new post.
  2. Add the Product Collection block and select the Products by Brands collection.
  3. Ensure the initial/empty state of the block displays No products to display.
  4. Save the post without selecting any brand and ensure the empty block is not rendered on the front end.
  5. Try adjusting the filters in the block settings panel.
  6. Use the top-most control in the Inspector Controls to choose brands to display products.
  7. Ensure the products associated with the brands are preserved in both the editor and front end.

Testing that has already taken place:

Milestone

Note: Check the box above to have the milestone automatically assigned when merged.
Alternatively (e.g. for point releases), manually assign the appropriate milestone.

Changelog entry

  • Automatically create a changelog entry from the details below.
  • This Pull Request does not require a changelog entry. (Comment required below)
Changelog Entry Details

Significance

  • Patch
  • Minor
  • Major

Type

  • Fix - Fixes an existing bug
  • Add - Adds functionality
  • Update - Update existing functionality
  • Dev - Development related task
  • Tweak - A minor adjustment to the codebase
  • Performance - Address performance issues
  • Enhancement - Improvement to existing functionality

Message

Changelog Entry Comment

Comment

@github-actions github-actions bot added type: community contribution plugin: woocommerce Issues related to the WooCommerce Core plugin. labels Jan 15, 2026
@amitraj2203 amitraj2203 marked this pull request as ready for review January 15, 2026 13:43
@woocommercebot woocommercebot requested review from a team, ObliviousHarmony, dinhtungdu and straku and removed request for a team January 15, 2026 13:43
@github-actions
Copy link
Contributor

github-actions bot commented Jan 15, 2026

Testing Guidelines

Hi @woocommerce/rubik,

Apart from reviewing the code changes, please make sure to review the testing instructions (Guide) and verify that relevant tests (E2E, Unit, Integration, etc.) have been added or updated as needed.

Reminder: PR reviewers are required to document testing performed. This includes:

  • 🖼️ Screenshots or screen recordings.
  • 📝 List of functionality tested / steps followed.
  • 🌐 Site details (environment attributes such as hosting type, plugins, theme, store size, store age, and relevant settings).
  • 🔍 Any analysis performed, such as assessing potential impacts on environment attributes and other plugins, conducting performance profiling, or using LLM/AI-based analysis.

⚠️ Within the testing details you provide, please ensure that no sensitive information (such as API keys, passwords, user data, etc.) is included in this public issue.

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Jan 15, 2026

📝 Walkthrough

Walkthrough

Adds a new "Products by Brand" product-collection to WooCommerce: client block definition and registration, inspector taxonomy support, CoreCollectionNames enum entry, PHP handler registration, and a PHPUnit test validating brand-based queries.

Changes

Cohort / File(s) Summary
Changelog
plugins/woocommerce/changelog/62368-add-products-by-brand-collection
New changelog entry documenting the minor addition.
Client block: definition
plugins/woocommerce/client/blocks/assets/js/blocks/product-collection/collections/by-brand.tsx
New collection export defining name, title, icon, description, scope, attributes (flex layout, 5 cols), innerBlocks (centered H2 heading, product template, pagination), and hideControls.
Client block: registration
plugins/woocommerce/client/blocks/assets/js/blocks/product-collection/collections/index.tsx
Imports by-brand and inserts it into the collections array (positioned after byTag).
Inspector / taxonomy controls
plugins/woocommerce/client/blocks/assets/js/blocks/product-collection/edit/inspector-controls/index.tsx, .../taxonomy-controls/use-taxonomy-controls.tsx
Expands taxonomy applicability to include BY_BRAND, updates conditional rendering/labels, and adds BY_BRAND branch to taxonomy filtering logic.
Types
plugins/woocommerce/client/blocks/assets/js/blocks/product-collection/types.ts
Adds enum member BY_BRAND = 'woocommerce/product-collection/by-brand'.
Backend handler
plugins/woocommerce/src/Blocks/BlockTypes/ProductCollection/HandlerRegistry.php
Registers handler for woocommerce/product-collection/by-brand that returns empty results when no brand selected, mirrors existing category/tag handler behavior.
Tests
plugins/woocommerce/tests/php/src/Blocks/BlockTypes/ProductCollection/QueryBuilder.php
Adds test_collection_by_brand() creating brand terms and products, asserting correct filtering for Nike/Adidas in both frontend and editor contexts, and cleaning up test data.

Sequence Diagram(s)

sequenceDiagram
  participant Editor as Editor UI
  participant Inspector as Inspector Controls
  participant ClientBlock as Product Collection Block
  participant Backend as PHP Handler
  participant DB as Database

  Editor->>ClientBlock: insert "Products by Brand" collection
  Editor->>Inspector: open taxonomy panel
  Inspector->>ClientBlock: select brand (e.g., "Nike")
  ClientBlock->>Backend: request products filtered by brand
  Backend->>DB: query products with product_brand = "Nike"
  DB-->>Backend: return matching products
  Backend-->>ClientBlock: return product list
  ClientBlock-->>Editor: render products and pagination
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly and concisely summarizes the main change: adding a 'Products by Brand' collection to the Product Collection block, which aligns with all modifications in the changeset.
Description check ✅ Passed The description is related to the changeset, providing testing instructions, context, and linking to issue #62368 that this PR addresses.
Linked Issues check ✅ Passed The PR successfully implements all requirements from issue #62368: introduces a 'Products by Brand' collection option using the same approach as category and tag collections.
Out of Scope Changes check ✅ Passed All changes are directly related to implementing the 'Products by Brand' collection feature; no out-of-scope modifications detected.
Docstring Coverage ✅ Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing touches
  • 📝 Generate docstrings

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link
Contributor

@kmanijak kmanijak left a comment

Choose a reason for hiding this comment

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

It's looking good! Thanks a lot for this contribution!

I left some minor comment and one open question (I don't have a strong opinion so let's discuss briefly). Once resolved, I'll be happy to merge the PR! 🙌

@straku straku removed their request for review January 15, 2026 16:05
@dinhtungdu dinhtungdu removed their request for review January 16, 2026 02:19
@kmanijak kmanijak self-requested a review January 19, 2026 09:00
Copy link
Contributor

@kmanijak kmanijak left a comment

Choose a reason for hiding this comment

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

Thanks for answering to my comments! There's just one lint error remaining and let's ship it 🚢 !

Copy link
Contributor

@kmanijak kmanijak left a comment

Choose a reason for hiding this comment

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

Thanks for super quick reaction! Let's merge it!

@kmanijak kmanijak merged commit 5e7d832 into woocommerce:trunk Jan 19, 2026
49 checks passed
@github-actions github-actions bot added this to the 10.6.0 milestone Jan 19, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

plugin: woocommerce Issues related to the WooCommerce Core plugin. type: community contribution

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Product Collection: Introduce Products by Brand

2 participants