1

我很难在来自 magento 1.7 的响应中使用我的产品商店的代理

响应如下所示:

{
 "1":
   {"entity_id":"1","type_id":"simple","sku":"dress_test","status":"1","visibility":"4","tax_class_id":"2","weight":"1.0000","price":"1500.0000","special_price":"1000.0000","name":"Wedding dress","url_key":"dress","country_of_manufacture":"AO","msrp_display_actual_price_type":"2","gift_message_available":"1","news_from_date":"2012-03-21 00:00:00","news_to_date":"2012-03-24 00:00:00","special_from_date":"2012-03-21 00:00:00","special_to_date":"2012-03-24 00:00:00","description":"White wedding dress"},
 "2":
   {"entity_id":"2","type_id":"simple","sku":"black_sunglasses","status":"1","visibility":"4","tax_class_id":"2","weight":"0.2000","price":"500.0000","special_price":"300.0000","name":"Sunglasses","url_key":"sunglasses","country_of_manufacture":"AR","msrp_display_actual_price_type":"2","gift_message_available":null,"news_from_date":null,"news_to_date":null,"special_from_date":"2012-03-21 00:00:00","special_to_date":"2012-03-24 00:00:00","description":"Black sunglasses"}
}

但是 sencha 的预期输入(我认为)应该是这样的:

{
 {"entity_id":"1","type_id":"simple","sku":"dress_test","status":"1","visibility":"4","tax_class_id":"2","weight":"1.0000","price":"1500.0000","special_price":"1000.0000","name":"Wedding dress","url_key":"dress","country_of_manufacture":"AO","msrp_display_actual_price_type":"2","gift_message_available":"1","news_from_date":"2012-03-21 00:00:00","news_to_date":"2012-03-24 00:00:00","special_from_date":"2012-03-21 00:00:00","special_to_date":"2012-03-24 00:00:00","description":"White wedding dress"},
 {"entity_id":"2","type_id":"simple","sku":"black_sunglasses","status":"1","visibility":"4","tax_class_id":"2","weight":"0.2000","price":"500.0000","special_price":"300.0000","name":"Sunglasses","url_key":"sunglasses","country_of_manufacture":"AR","msrp_display_actual_price_type":"2","gift_message_available":null,"news_from_date":null,"news_to_date":null,"special_from_date":"2012-03-21 00:00:00","special_to_date":"2012-03-24 00:00:00","description":"Black sunglasses"}
}

如何更改代理的行为以便能够将加载的数据存储到我的商店中?

提前谢谢了!

4

1 回答 1

1

要自定义您自己的响应,您必须继承 Ext.data.reader.Reader Reader 或者在您的情况下,Json 类将数据从响应转换为结果集,被 Sencha 的模型/代理/存储接受。

干杯,奥列格

添加

Ext.define('lib.data.reader.Json', { 
    extend: 'Ext.data.reader.Json', 
    alias : 'reader.magentojson', ... 
})

而不是在阅读器上使用以后的参考:'magentojson'

并且您保留对“json”阅读器的原始引用!

于 2012-09-04T10:58:25.510 回答