loading best selling items for sections
This commit is contained in:
@@ -7,7 +7,8 @@ var _ = require('underscore');
|
||||
|
||||
// Define initial data points
|
||||
var _items = new ItemCollection(),
|
||||
_itemWithDetails = new ItemWithDetails();
|
||||
_itemWithDetails = new ItemWithDetails(),
|
||||
_bestSellingForSection = new ItemCollection();
|
||||
|
||||
|
||||
var loadItemsForFrontpage = function() {
|
||||
@@ -49,10 +50,30 @@ var fetchItemWithDetails = function() {
|
||||
}
|
||||
}
|
||||
|
||||
var fetchBestSellingItemsForSection = function(sectionId) {
|
||||
console.log('getting section', sectionId);
|
||||
var items = _bestSellingForSection;
|
||||
items.setClassificationType(1);
|
||||
items.setClassificationId(sectionId);
|
||||
items.setLimit(30);
|
||||
items.setOffset(0);
|
||||
|
||||
|
||||
items.fetch({
|
||||
success: function() {
|
||||
ItemStore.emitChange();
|
||||
}
|
||||
});
|
||||
};
|
||||
|
||||
|
||||
// Extend ItemStore with EventEmitter to add eventing capabilities
|
||||
var ItemStore = _.extend({}, EventEmitter.prototype, {
|
||||
|
||||
getBestSellingForSection: function() {
|
||||
|
||||
return _bestSellingForSection;
|
||||
},
|
||||
// item with details
|
||||
getLoadedItemWithDetails: function() {
|
||||
return _itemWithDetails;
|
||||
@@ -94,6 +115,9 @@ AppDispatcher.register(function(payload) {
|
||||
fetchItemWithDetails();
|
||||
break;
|
||||
|
||||
case ItemConstants.LOAD_BSI_FOR_SECTION:
|
||||
fetchBestSellingItemsForSection(action.sectionId);
|
||||
break;
|
||||
|
||||
case ItemConstants.LOAD_FOR_FRONTPAGE:
|
||||
loadItemsForFrontpage();
|
||||
@@ -109,4 +133,4 @@ AppDispatcher.register(function(payload) {
|
||||
|
||||
});
|
||||
|
||||
module.exports = ItemStore;
|
||||
module.exports = ItemStore;
|
||||
|
||||
Reference in New Issue
Block a user