# Erstes Plugin

**URL:** https://forum.shopware.com/t/erstes-plugin/63760
**Category:** Programmierung
**Created:** [31. Dezember 2019 um 20:57 UTC](https://forum.shopware.com/t/erstes-plugin/63760 "2019-12-31T20:57:08Z")
**Posts on this page:** 2
**Page:** 1

<div class="post-metadata">

### Author: ![Alex2019](https://avatars.discourse-cdn.com/v4/letter/a/f4b2a3/32.png) [@Alex2019](https://forum.shopware.com/u/Alex2019)
#### Post date: [31. Dezember 2019 um 20:57 UTC](https://forum.shopware.com/t/erstes-plugin/63760/1 "2019-12-31T20:57:08Z")

</div>

Hallo,

Versuche grade mein erstes Plugin zu schreiben.

Wie bekomme ich die Artikel&nbsp;ID&nbsp;vom Artikel in die SQL Abfrage?

Im&nbsp;Moment&nbsp;ist das ja die&nbsp;150 er&nbsp;soll automatisch die Artikel&nbsp;ID&nbsp;nehmen.

```
scheduleClearCache($this->getCacheArray());
		parent::install($context);
 
	}
 
	public function uninstall(UninstallContext $context)
	{
		$context->scheduleClearCache($this->getCacheArray());
		parent::uninstall($context);
	}
 
	public function activate(ActivateContext $context)
	{
		$context->scheduleClearCache($this->getCacheArray());
		parent::install($context);
	}
 
	public function deactivate(DeactivateContext $context)
	{
		$context->scheduleClearCache($this->getCacheArray());
		parent::install($context);
	}
 
 
	/**
	 * Get caches to clear
	 *
	 * @return array
	 */
	private function getCacheArray()
	{
		return [
			InstallContext::CACHE_TAG_CONFIG,
			InstallContext::CACHE_TAG_HTTP
		];
	}
 
	
	public static function getSubscribedEvents() {
		return [
			'Enlight_Controller_Action_PostDispatch_Frontend_Detail' => 'onFrontendDetail'
		];
	}
	
	
/ **Plugin iformationen** /	

public function onFrontendDetail(\Enlight_Event_EventArgs $arguments){
	
 

	
	
	
	
	$view = $arguments->get('subject')->View();
 
 
		$qb = $this->container->get('dbal_connection')->createQueryBuilder();
 
		$qb->select('u.*', 'p.*')
			->from('s_articles_categories', 'u')
			->leftJoin('u', 's_categories', 'p', 'u.categoryID = p.id')
			->where('articleID = :id')
			->setParameter('id', 150);
	
 		$single = $qb->execute()->fetchAll();
		$view->assign('info_categories', $single);
		
	
	}
	
	
	
	
}

```

Ich wäre für Hilfe, Tipps und Unterstützung sehr dankbar.

&nbsp;

---

<div class="post-metadata">

### Author: ![Lukaschel](https://avatars.discourse-cdn.com/v4/letter/l/e56c9b/32.png) [@Lukaschel](https://forum.shopware.com/u/Lukaschel)
#### Post date: [1. Januar 2020 um 14:35 UTC](https://forum.shopware.com/t/erstes-plugin/63760/2 "2020-01-01T14:35:11Z")

</div>

Hallo Alex,

mit

```
$id = (int) $arguments->getRequest()->sArticle;

```

kriegst du die ID in dem Request.

Schau doch mal unter /engine/Shopware/Controlles/Frontend/Detail.php nach wie die da so Ihre Werte holen, hilft vielleicht auch für die Zukunft.

Grüße Lukaschel
