Skip to content

Commit

Permalink
add migration to publish all products to catalog
Browse files Browse the repository at this point in the history
This migration is an exact copy of migration #24. It will take all existing products and publish them to the catalog, which will in turn now publish the media to the variants
  • Loading branch information
kieckhafer committed Jul 20, 2018
1 parent 4c40d0d commit 2fcd0bc
Showing 1 changed file with 21 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
import { Migrations } from "meteor/percolate:migrations";
import Logger from "@reactioncommerce/logger";
import { Products } from "/lib/collections";
import collections from "/imports/collections/rawCollections";
import publishProductsToCatalog from "/imports/plugins/core/catalog/server/no-meteor/utils/publishProductsToCatalog";

Migrations.add({
version: 32,
up() {
const visiblePublishedProducts = Products.find({
ancestors: [],
isDeleted: { $ne: true },
isVisible: true,
type: "simple"
}, { _id: 1 }).map((product) => product._id);
const success = Promise.await(publishProductsToCatalog(visiblePublishedProducts, collections));
if (!success) {
Logger.error("Migration 32 failed to create catalog products for some published products.");
}
}
});

0 comments on commit 2fcd0bc

Please sign in to comment.