Shop:
Ext.define('onlineStore.store.market', {
model: 'Market',
root: 'products',
proxy: {
type: 'ajax',
url: 'http://localhost/onlineStore/data/market.json',
reader: {
type: 'json'
}
},
autoLoad: true
});
Product Model:
Ext.define('Market', {
extend: 'Ext.data.Model',
fields: [
{name: 'name', type: 'string'}
]
});
Products JSON:
{
"success": true,
"products": [
{"productName": "Apple", "category": "Fruit", "price": "$0.99"},
{"productName": "Banana", "category": "Fruit", "price": "$1.50"},
{"productName": "Milk", "category": "Dairy", "price": "$2.99"}
]
}
I am trying to map the data from my products JSON file to the Market model by setting name
in the model equal to the productName
in the JSON data. I have been researching this issue but haven't found a solution yet. Can someone please assist me with this?