Quantcast
Channel: Neueste Diskussionen - Shopware Community Forum
Viewing all articles
Browse latest Browse all 14594

Backend Plugin erstellen - brauche Hilfe

$
0
0

Moin,

ich versuche in SW5 ein Backend-Plugin mit Menüpunkt zu erstellen. Das Plugin lässt sich installieren und der Menüpunkt erscheint auch. Allerdings sobald ich auf den Memüpunkt klicke, kommt nur das "... wird geladen..." und das wars. Das bleibt dann da und nichts passiert mehr. Was stimmt da nicht? Der Code ist anbei..

Bootstrap.php

<?php

	/**
	 * Standard Shopware Plugin Class
	 */
	class Shopware_Plugins_Frontend_TestUwe_Bootstrap extends Shopware_Components_Plugin_Bootstrap {

		/**
		 * Returns the meta information about the plugin.
		 * @return array
		 */
		public function getCapabilities() {
			return array(
				'install' => true,
				'enable' => true,
				'update' => true
			);
		}

		/**
		 * Plugin install method
		 */
		public function install() {

			if(!$this->assertVersionGreaterThen("4.3.0"))
				throw new Enlight_Exception("This Plugin needs min shopware 4.3.0");

			$this->createMenu();
			$this->subscribeEvents();
			

			return array('success' => true, 'invalidateCache' => array('config', 'frontend', 'backend', 'proxy'));
		}

		/**
		 * Plugin uninstall method
		 */
		public function uninstall() {
			return array('success' => true, 'invalidateCache' => array('config', 'frontend', 'backend', 'proxy'));
		}

		/**
		 * activates the plugin
		 */
		public function enable() {
			Shopware()->Db()->exec('UPDATE s_core_menu SET active=1 WHERE name = "TestUwe"');

			return true;
		}

		/**
		 * deactivates the plugin
		 */
		public function disable() {
			Shopware()->Db()->exec('UPDATE s_core_menu SET active=0 WHERE name = "TestUwe"');

			return true;
		}

		/**
		 * get label for this plugin
		*/
		public function getLabel() {
			return 'TestUwe';
		}

		/**
		 * Get version tag of this plugin to display in manager
		 */
		public function getVersion() {
			return '4.01.01';
		}

		/**
		 * get the main info for the plugin
		 */
		public function getInfo() {
			return array (
				'version' => $this->getVersion(),
				'autor' => 'Uwe Heldt',
				'copyright' => 'Uwe Heldt',
				'label' => $this->getLabel(),
				'support' => 'http://www.piloten-training.com',
				'link' => 'http://www.piloten-training.com'
			);
		}

		/**
		 * create menu entries for this plugin
		 */
		protected function createMenu() {
			$parent = $this->createMenuItem(array (
				'label' => 'TestUwe',
				'controller' => 'TestUwe',
				'class' => 'sprite-credit-cards',
				'action' => 'index',
				'active' => 1,
				'parent' => $this->Menu()->findOneBy('label', 'Marketing')
			));
		}

		/**
		 * create Events/Hooks for the plugin
		 */
		protected function subscribeEvents() {
			// Events für Backend- und Frontend-Controller
			$this->subscribeEvent('Enlight_Controller_Dispatcher_ControllerPath_Backend_TestUwe', 'onGetControllerPathBackend');		
		}

		/**
		 * get the backend controller path
		 */
		public function onGetControllerPathBackend(Enlight_Event_EventArgs $args) {
			$this->Application()->Template()->addTemplateDir($this->Path() . 'Views/');

			return $this->Path() . '/Controllers/Backend/TestUwe.php';
		}
		
	}
?>

 

TestUwe.php

<?php
	
	/**
	 * Shopware backend class for TestUwe
	 */
	class Shopware_Controllers_Backend_TestUwe extends Shopware_Controllers_Backend_ExtJs
	{

		/**
     * this function is called initially and extends the standard template directory
     * @return void
     */
    public function init()
    {
        $this->View()->addTemplateDir(dirname(__FILE__) . "/Views/");
        parent::init();
    }

		/**
		 * index action is called if no other action is triggered
		 */
		public function indexAction()
		{
			$this->View()->loadTemplate("backend/Test_Uwe/app.js");
		}
	}
?>

app.js

//{block name="backend/test_uwe/application"}
	Ext.define('Shopware.apps.TestUwe', {
		name: 'Shopware.apps.TestUwe',
		extend: 'Enlight.app.SubApplication',
		loadPath: '{url action=load}',
		bulkLoad: true,
		defaultController: 'Main',
		controllers: [
			'Main'
		],
		launch: function() {
			var me = this;

			var controller = me.getController('Main');

			return controller.mainWindow;
		}
	});
//{/block}

 

main.js

// {namespace name=backend/TestUwe/controller}
// {block name=backend/TestUwe/controller/main}
Ext.define('Shopware.apps.TestUwe.controller.Main', {

    extend: 'Ext.app.Controller',

    mainWindow: null,

    init: function () {
        var me = this;

        me.mainWindow = me.getView('list.Window').create({ }).show();

        me.callParent(arguments);
    }
});
// {/block}

product.js



Ext.define('Shopware.apps.TestUwe.view.list.Product', {
    extend: 'Shopware.grid.Panel',
    alias:  'widget.product-listing-grid',
    region: 'center',

    configure: function() {
        return {
            detailWindow: 'Shopware.apps.TestUwe.view.detail.Window'
        };
    }
});

window.js


Ext.define('Shopware.apps.TestUwe.view.list.Window', {
    extend: 'Shopware.window.Listing',
    alias: 'widget.product-list-window',
    height: 450,
    title : '{s name=window_title}Product listing{/s}',

    configure: function() {
        return {
            listingGrid: 'Shopware.apps.TestUwe.view.list.Product',
            listingStore: 'Shopware.apps.TestUwe.store.Product'
        };
    }
});

product.js



Ext.define('Shopware.apps.TestUwe.view.detail.Product', {
    extend: 'Shopware.model.Container',
    padding: 20,

    configure: function() {
        return {
            controller: 'TestUwe'
        };
    }
});

 


Viewing all articles
Browse latest Browse all 14594