Skip to content
This repository has been archived by the owner on Feb 23, 2024. It is now read-only.

Fix SKU search in the Store API #4469

Merged
merged 2 commits into from
Jul 20, 2021
Merged

Fix SKU search in the Store API #4469

merged 2 commits into from
Jul 20, 2021

Conversation

mikejolley
Copy link
Member

I discovered that the SKU searching code in the Store API was never ran. This is due to using the wrong variable name (WP Query uses s, but we were looking for search ).

Since we actually want to control the search, we should map this to search so we can search on the product title and SKU without WP_Query interfering with things.

I have added a test to check SKU search is functional.

How to test the changes in this Pull Request:

Try some search requests via the Store API, for example:

https://store.local/wp-json/wc/store/products?search=woo-album

Ensure matched results match your query. Try searching for both titles and SKUs.

Changelog

Fixed the SKU search on the /wc/store/products endpoint.

@mikejolley mikejolley added status: needs review focus: rest api Work impacting REST api routes. labels Jul 14, 2021
@mikejolley mikejolley self-assigned this Jul 14, 2021
@mikejolley mikejolley requested a review from a team as a code owner July 14, 2021 21:53
@mikejolley mikejolley requested review from ralucaStan and removed request for a team July 14, 2021 21:53
@github-actions
Copy link
Contributor

Size Change: 0 B

Total Size: 961 kB

ℹ️ View Unchanged
Filename Size
build/active-filters-frontend.js 8.28 kB
build/active-filters.js 7.84 kB
build/all-products-frontend.js 23 kB
build/all-products.js 37.5 kB
build/all-reviews.js 9.61 kB
build/atomic-block-components/add-to-cart--atomic-block-components/button--atomic-block-components/image---a7e2bb9b.js 2.56 kB
build/atomic-block-components/add-to-cart--atomic-block-components/button.js 1.82 kB
build/atomic-block-components/add-to-cart--atomic-block-components/image--atomic-block-components/title.js 333 B
build/atomic-block-components/add-to-cart-frontend.js 8.65 kB
build/atomic-block-components/add-to-cart.js 7.72 kB
build/atomic-block-components/button-frontend.js 1.74 kB
build/atomic-block-components/button.js 873 B
build/atomic-block-components/category-list-frontend.js 469 B
build/atomic-block-components/category-list.js 477 B
build/atomic-block-components/image-frontend.js 1.87 kB
build/atomic-block-components/image.js 1.34 kB
build/atomic-block-components/price-frontend.js 2.09 kB
build/atomic-block-components/price.js 2.11 kB
build/atomic-block-components/rating-frontend.js 562 B
build/atomic-block-components/rating.js 568 B
build/atomic-block-components/sale-badge-frontend.js 856 B
build/atomic-block-components/sale-badge.js 868 B
build/atomic-block-components/sku-frontend.js 388 B
build/atomic-block-components/sku.js 393 B
build/atomic-block-components/stock-indicator-frontend.js 610 B
build/atomic-block-components/stock-indicator.js 611 B
build/atomic-block-components/summary-frontend.js 906 B
build/atomic-block-components/summary.js 912 B
build/atomic-block-components/tag-list-frontend.js 465 B
build/atomic-block-components/tag-list.js 471 B
build/atomic-block-components/title-frontend.js 1.43 kB
build/atomic-block-components/title.js 1.28 kB
build/attribute-filter-frontend.js 18 kB
build/attribute-filter.js 11.8 kB
build/blocks-checkout.js 20.2 kB
build/cart-frontend.js 78.3 kB
build/cart.js 45.8 kB
build/checkout-frontend.js 82.6 kB
build/checkout.js 48.1 kB
build/featured-category.js 7.39 kB
build/featured-product.js 9.54 kB
build/handpicked-products.js 6.55 kB
build/price-filter-frontend.js 14.3 kB
build/price-filter.js 9.57 kB
build/price-format.js 1.38 kB
build/product-best-sellers.js 6.73 kB
build/product-categories.js 3.39 kB
build/product-category.js 7.59 kB
build/product-new.js 6.88 kB
build/product-on-sale.js 7.23 kB
build/product-search.js 2.67 kB
build/product-tag.js 6.69 kB
build/product-top-rated.js 6.85 kB
build/products-by-attribute.js 7.81 kB
build/reviews-by-category.js 11.6 kB
build/reviews-by-product.js 13.1 kB
build/reviews-frontend.js 9.22 kB
build/single-product-frontend.js 25.7 kB
build/single-product.js 9.86 kB
build/vendors--atomic-block-components/price-frontend.js 5.71 kB
build/wc-blocks-data.js 10.9 kB
build/wc-blocks-editor-style-rtl.css 14.9 kB
build/wc-blocks-editor-style.css 14.9 kB
build/wc-blocks-google-analytics.js 1.99 kB
build/wc-blocks-middleware.js 1.48 kB
build/wc-blocks-registry.js 2.75 kB
build/wc-blocks-shared-context.js 1.54 kB
build/wc-blocks-shared-hocs.js 1.75 kB
build/wc-blocks-style-rtl.css 19.3 kB
build/wc-blocks-style.css 19.3 kB
build/wc-blocks-vendors-style-rtl.css 1.05 kB
build/wc-blocks-vendors-style.css 1.05 kB
build/wc-blocks-vendors.js 235 kB
build/wc-blocks.js 3.51 kB
build/wc-payment-method-bacs.js 812 B
build/wc-payment-method-cheque.js 807 B
build/wc-payment-method-cod.js 903 B
build/wc-payment-method-paypal.js 844 B
build/wc-payment-method-stripe.js 12.3 kB
build/wc-settings.js 2.93 kB

compressed-size-action

@ralucaStan
Copy link
Contributor

This tests out good.
I recommend somebody else's 👀 to double-check the PHP code.

Copy link
Contributor

@Aljullu Aljullu left a comment

Choose a reason for hiding this comment

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

Confirming it's testing well and changes look safe based on the discussion we had yesterday.

@github-actions github-actions bot added this to the 5.6.0 milestone Jul 16, 2021
@mikejolley mikejolley merged commit bb5a6da into trunk Jul 20, 2021
@mikejolley mikejolley deleted the fix/sku-search branch July 20, 2021 15:31
@Aljullu Aljullu added the type: bug The issue/PR concerns a confirmed bug. label Aug 2, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
focus: rest api Work impacting REST api routes. type: bug The issue/PR concerns a confirmed bug.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants