ticket #3 - Added learning cartridge with all complete examples
This commit is contained in:
@@ -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)
|
||||
});
|
||||
};
|
23
the_learning_cartridge/cartridge/models/product/fullProduct.js
Executable file
23
the_learning_cartridge/cartridge/models/product/fullProduct.js
Executable 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;
|
12
the_learning_cartridge/cartridge/models/store.js
Executable file
12
the_learning_cartridge/cartridge/models/store.js
Executable 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;
|
Reference in New Issue
Block a user