diff --git a/packages/api-plugin-products/src/index.js b/packages/api-plugin-products/src/index.js index 0041898cec5..b66b1e1172d 100644 --- a/packages/api-plugin-products/src/index.js +++ b/packages/api-plugin-products/src/index.js @@ -33,8 +33,8 @@ export default async function register(app) { [{ hashtags: 1 }, { name: "c2_hashtags" }], [{ shopId: 1 }, { name: "c2_shopId" }], [{ "workflow.status": 1 }, { name: "c2_workflow.status" }], - [{ createdAt: 1, shopId: 1 }, { name: "c2_createdAt_shopId" }], - [{ updatedAt: 1, shopId: 1 }, { name: "c2_updatedAt_shopId" }], + [{ createdAt: 1, shopId: 1, ancestors: 1 }, { name: "c2_createdAt_shopId_ancestors" }], + [{ updatedAt: 1, shopId: 1, ancestors: 1 }, { name: "c2_updatedAt_shopId_ancestors" }], // Use _id as second sort to force full stability [{ updatedAt: 1, _id: 1 }] ] diff --git a/packages/api-plugin-products/src/utils/applyProductFilters.js b/packages/api-plugin-products/src/utils/applyProductFilters.js index 5bcc1862644..e48d5e864c1 100644 --- a/packages/api-plugin-products/src/utils/applyProductFilters.js +++ b/packages/api-plugin-products/src/utils/applyProductFilters.js @@ -103,7 +103,7 @@ export default function applyProductFilters(context, productFilters) { // Init default selector - Everyone can see products that fit this selector let selector = { - ancestors: [], // Lookup top-level products + ancestors: { $size: 0 }, // Lookup top-level products isDeleted: { $ne: true } // by default, we don't publish deleted products };