Skip to content

Commit

Permalink
Fix issue #2026 changed price not displayed for prod on grid page (#2064
Browse files Browse the repository at this point in the history
)

* Fix issue #2016 changed price not displayed for prod on grid page

* Add getVariantQuantity function to ProductRevision
  • Loading branch information
hrath2015 authored and mikemurray committed Apr 7, 2017
1 parent cc0b1b9 commit fae0078
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 2 deletions.
10 changes: 9 additions & 1 deletion imports/plugins/core/revisions/server/hooks.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ function convertMetadata(modifierObject) {
return metadata;
}

const ProductRevision = {
export const ProductRevision = {
getProductPriceRange(productId) {
const product = Products.findOne(productId);
if (!product) {
Expand Down Expand Up @@ -154,6 +154,14 @@ const ProductRevision = {
}
});
return variants;
},
getVariantQuantity(variant) {
const options = this.getVariants(variant._id);
if (options && options.length) {
return options.reduce((sum, option) =>
sum + option.inventoryQuantity || 0, 0);
}
return variant.inventoryQuantity || 0;
}
};

Expand Down
3 changes: 2 additions & 1 deletion server/methods/catalog.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@ import _ from "lodash";
import { EJSON } from "meteor/ejson";
import { check } from "meteor/check";
import { Meteor } from "meteor/meteor";
import { Catalog, copyFile, ReactionProduct } from "/lib/api";
import { copyFile, ReactionProduct } from "/lib/api";
import { ProductRevision as Catalog } from "/imports/plugins/core/revisions/server/hooks";
import { Media, Products, Revisions, Tags } from "/lib/collections";
import { Logger, Reaction } from "/server/api";

Expand Down

0 comments on commit fae0078

Please sign in to comment.