In Shopware Informationen verarbeiten und aufbereiten mit Smarty Template

Shopware Plugins sind super, Shopware Plugins sind geil. Ich entwickle gerne Plugins für jede Kleinigkeit.
Aber muss das immer sein?
Ich meine nein.
Vor allem wenn es statisch sein kann.

Alles was man meistens benötigt, wird ja schon übergeben wie z.B. Controller, sArticles, sArticle, sBasket, sUserData u.v.m.
So könnten wir anhand des Controllers von index über listing, detail bis hin zu checkout den Besucher begleiten und im Hintergrund Informationen per JavaScript sammeln.

Ein Smarty Template in Shopware könnte z.B. so aussehen.

{extends file='parent:frontend/listing/index.tpl'}
{block name='frontend_index_body_inline' append}
	<script type="text/javascript" src="{link file='frontend/_resources/javascript/speicherInfos.js'}" async="true"></script>
	{if $Controller=='index'}
	<script type="text/javascript">
		var info = [
			{ 'page': '{$Controller}' }
		];
		speicherInfos.save(info);
	</script>
	{elseif $Controller=='listing' || $Controller=='search'}
		{$keyword = $sCategoryContent.description}
		{$listAr = $sArticles}
		{$articleID = ''}
		{if $Controller=='search'}
			{$keyword = $sSearchResults.sSearchTerms|implode:' '}
			{$listAr = $sSearchResults.sArticles}	
		{/if}
		{section name=i loop=3}
			{if isset($listAr[i].articleID)}
				{$articleID = $articleID|cat:",'"|cat:$listAr[i].articleID|cat:"'"}
			{/if}
		{/section}
	<script type="text/javascript">
		var info = [
			{ 'page': '{$Controller}' },
			{ 'productIDs': [{$articleID|substr:1}] },
			{ 'Keywords': '{$keyword}' }
		];
		speicherInfos.save(info);
	</script>
	{elseif $Controller=='detail'}
	<script type="text/javascript">
		var info = [
			{ 'page': '{$Controller}' },
			{ 'productID': '{$sArticle.articleID}' }
		];
		speicherInfos.save(info);
	</script>
	{elseif $Controller=='checkout'}
		{$pageType = 'basket'}
		{$orderID = ''}
		{$listAr = $sBasket.content}
		{$articleID = ''}
		{$price = ''}
		{$quantity = ''}
		{if isset($sOrderNumber)}
			{$pageType = 'confirmation'}
			{$orderID = "{ 'orderID': '"|cat:$sOrderNumber|cat:"' },"}
		{/if}
		{section name=i loop=$listAr}
			{$articleID = $articleID|cat:",'"|cat:$listAr[i].articleID|cat:"'"}
			{$priceInt = $listAr[i].price|replace:',':'.'}
			{$price = $price|cat:",'"|cat:$priceInt|cat:"'"}
			{$quantity = $quantity|cat:",'"|cat:$listAr[i].quantity|cat:"'"}
		{/section}
	<script type="text/javascript">
		var info = [
			{ 'page': '{$pageType}' },
			{$orderID}
			{ 'productIDs': [{$articleID|substr:1}] },
			{ 'Prices': [{$price|substr:1}] },
			{ 'Quantities': [{$quantity|substr:1}] }
		];
		speicherInfos.save(info);
	</script>
	{/if}
{/block}

Das Template tut nichts anderes als die Werte für ein JavaScript zu verarbeiten und aufzubereiten, die je nach Contoller übergeben werden.

Fazit:

Soll es mal schnell gehen und man keine Entwicklungszeit für Plugins investieren möchte, können Templates zur Verarbeitung und Aufbereitung von Informationen eine gut Lösung sein.