Просмотр исходного кода

fix(core): Correctly populate Collections in channel

Michael Bromley 3 лет назад
Родитель
Сommit
58090bbc42

+ 1 - 2
packages/core/e2e/populate.e2e-spec.ts

@@ -188,8 +188,7 @@ describe('populate() function', () => {
         it('product also assigned to default channel', async () => {
             await adminClient.setChannelToken(E2E_DEFAULT_CHANNEL_TOKEN);
             const { products } = await adminClient.query<GetProductListQuery>(GET_PRODUCT_LIST);
-            expect(products.totalItems).toBe(1);
-            expect(products.items.map(i => i.name).sort()).toEqual(['Model Hand']);
+            expect(products.items.map(i => i.name).includes('Model Hand')).toBe(true);
         });
     });
 });

+ 3 - 2
packages/core/src/cli/populate.ts

@@ -87,15 +87,16 @@ export async function populate<T extends INestApplicationContext>(
         );
         if (importResult.errors && importResult.errors.length) {
             const errorFile = path.join(process.cwd(), 'vendure-import-error.log');
-            console.log(
+            Logger.error(
                 `${importResult.errors.length} errors encountered when importing product data. See: ${errorFile}`,
+                loggerCtx,
             );
             await fs.writeFile(errorFile, importResult.errors.join('\n'));
         }
 
         Logger.info(`Imported ${importResult.imported} products`, loggerCtx);
 
-        await populateCollections(app, initialData);
+        await populateCollections(app, initialData, channel);
     }
 
     Logger.info('Done!', loggerCtx);

+ 1 - 2
packages/core/src/data-import/providers/populator/populator.ts

@@ -122,8 +122,7 @@ export class Populator {
                     this.processFilterDefinition(filter, allFacetValues),
                 );
             } catch (e: any) {
-                // tslint:disable-next-line:no-console
-                console.log(e);
+                Logger.error(e.message);
             }
             const collection = await this.collectionService.create(ctx, {
                 translations: [