Skip to content

Commit a403402

Browse files
authored
Merge pull request #100 from saleor/fix-setting-attribute-values-on-products-and-channel-listings
fix: implement channel listings for products and variants
2 parents 0f80116 + 8f89f17 commit a403402

File tree

6 files changed

+833
-16
lines changed

6 files changed

+833
-16
lines changed

.changeset/four-sides-press.md

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
---
2+
"@saleor/configurator": patch
3+
---
4+
5+
Added support for product channel listings and fixed entity identification issues
6+
7+
- Products and variants can now be configured with channel-specific pricing and visibility settings
8+
- Fixed duplicate detection by using slugs as identifiers for categories, channels, and products instead of names
9+
- Enables multi-channel commerce with per-channel product availability and pricing

src/core/diff/comparators/product-comparator.test.ts

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ describe("ProductComparator", () => {
66

77
const sampleProduct = {
88
name: "Sample Product",
9+
slug: "sample-product",
910
productType: "Clothing",
1011
category: "Apparel",
1112
attributes: {
@@ -31,7 +32,7 @@ describe("ProductComparator", () => {
3132
expect(results[0]).toEqual({
3233
operation: "CREATE",
3334
entityType: "Products",
34-
entityName: "Sample Product",
35+
entityName: "sample-product",
3536
desired: sampleProduct,
3637
});
3738
});
@@ -46,7 +47,7 @@ describe("ProductComparator", () => {
4647
expect(results[0]).toEqual({
4748
operation: "DELETE",
4849
entityType: "Products",
49-
entityName: "Sample Product",
50+
entityName: "sample-product",
5051
current: sampleProduct,
5152
});
5253
});
@@ -64,7 +65,7 @@ describe("ProductComparator", () => {
6465
expect(results).toHaveLength(1);
6566
expect(results[0].operation).toBe("UPDATE");
6667
expect(results[0].entityType).toBe("Products");
67-
expect(results[0].entityName).toBe("Sample Product");
68+
expect(results[0].entityName).toBe("sample-product");
6869
expect(results[0].changes).toContainEqual({
6970
field: "productType",
7071
currentValue: "Clothing",
@@ -131,6 +132,7 @@ describe("ProductComparator", () => {
131132
it("should handle products with no attributes", () => {
132133
const productWithoutAttributes = {
133134
name: "Simple Product",
135+
slug: "simple-product",
134136
productType: "Simple",
135137
category: "Basic",
136138
variants: [],

src/core/diff/comparators/product-comparator.ts

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -58,10 +58,13 @@ export class ProductComparator extends BaseEntityComparator<
5858
}
5959

6060
/**
61-
* Gets the name of a product entity
61+
* Gets the identifier of a product entity (uses slug for identification)
6262
*/
6363
protected getEntityName(entity: ProductEntity): string {
64-
return entity.name;
64+
if (!entity.slug) {
65+
throw new Error("Product must have a valid slug");
66+
}
67+
return entity.slug;
6568
}
6669

6770
/**

0 commit comments

Comments
 (0)