Skip to content

Commit

Permalink
Merge pull request #3 from khilaadi83/Carousel_config_prefrence
Browse files Browse the repository at this point in the history
fixed carousel lenght issue
  • Loading branch information
Sowmith112 authored Apr 27, 2024
2 parents 3019e27 + c48ad41 commit f82699b
Showing 1 changed file with 8 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ server.extend(module.superModule);

server.append('Show', function (req, res, next) {

Check warning on line 6 in cartridges/sfra_training/cartridges/sfra_training/cartridge/controllers/Cart.js

View workflow job for this annotation

GitHub Actions / deploy-build / build

Unexpected unnamed function
var viewData = res.getViewData();
var carousel_length = dw.system.Site.getCurrent().getCustomPreferenceValue('carousel');
var ProductFactory = require('*/cartridge/scripts/factories/product');
var productListHelper = require('*/cartridge/scripts/helpers/recentProductHelper');
var type = 100;
Expand All @@ -16,20 +17,25 @@ server.append('Show', function (req, res, next) {
items = items.iterator();
var recentProductArr = {};
var ProductDetail;
var remainingItems = list.items.size() - carousel_length;
var i = 0;
while (items.hasNext()) {
i++;
var pidObj = {
pid: (items.next()).productID
};
recentProductArr = {
ProductDetail: ProductFactory.get(pidObj)
};
allproductDetails.push(recentProductArr.ProductDetail);
if (i > remainingItems) {
allproductDetails.push(recentProductArr.ProductDetail);
}
}
}
var allproductDetails = allproductDetails.reverse();
viewData = {
allProductDetails: allproductDetails
}
};
res.setViewData(viewData);
next();
});
Expand Down

0 comments on commit f82699b

Please sign in to comment.