Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions .changeset/four-sides-press.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
---
"@saleor/configurator": patch
---

Added support for product channel listings and fixed entity identification issues

- Products and variants can now be configured with channel-specific pricing and visibility settings
- Fixed duplicate detection by using slugs as identifiers for categories, channels, and products instead of names
- Enables multi-channel commerce with per-channel product availability and pricing
8 changes: 5 additions & 3 deletions src/core/diff/comparators/product-comparator.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ describe("ProductComparator", () => {

const sampleProduct = {
name: "Sample Product",
slug: "sample-product",
productType: "Clothing",
category: "Apparel",
attributes: {
Expand All @@ -31,7 +32,7 @@ describe("ProductComparator", () => {
expect(results[0]).toEqual({
operation: "CREATE",
entityType: "Products",
entityName: "Sample Product",
entityName: "sample-product",
desired: sampleProduct,
});
});
Expand All @@ -46,7 +47,7 @@ describe("ProductComparator", () => {
expect(results[0]).toEqual({
operation: "DELETE",
entityType: "Products",
entityName: "Sample Product",
entityName: "sample-product",
current: sampleProduct,
});
});
Expand All @@ -64,7 +65,7 @@ describe("ProductComparator", () => {
expect(results).toHaveLength(1);
expect(results[0].operation).toBe("UPDATE");
expect(results[0].entityType).toBe("Products");
expect(results[0].entityName).toBe("Sample Product");
expect(results[0].entityName).toBe("sample-product");
expect(results[0].changes).toContainEqual({
field: "productType",
currentValue: "Clothing",
Expand Down Expand Up @@ -131,6 +132,7 @@ describe("ProductComparator", () => {
it("should handle products with no attributes", () => {
const productWithoutAttributes = {
name: "Simple Product",
slug: "simple-product",
productType: "Simple",
category: "Basic",
variants: [],
Expand Down
7 changes: 5 additions & 2 deletions src/core/diff/comparators/product-comparator.ts
Original file line number Diff line number Diff line change
Expand Up @@ -58,10 +58,13 @@ export class ProductComparator extends BaseEntityComparator<
}

/**
* Gets the name of a product entity
* Gets the identifier of a product entity (uses slug for identification)
*/
protected getEntityName(entity: ProductEntity): string {
return entity.name;
if (!entity.slug) {
throw new Error("Product must have a valid slug");
}
return entity.slug;
}

/**
Expand Down
Loading