You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
chore(api,types): allow filtering on variant sku/barcode/ean/upc on both /store and /admin apis (#14826)
from both /admin and /store endpoints. Covers both /admin/products and /admin/products/:id/variants
## Summary
**What** — What changes are introduced in this PR?
add ability to filter products by variant `sku`/`ean`/`upc`/`barcode` in addition to `option`
**Why** — Why are these changes relevant or necessary?
for /store/products
These are real-world identities that a storefront might encounter from barcodes, qr-codes or other entities.
for /admin/products
it already had an option to filter by 'ean'/'upc' and 'barcode' but in larger setups, the SKU would be dictated by the ERP or Inventory system, so it makes it easier to react to environment events/webhooks to find the product/variant to deal with.
for /admin/product/:id/variant
it can now filter the skus by `sku=12356`
note: for /store, the `variants[sku]` already works, but was not reflected into the type system, so it didn't work/was suggested on the js-sdk.
**How** — How have these changes been implemented?
Updated validators and types
**Testing** — How have these changes been tested, or how can the reviewer test the feature?
Unittests provided for both /store and /admin
---
## Examples
Provide examples or code snippets that demonstrate how this feature works, or how it can be used in practice.
This helps with documentation and ensures maintainers can quickly understand and verify the change.
/store/products
```ts
const productResponse = await sdk.store.products.list({
variants: {
sku: 'SKU1234567'
}
});
```
/admin/products
```ts
const productResponse = await sdk.admin.products.list({
variants: {
sku: 'SKU1234567'
}
});
```
/admin/products/:id/variants
```
const productResponse = await sdk.admin.productVariants.list({
sku: 'SKU1234567'
});
```
---
## Checklist
Please ensure the following before requesting a review:
- [X] I have added a **changeset** for this PR
- Every non-breaking change should be marked as a **patch**
- To add a changeset, run `yarn changeset` and follow the prompts
- [X] The changes are covered by relevant **tests**
- [X] I have verified the code works as intended locally
- [X] I have linked the related issue(s) if applicable
---
## Additional Context
Add any additional context, related issues, or references that might help the reviewer understand this PR.
Co-authored-by: Nicolas Gorga <62995075+NicolasGorga@users.noreply.github.com>
0 commit comments