ticket #3 - Added learning cartridge with all complete examples

This commit is contained in:
Max Gialanella
2021-12-22 11:09:55 -07:00
parent 8f15cd15df
commit 3f354195f2
33 changed files with 783 additions and 0 deletions

View File

@@ -0,0 +1,9 @@
'use strict';
module.exports = function (object, productApi) {
var inventoryRecord = productApi.availabilityModel.inventoryRecord;
Object.defineProperty(object, 'stockInformation', {
enumerable: true,
value: inventoryRecord==null ? 0 :parseInt(inventoryRecord.ATS,10)
});
};

View File

@@ -0,0 +1,23 @@
'use strict';
var base = module.superModule;
//Load our stock information decorator
var stockInformation = require('*/cartridge/models/product/decorators/stockInformation');
/**
* Decorate product with product line item information
* @param {Object} product - Product Model to be decorated
* @param {dw.catalog.Product} apiProduct - Product information returned by the script API
* @param {Object} options - Options passed in from the factory
* @returns {Object} - Decorated product model
*/
function fullProduct(product, apiProduct, options) {
//Call base, pass all the same paramters
base.call(this, product, apiProduct, options);
//use decorator to lead invintory from product api
stockInformation(product,apiProduct);
return product;
}
module.exports = fullProduct;

View File

@@ -0,0 +1,12 @@
'use strict';
var base = module.superModule;
function store(storeObject) {
base.call(this, storeObject);
this.email = storeObject.email;
}
store.prototype = Object.create(base.prototype);
module.exports = store;