Hallo Leute
Bin erst seit kurzem mit Shopware und ExtJS unterwegs.
Ich habe mit Hilfe dieser Anleitung Attribute system zwei weitere RTE-Felder nach dem normalen „Beschreibung“ RTE-Feld hinzugefügt.
Die zwei RTE-Felder werden im Backend wie gewünscht angezeigt. Wenn ich etwas reinschreibe und Speichere wird es auch in die Datenbank geschrieben (in HTML-Format).
Aber: Der Inhalt welcher in der Datenbank steht wird nicht angezeigt. D.h. die zwei Felder sind immer leer, sobald ich die Artikel-Detailseite neu öffne.
In der install-function vom plugin habe ich:
// create description_short
$service->update('s_articles_attributes', 'description_short', 'text', [
'label' => 'Kurzbeschrieb',
'translatable' => false,
'displayInBackend' => false,
'position' => 0,
'custom' => false,
]);
// create description_technical
$service->update('s_articles_attributes', 'description_technical', 'text', [
'label' => 'Technische Daten',
'translatable' => false,
'displayInBackend' => false,
'position' => 0,
'custom' => false,
]);
Die RTE-Felder erstelle ich im window.js (würde wahrscheinlich noch bisschen schöne gehen):
//{block name="backend/article/view/detail/window"}
// {$smarty.block.parent}
Ext.define('Shopware.apps.MyPlugin.view.detail.Window', {
override: 'Shopware.apps.Article.view.detail.Window',
createDescriptionFieldSet: function() {
var me = this;
return Ext.create('Ext.form.FieldSet', {
layout: 'anchor',
cls: Ext.baseCSSPrefix + 'article-description-field-set',
defaults: {
labelWidth: 155,
anchor: '100%',
translatable: true,
xtype: 'textarea'
},
title: 'Texte',
items: [
{
xtype: 'tinymce',
fieldLabel: 'Kurzbeschrieb',
name: 'descriptionShort',
margin: '0 0 15',
cls: Ext.baseCSSPrefix + 'article-description-short',
height: 100
},
{
xtype: 'tinymce',
fieldLabel: 'Beschreibung',
name: 'descriptionLong',
margin: '0 0 15',
cls: Ext.baseCSSPrefix + 'article-description-long',
height: 100
},
{
xtype: 'tinymce',
fieldLabel: 'Technische Daten',
name: 'descriptionTechnical',
margin: '0 0 15',
cls: Ext.baseCSSPrefix + 'article-description-technical',
height: 100
}
]
});
},
});
//{/block}
Gespeichert wird’s dann im detail-controller:
//{block name="backend/article/controller/detail"}
// {$smarty.block.parent}
Ext.define('Shopware.apps.MyPlugin.controller.Detail', {
override: 'Shopware.apps.Article.controller.Detail',
onSaveArticle: function(win, article, options) {
var me = this,
originalCallback = options.callback;
var customCallback = function(newArticle, success) {
Ext.callback(originalCallback, this, arguments);
Ext.Ajax.request({
method: 'POST',
url: '{url controller=AttributeData action=saveData}',
params: {
_foreignKey: newArticle.get('mainDetailId'),
_table: 's_articles_attributes',
__attribute_description_short: Ext.ComponentQuery.query('textarea[name="descriptionShort"]')[0].getValue(),
__attribute_description_technical: Ext.ComponentQuery.query('textarea[name="descriptionTechnical"]')[0].getValue(),
}
});
};
if (!options.callback || options.callback.toString() !== customCallback.toString()) {
options.callback = customCallback;
}
me.callParent([win, article, options]);
}
});
//{/block}
Hat jemand von euch einen Tipp für mich? Das Speichern ist kein Problem nur das Auslesen.