我被困在Shopware擴展的開發中。 我想以正確的方式擴展類別的管理。帶有ExtJs的Shopware後臺增強類
實現創建的插件(遺留)。這個插件在類別中追加第一個標籤。
//{block name="backend/category/view/tabs/settings" append}
這樣做是爲了添加一個帶下拉的字段集。該文件是這樣的:
//{block name="backend/category/view/tabs/settings" append}
Ext.define('Shopware.apps.HaendlerbundFoobarCategories.view.category.tabs.settings', {
override:'Shopware.apps.Category.view.category.tabs.Settings',
getItems: function() {
var me = this;
var items = me.callParent(arguments);
me.FooBar = me.getFooBarSection();
items.push(me.FooBar);
return items;
},
getFooBarSection : function()
{
var me = this;
return Ext.create('Ext.form.FieldSet',{
title: 'FooBar Verlinkung',
anchor: '100%',
defaults : me.defaults,
disabled : false,
items : me.getDropdowns()
});
},
getDropdowns:function(){
var me = this;
return me.templateComboBox = Ext.create('Ext.form.field.ComboBox', {
xtype:'combobox',
fieldLabel: 'FooBar Product',
store: me.fooBarProducts.load(),
labelWidth: 155,
valueField: 'id',
displayField:'title',
editable: true,
allowBlank:true,
name:'fbproduct'
});
}
});
//{/block}
我懷疑的主要問題是商店。像這樣離開它,我得到一個JS 錯誤無法讀取未定義的屬性「負載」。沒有.load()沒有錯誤,但我也無法確定商店是否已加載。
的存儲文件本身是在查看/後端/ haendlerbund_foobar_categories /存儲/ foo_bar_products
和該文件的內容是:
//{block name="backend/haendlerbund_foobar_categories/store/fooBarProducts"}
Ext.define('Shopware.apps.HaendlerbundFoobarCategories.store.fooBarProducts', {
//...
model: 'Shopware.apps.HaendlerbundFoobarCategories.model.fooBarProducts',
proxy : {
type : 'ajax',
/**
* Configure the url mapping for the different
* store operations based on
* @object
*/
api : {
read : '{url controller=HaendlerbundFoobarCategories action=getProducts}'
},
/**
* Configure the data reader
* @object
*/
reader : {
type : 'json',
root: 'data'
}
}
});
//{/block}
編輯: 爲了進一步上下文中,這是商店引用的模型的當前狀態。
Ext.define('Shopware.apps.HaendlerbundFoobarCategories.model.fooBarProducts', {
extend: 'Ext.data.Model',
/**
* If the name of the field is 'id' extjs assumes automatically that
* this field is an unique identifier.
* @integer
*/
idProperty : 'id',
fields:[
{ name : 'id', type: 'int' },
{ name : 'ffid', type: 'bigint' },
{ name : 'title', type: 'string' },
{ name : 'description', type: 'string' },
{ name : 'price', type: 'decimal' },
{ name : 'vat', type: 'decimal' },
{ name : 'image', type: 'text' },
{ name : 'active', type: 'boolean' },
{ name : 'createdAt', type: 'datetime' },
{ name : 'modfiedAt', type: 'datetime' }
],
/*associations: [
{
relation: 'OneToMany',
storeClass: 'Shopware.apps.HaendlerbundFoobarCategories.store.fooBarProducts',
loadOnDemand: true,
type: 'hasMany',
model: 'Shopware.apps.HaendlerbundFooBarCategories.model.fooBarProducts',
name: 'getCategories',
associationKey: 'categories'
},
]*/
});
,而PHP的控制器,店裏的引用以及具有以下內容:
<?php
class Shopware_Controllers_Backend_HaendlerbundFoobarCategories extends Shopware_Controllers_Backend_Application
{
protected $model = 'Shopware\CustomModels\Product\FFProduct';
protected $alias = 'ffproducts';
protected function getListQuery()
{
$builder = parent::getListQuery();
return $builder;
}
protected function getDetailQuery($id)
{
$builder = parent::getDetailQuery($id);
return $builder;
}
protected function getAdditionalDetailData(array $data)
{
return $data;
}
public function getProducts(){
$builder = $this->getManager()->createQueryBuilder();
$builder->select('*')
->from($model, $alias);
$data['id'] = 1;
$data['ffid'] = 1;
$data['title'] = 'lorem ipsum';
$this->view()->assign([
'success' => true,
'data' => $data,
'total' => 1
]);
}
}
它應該返回一些虛擬的數據了。
我無法解決問題。正如我所能找到的任何文件都着眼於創建改變現有領域的單獨組件。我懷疑我是在錯誤的範圍內或有一個命名空間錯誤或什麼的。
任何幫助,非常感謝。
我測試你的建議。這沒有什麼區別。 但是,商店可能的輸入不會返回任何數據,這讓我有一個想法來進行測試。 –
請做一個'console.log(me.fooBarProducts)'並檢查你得到了什麼。 – Alexander
當我找到把這個實際看到的迴應的地方時,會做什麼。現在我試着測試類的命名等等。我想也有一些混雜的事情。 無論是商店還是模型是一個純粹的ExtJS的環境,其實我揣摩,如果我至少得到了正確的範圍。 –