# ServiceDecorator for GoogleShoppingPriceAgent

**URL:** <https://forum.litium.com/t/servicedecorator-for-googleshoppingpriceagent/2301>\
**Category:** Questions\
**Tags:** litium-7\
**Created:** [November 11, 2021, 12:59pm UTC](https://forum.litium.com/t/servicedecorator-for-googleshoppingpriceagent/2301 "2021-11-11T12:59:43Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![andreas.crona](https://yyz2.discourse-cdn.com/flex030/user_avatar/forum.litium.com/andreas.crona/32/662_2.png) [@andreas.crona](https://forum.litium.com/u/andreas.crona)\
**Post date:** [November 11, 2021, 12:59pm UTC](https://forum.litium.com/t/servicedecorator-for-googleshoppingpriceagent/2301/1 "2021-11-11T12:59:43Z")

</div>

Hello.  
When I am trying to decorate `GoogleShoppingPriceAgent` I get back that there is no registered service in the container with that name. I need to add a custom field, I have added the value to the `PriceAgentItem` but that doesn’t add it to the output XML from the `PriceAgent Render-method`. Hence I need/want to decorate the `GoogleShoppingPriceAgent` and add my value to the XML.

I have solved this by copying the code for `GoogleShoppingPriceAgent` and register my own agent before the built in one to completely override it. But I dont think it’s a nice solution.

So if anyone have decorated a `PriceAgent` implementation I would like to know how 🙂 (if possible)

Litium version: _[7.6.2]_

---

<div class="post-metadata">

**Author:** ![steve.redstorm](https://yyz2.discourse-cdn.com/flex030/user_avatar/forum.litium.com/steve.redstorm/32/14_2.png) [@steve.redstorm](https://forum.litium.com/u/steve.redstorm)\
**Post date:** [November 11, 2021, 3:21pm UTC](https://forum.litium.com/t/servicedecorator-for-googleshoppingpriceagent/2301/2 "2021-11-11T15:21:44Z")

</div>

You need to create 2 files/classes in Litium.Accelerator project:

> public class PriceAgentItemFactoryImpl : PriceAgentItemFactory

and

> [Plugin(“GoogleShopping”)]  
> public class GoogleShoppingPriceAgent : IPriceAgent

and implement your own logic.  
If you need some reference I got these files from Litium V6 that I can send you.

---

<div class="post-metadata">

**Author:** ![andreas.crona](https://yyz2.discourse-cdn.com/flex030/user_avatar/forum.litium.com/andreas.crona/32/662_2.png) [@andreas.crona](https://forum.litium.com/u/andreas.crona)\
**Post date:** [November 11, 2021, 8:17pm UTC](https://forum.litium.com/t/servicedecorator-for-googleshoppingpriceagent/2301/3 "2021-11-11T20:17:12Z")

</div>

Thanks for the reply Steve.  
This is the approach I went for when solving it, but I think it would be nice to just use service decorator on the already implemented `GoogleShoppingPriceAgent` that comes with the Accelerator.

Seems bloated to like write my own agent to just add one property. But if there is no other way I will go for it

---

<div class="post-metadata">

**Author:** ![steve.redstorm](https://yyz2.discourse-cdn.com/flex030/user_avatar/forum.litium.com/steve.redstorm/32/14_2.png) [@steve.redstorm](https://forum.litium.com/u/steve.redstorm)\
**Post date:** [November 12, 2021, 8:50am UTC](https://forum.litium.com/t/servicedecorator-for-googleshoppingpriceagent/2301/4 "2021-11-12T08:50:08Z")

</div>

These are not service classes so you can not decorate them.

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex030/uploads/litium/original/1X/12eddac3b8b661de1db86af10ac8151b571e6fb9.png) [@system](https://forum.litium.com/u/system)\
**Post date:** [December 10, 2021, 8:50am UTC](https://forum.litium.com/t/servicedecorator-for-googleshoppingpriceagent/2301/5 "2021-12-10T08:50:15Z")

</div>

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.
