# Smarty URL auf artikel eines subshops

**URL:** https://forum.shopware.com/t/smarty-url-auf-artikel-eines-subshops/57804
**Category:** Programmierung
**Created:** [31. Januar 2019 um 15:31 UTC](https://forum.shopware.com/t/smarty-url-auf-artikel-eines-subshops/57804 "2019-01-31T15:31:05Z")
**Posts on this page:** 4
**Page:** 1

<div class="post-metadata">

### Author: ![langnickel](https://avatars.discourse-cdn.com/v4/letter/l/3ec8ea/32.png) [@langnickel](https://forum.shopware.com/u/langnickel)
#### Post date: [31. Januar 2019 um 15:31 UTC](https://forum.shopware.com/t/smarty-url-auf-artikel-eines-subshops/57804/1 "2019-01-31T15:31:05Z")

</div>

Frage, ich habe die ordernumber und/oder die detail ID eines Artikels. Nun möchte ich auf Subshop A einen link zu diesem Artikel setzen (am Besten die seo url) damit man auf den subshop B kommt. Smarty URL akzeptiert glaube ich nicht die Shop ID? Wie komme ich an die SEO Url des Artikels eines bestimmten Subshops?

---

<div class="post-metadata">

### Author: ![kreativrudel](https://dub1.discourse-cdn.com/flex013/user_avatar/forum.shopware.com/kreativrudel/32/14503_2.png) [@kreativrudel](https://forum.shopware.com/u/kreativrudel)
#### Post date: [5. März 2019 um 16:08 UTC](https://forum.shopware.com/t/smarty-url-auf-artikel-eines-subshops/57804/2 "2019-03-05T16:08:25Z")

</div>

Hast du dazu was herausfinden könne ? Würde mich auch interessieren. Ich brauche die $baseUrl eines Subshops…

---

<div class="post-metadata">

### Author: ![kreativrudel](https://dub1.discourse-cdn.com/flex013/user_avatar/forum.shopware.com/kreativrudel/32/14503_2.png) [@kreativrudel](https://forum.shopware.com/u/kreativrudel)
#### Post date: [5. März 2019 um 16:51 UTC](https://forum.shopware.com/t/smarty-url-auf-artikel-eines-subshops/57804/3 "2019-03-05T16:51:26Z")

</div>

Für alle die ebenfalls die URL eines Subshops mittels ID abfragen wollen. Ich konnte dazu nichts finden deshalb habe ich eine eigene Smarty Funktion dazu geschrieben.

```
 # \_private/smarty/function.getShopUrl.php function smarty\_function\_getShopUrl($params, $smarty) { $shopRepository = Shopware()-\>Models()-\>getRepository('\Shopware\Models\Shop\Shop'); $builder = $shopRepository-\>createQueryBuilder('shop') -\>select('shop') -\>where('shop.id = :id') -\>setParameter(':id', $params['id']); $query = $builder-\>getQuery(); /\*\* \* @var \Shopware\Models\Shop\Shop $shop \*/ $shop = $query-\>getOneOrNullResult(); $protocol = 'http'; if ($shop) { if ( $shop-\>getSecure() || ($shop-\>getMain() && $shop-\>getMain()-\>getSecure()) ) { $protocol = 'https'; } return sprintf('%s://%s%s', $protocol, $shop-\>getHost() ?: $shop-\>getMain()-\>getHost(), $shop-\>getBaseUrl()); } return ''; } # #### # aufruf im template: {getShopUrl id="3"} # #### 

```

&nbsp;

@langnickel, du könntest es ja noch etwas aufbohren damit dir dann noch zusätzlich die URL zum Artikel zusammengebaut wird

---

<div class="post-metadata">

### Author: ![langnickel](https://avatars.discourse-cdn.com/v4/letter/l/3ec8ea/32.png) [@langnickel](https://forum.shopware.com/u/langnickel)
#### Post date: [7. März 2019 um 15:33 UTC](https://forum.shopware.com/t/smarty-url-auf-artikel-eines-subshops/57804/4 "2019-03-07T15:33:21Z")

</div>

Danke @kreativrudel‍&nbsp; ich schaue es mir die Tage mal an.
