Erstes Plugin

Hallo,

Versuche grade mein erstes Plugin zu schreiben.

Wie bekomme ich die Artikel ID vom Artikel in die SQL Abfrage?

Im Moment ist das ja die 150 er soll automatisch die Artikel ID 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.

 

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

1 „Gefällt mir“