Skip to content
This repository has been archived by the owner on May 5, 2022. It is now read-only.

Commit

Permalink
Add variation properties to compare cilt
Browse files Browse the repository at this point in the history
  • Loading branch information
AliveMen committed Mar 23, 2020
1 parent 2dbc9ef commit d37f063
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion assets/js/products-compare/product-compare.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,10 @@ storefrontApp.controller('productCompareListController', ['$rootScope', '$scope'
if (_.isEmpty($scope.products))
return [];
var grouped = {};
var properties = _.flatten(_.map($scope.products, function(product) { return product.properties; }));

var properties = _.flatten(_.map($scope.products, function(product) { return product.variationProperties; }));
properties = properties.concat(_.flatten(_.map($scope.products, function(product) { return product.properties; })));

var propertyDisplayNames = _.uniq(_.map(properties, function(property) { return property.displayName; }));
_.each(propertyDisplayNames, function(displayName) {
grouped[displayName] = [];
Expand All @@ -57,6 +60,12 @@ storefrontApp.controller('productCompareListController', ['$rootScope', '$scope'
property.value = formatNumber(property.value);
}
})
_.each(product.variationProperties, function(property) {
property.productId = product.id;
if (property.valueType.toLowerCase() === 'number') {
property.value = formatNumber(property.value);
}
})
return product;
}

Expand Down

0 comments on commit d37f063

Please sign in to comment.