Hallo zusammen,
ich möchte im Backend einen zusätzlichen Tab in den Artikeldetails im Backend hinzufügen, scheiter jedoch kläglich…
Ich habe ein neues Backend Plugin angelegt und mich an diesem Beispiel orientiert, das jedoch für SW4 erstellt wurde: http://community.shopware.com/Artikelmodul-Bestell%C3%BCbersicht_detail_1071.html
Ich bekomme einfach keinen zusätlichen Tab ins in die Artikeldetails. Ich habe, aus verzweiflung, nach jeder änderung das Plugin neu installiert, das Backend neu geladen und sogar den Shop cache geleert.
Ich habe den Shop in Version 5.1.3 installiert.
Ich bin für jeden Anhaltspunkt dankbar!
Vielen Dank schon mal!
//Kafke
Bootstrap.php
Models();
}
public function getInfo() {
return array(
'version' => $this->getVersion(),
'author' => "TRH ", 'source' => $this->getSource(),
'copyright' => "Copyright (c) 2016, TRH",
'label' => $this->getLabel(),
'description' => 'TRH test erweiterung Version ' . $this->getVersion()
);
}
public function install() {
try {
$this->subscribeEvents();
$this->createAttributes();
$this->createConfig();
} catch (Exception $e) {
$this->uninstall();
return array('success' => false, 'message' => $e->getMessage());
}
$this->Application()->Models()->generateAttributeModels(dirname($this->Application()->AppPath()));
return true;
}
private function subscribeEvents() {
$this->subscribeEvent('Enlight_Controller_Action_PostDispatch_Backend_Article', 'onPostDispatchBackendArticle');
$this->subscribeEvent('Enlight_Controller_Dispatcher_ControllerPath_BackendTRHArticleOrdersTab', 'onGetBackendController');
}
public function onPostDispatchBackendArticle(Enlight_Event_EventArgs $args) {
$args->getSubject()->View()->addTemplateDir(
$this->Path() . 'Views/'
);
if ($args->getRequest()->getActionName() === 'load') {
$args->getSubject()->View()->extendsTemplate(
'backend/view/options/window.js'
);
}
if ($args->getRequest()->getActionName() === 'index') {
$args->getSubject()->View()->extendsTemplate('backend/app.js');
}
}
public function onGetBackendController() {
$this->Application()->Template()->addTemplateDir(
$this->Path() . 'Views/'
);
return $this->Path() . 'Controllers/Backend/TRH.php';
}
private function createAttributes() {
for ($i = 1; $i < 11; $i++) {
$this->Application()->Models()->addAttribute(
's_articles_attributes', 'TRH', 'color' . $i, 'varchar(255)', true, NULL
);
}
$this->getEntityManager()->generateAttributeModels(array(
's_articles_attributes'
));
}
private function createConfig() {
$colors = array("Gelb", "Rot", "Weiß", "Blau", "Pink", "Rosa", NULL, NULL, NULL, NULL);
for ($i = 0; $i < 10; $i++) {
$this->Form()->setElement('text', 'TRH_color' . $i, array('label' => 'Farbe ' . $i, 'required' => false, 'value' => $colors[$i]));
}
}
public function uninstall() {
try {
for ($i = 0; $i < 10; $i++) {
$this->Application()->Models()->addAttribute('s_articles_attributes', 'TRH', 'color' . $i);
}
$this->getEntityManager()->generateAttributeModels(array('s_articles_attributes'));
} catch (\Exception $e) {
// return array('success' => false, 'message' => $e->getMessage());
}
return true;
}
}
Views/backend/app.js
//{namespace name=backend/TRH}
//{block name="backend/article/application" append}
//{include file="backend/view/options/grid.js"}
//{include file="backend/store/order.js"}
//{include file="backend/model/order.js"}
//{/block}
Views/backend/view/options/window.js
//{namespace name="backend/TRH"}
//{block name="backend/article/view/detail/window" append}
Ext.define('Shopware.apps.Article.TRH.view.Window', {
override: 'Shopware.apps.Article.view.detail.Window',
/**
* @Override
* Creates the main tab panel which displays the different tabs for the article sections.
* To extend the tab panel this function can be override.
*
* @return Ext.tab.Panel
*/
createMainTabPanel: function() {
var me = this, result;
result = me.callParent(arguments);
me.registerAdditionalTab({
title: '{s name=window/tab_TRH_article_orders_tab}Bestellübersicht{/s}',
contentFn: me.createTRHArticleOrdersTab,
articleChangeFn: me.articleChange,
tabConfig: {
layout: {
type: 'hbox',
align: 'stretch'
},
listeners: {
activate: function () {
me.TRHArticleOrdersTabOrderStore.load();
me.fireEvent('TRHArticleOrdersTabActivated', me);
}
}
},
scope: me
});
return result;
},
/**
* Callback function called when the article changed (splitview).
*
* @param article
* @param tabConfig
*/
articleChange: function(article, tabConfig) {
var me = this;
me.TRHArticleOrdersTabOrderStore.getProxy().extraParams.articleId = article.get('id');
me.TRHArticleOrdersTabOrderStore.load();
},
/**
* @return Ext.container.Container
*/
createTRHArticleOrdersTab: function(article, stores, eOpts) {
var me = this, disabled = true, tab = eOpts.tab;
me.TRHArticleOrdersTabOrderStore = Ext.create('Shopware.apps.Article.TRHArticleOrdersTab.store.Order');
me.TRHArticleOrdersTabOrderStore.getProxy().extraParams.articleId = null;
if (article.get('id')) {
me.TRHArticleOrdersTabOrderStore.getProxy().extraParams.articleId = article.get('id');
disabled = article.get('id') === null;
}
me.TRHArticleOrdersTab = Ext.create('Ext.container.Container', {
flex: 1,
layout: 'fit',
items: [
{
xtype: 'TRH-article-order-tag-grid',
store: me.TRHArticleOrdersTabOrderStore
}
]
});
tab.add(me.TRHArticleOrdersTab);
tab.setDisabled(false);
return me.TRHArticleOrdersTab;
}
});
//{/block}