# Extending services für bestimmte Controller / actions

**URL:** <https://forum.shopware.com/t/extending-services-fur-bestimmte-controller-actions/57999>\
**Category:** Programmierung\
**Created:** [12. Februar 2019 um 12:06 UTC](https://forum.shopware.com/t/extending-services-fur-bestimmte-controller-actions/57999 "2019-02-12T12:06:22Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Sition](https://avatars.discourse-cdn.com/v4/letter/s/df705f/32.png) [@Sition](https://forum.shopware.com/u/Sition)\
**Post date:** [12. Februar 2019 um 12:06 UTC](https://forum.shopware.com/t/extending-services-fur-bestimmte-controller-actions/57999/1 "2019-02-12T12:06:22Z")

</div>

Hallo zusammen, wir haben eine Frage zum extending der Services.  
Wir möchten den ListProductService erweitern, ABER wir benötigen keine erweiterung (die zusätzliche daten abruft) auf den checkout -Seiten.

Gibt es eine möglichkeit, die ausdehnung auf bestimmte Controller / Action zu beschränken?

Wenn wir die services.xml implementieren, scheint der Service auf jeder Seite zu erweitern:

&nbsp;

&nbsp;

&nbsp;

---

<div class="post-metadata">

**Author:** ![Michael\_Telgmann](https://dub1.discourse-cdn.com/flex013/user_avatar/forum.shopware.com/michael_telgmann/32/20289_2.png) [@Michael\_Telgmann](https://forum.shopware.com/u/Michael_Telgmann)\
**Post date:** [12. Februar 2019 um 12:29 UTC](https://forum.shopware.com/t/extending-services-fur-bestimmte-controller-actions/57999/2 "2019-02-12T12:29:54Z")

</div>

Hallo Sition,

versuche mal folgendes **(ungetestet)**

und dann der Decorator:

```
namespace SwagFoo;

use Shopware\Bundle\StoreFrontBundle\Service\ListProductServiceInterface;
use Shopware\Bundle\StoreFrontBundle\Struct;

class ListProductServiceDecorator implements ListProductServiceInterface
{
    /**
     * @var ListProductServiceInterface
     */
    private $coreListProductService;

    /**
     * @var \Enlight_Controller_Front
     */
    private $front;

    public function __construct(ListProductServiceInterface $coreListProductService, \Enlight_Controller_Front $front)
    {
        $this->coreListProductService = $coreListProductService;
        $this->front = $front;
    }

    public function getList(array $numbers, Struct\ProductContextInterface $context)
    {
        if ($this->front->Request()->getControllerName() === 'checkout') {
            return $this->coreListProductService->getList($numbers, $context);
        }

        // return custom stuff
    }

    public function get($number, Struct\ProductContextInterface $context)
    {
        if ($this->front->Request()->getControllerName() === 'checkout') {
            return $this->coreListProductService->get($number, $context);
        }

        // return custom stuff
    }
}

```

So prüfst du im Request, welcher Controller aufgerufen wird und kannst dann entsprechend reagieren.

Viele Grüße aus Schöppingen

![cool](https://europe1.discourse-cdn.com/flex013/uploads/shopware/original/1X/86c57fbace799dd4eb1f1b8a2d3bdc1733f0aea1.png "cool")&nbsp;Michael Telgmann
