For both Wholesale and the new Fabrix channel for CG, we'd need to assign products to other channels. To be able to reuse things like this, we should create a publishable package in the plugins repository: "@pinelab/vendure-scripts"
It should expose functions that can be used on Vendure projects. To start, we'd need 2 functions:
assignAllProductsToChannel. A helper function that assigns all products of channel X to channel Y, including:
Facets and facetvalues connected to the products
Assets connected to the products
Anything else we might be missing?
assignProductsToChannel([1,3,4,5,6]) (list of product ids to assing to channel).
Some acceptance requirements:
These scripts will be run locally mostly, so no need to use jobqueue
It should be scalable for large projects: We should not load ALL products then assign all of them, but rather in batches.
Script should be idempotent: running the script multiple times should not break anything. It should just assign 1 product to the new channel once.
Example code
I imagine we have something like this.
import { assignAllProductsToChannel } from '@pinelab/vendure-scripts';
// Consumers load their Vendure app here first, before using our script, because we need them to load their .env and connect to their db etc.
await bootstrap();
await assignAllProductsToChannel(ctx, {
sourceChannelId: 1,
targetChannelId: 2,
});
For both Wholesale and the new Fabrix channel for CG, we'd need to assign products to other channels. To be able to reuse things like this, we should create a publishable package in the plugins repository: "@pinelab/vendure-scripts"
It should expose functions that can be used on Vendure projects. To start, we'd need 2 functions:
assignAllProductsToChannel
. A helper function that assigns all products of channel X to channel Y, including:assignProductsToChannel([1,3,4,5,6])
(list of product ids to assing to channel).Some acceptance requirements:
Example code
I imagine we have something like this.