# Dynamic products

To integrate [dynamic products](https://docs.hostware.io/developer-documentation/module/hosting-module/broken-reference) into your hosting module, you need to implement following method in your HostingHandler.php file.

```php
public function getDynamicProducts(Category $category): ServerHostingDynamicProductResponse {
   $products = [];
   $productOptions = [];

   /*
    * Get and iterate all remote products. 
    *
    * The KEY should be the unique product identifiert, the value is a App\Models\Product object.
    */
   foreach($this->getClient($category->sales_channel_id)->getServers() as $serverItem){
   	$products[$serverItem->uuid] = new Product([
		"module_settings" => [
			"serverId" => $serverItem->uuid,
		],
		"price_base" => $serverItem->price->monthly, // monthly price
		"price_setup" => $serverItem->price->setup, // setup price if applicable
		
		"product_options" => [ // more on product options below!
			"os"
		],
		
		"de-DE" => [
			"name" => "Produkt Name",
			"description" => "Produkt Beschreibung DE"
		],
		"en-GB" => [
			"name" => "Product name",
			"description" => "Product description EN"
		]
	]);
   }

   return new ServerHostingDynamicProductResponse(
        $products,
        $productOptions
    );
}
```

## Develop / try out / debug

To try the code of your dynamic product implementation, first [create a category](https://docs.hostware.io/developer-documentation/module/hosting-module/broken-reference) where your module is listed as the only *dynamic source*.

Afterwards, use the following command to try out the code of your module. Note that you should replace the category id with the one you created.\
If you only have one category, you can just remove the categoryId= option.

```php
php artisan hw:synchronizeDynamicCategories --categoryId=1
```
