> ## Documentation Index
> Fetch the complete documentation index at: https://dokumentation.websale.de/llms.txt
> Use this file to discover all available pages before exploring further.

# Alternative product data

> How to show specific buyer groups different prices and product data in WEBSALE V8s, via price rules or via imported product data files.

With alternative product data, you grant specific buyer groups different prices or product conditions. This is triggered either through the customer account or through a marketing link.

The difference from the test-oriented enrichment of product data, the ProductDataFieldInjection, lies in the source. Alternative product data comes from the ERP system. This allows not only price adjustments, but completely different product data.

## How it works

Three questions determine the process and the required settings. Clarify these before you start with the configuration.

### Where does the data come from?

There are two sources, and the two integration paths further below follow from them.

| Source | Suitability |
| - | - |
| Price rules in the configuration | Percentage discount or surcharge on all products |
| Import of alternative product data files | Arbitrary fields and values for specific products |

### When should it take effect?

When the shop is called, WEBSALE V8s checks whether at least one entry is active for the buyer or the session. An entry is active when its criteria are met. These include:

* a validity period from and to
* the call in test mode or in production mode
* the sub-shop
* an activation in the buyer's customer account
* an activation via a URL parameter

Price-influencing elements such as customer discounts and percentage vouchers can be excluded. To do this, you overwrite the corresponding standard fields in the alternative product data, for example the discount eligibility.

### What applies with multiple entries?

Several entries can be active at the same time. Using the `Priority` parameter, you set their weighting. The product's standard data is then enriched or replaced once with the highest-weighted alternative data.

If no alternative data exists for this entry, the entry with the next lower priority for which data is available takes effect.

> [!WARNING]
>
> Alternative product data has three limits that you should know before planning:
>
> It cannot be passed to the data feeds of the DataflowManager.
>
> It cannot be used in aggregate functions, meaning not in search, sorting, and filtering. An alternative price therefore does not affect a price sort, for example.
>
> It can only be used for products with dependent variants, or rather for fully resolved dependent variant combinations.

## Requirements

The following applies for both paths:

* You use the article import Pro.
* The feature must be activated by WEBSALE for your shop. Contact your WEBSALE representative for this.

In both cases, the configuration takes place in the file `product_alternatives.cfg` in the directory `/konfiguration/`. Create it if it does not yet exist.

## Path 1: Applying price rules

In the following example, product prices are reduced by 20 percent as soon as the buyer's billing address field `Suffix5` contains the value `aktiv`. The rule applies from 21.03.2022 at 12:00 until 01.01.2025 at 00:00.

```ini theme={"theme":{"light":"github-light","dark":"github-dark"},"languages":{"custom":["/languages/websale.json"]}}
<+Entry>
   ID                                  = thirdPAentry
   Type                                = PriceRule
   UsePriceShadowingVariables          = yes
   ValidFrom                           = 20220321-12
   ValidUntil                          = 20250101
   ValidInSubShops-List                = Deutsch
   Test                                = yes
   PriceRule                           = discount
   PriceRuleParameter1                 = 20
   Priority                            = 3
   <Conditions>
      <+ConditionSet>
         <+Condition>
            Type                       = ActivateWithUserAccountSuffixField
            Name                       = Suffix5
            Value                      = aktiv
         </+Condition>
      </+ConditionSet>
   </Conditions>
</+Entry>
```

The period follows the format `YYYYMMDD-HH`, the hour is optional. `Test = yes` means the entry initially only takes effect in test mode, see the section on testing further below.

Reference: Configuration product\_alternatives.cfg&#x20;

## Path 2: Using alternative product data files

Here the ERP system delivers a second product data file that fully or partially replaces the first.

### Creating the file

The file name consists of the name of the original product data file and a freely selectable technical suffix. Permitted are alphanumeric characters as well as hyphen, underscore, and period.

If the original product data is in `1234.prg`, the alternative file is called, for example, `1234.prg-apd`.

> [!WARNING]
>
> The alternative file must contain **all** product data, not just the differing fields.
>
> If a product has base data, alternative data for a marketing campaign, and alternative data for specific customers, these cannot be updated individually. When the product is updated, all files must always be delivered, both the alternative and the regular ones.

### Adding to the configuration

In the following example, alternative product data is used in the same period as soon as the shop is called with the URL parameter `pafirsttest=aktiv`, for example via `https://www.xyz.de/?pafirsttest=aktiv`.

```ini theme={"theme":{"light":"github-light","dark":"github-dark"},"languages":{"custom":["/languages/websale.json"]}}
<+Entry>
   ID                                  = secondPAentry
   Type                                = AlternativeProductDataFields-Replacement
   AlternativeProductDataFileExtension = -apd
   UsePriceShadowingVariables          = yes
   ValidFrom                           = 20220321-12
   ValidUntil                          = 20250101
   ValidInSubShops-List                = Deutsch
   Test                                = yes
   Priority                            = 3
   <Conditions>
      <+ConditionSet>
         <+Condition>
            Type                       = ActivateWithURLParameter
            Name                       = pafirsttest
            Value                      = aktiv
         </+Condition>
      </+ConditionSet>
   </Conditions>
</+Entry>
```

The suffix from the file name goes into `AlternativeProductDataFileExtension`. Both values must match, otherwise the shop will not find the file.

## Showing original prices

This step is optional, but usually essential for the price display.

If the function overwrites a data field, in this case the price, the designer cannot tell in the template that the regular price was a different one. The shadow tags exist for this purpose. With them you additionally display the original price, for example as a strike-through price.

Product detail view `ws_product.htm`:

```html theme={"theme":{"light":"github-light","dark":"github-dark"},"languages":{"custom":["/languages/websale.json"]}}
{PR-UseAlternativeProductData}
   {APD-UsePriceShadow}
      {PR-PriceShadow}Ursprünglicher Preis: ~PR-PriceShadow~ ~WS-Currency~{/PR-PriceShadow}
      {PR-SetPriceShadow}Ursprünglicher Set-Preis: ~PR-SetPriceShadow~ ~WS-Currency~{/PR-SetPriceShadow}
   {/APD-UsePriceShadow}
{/PR-UseAlternativeProductData}
```

Shopping cart page `ws_basket.htm`:

```html theme={"theme":{"light":"github-light","dark":"github-dark"},"languages":{"custom":["/languages/websale.json"]}}
{BASKET-PR-UseAlternativeProductData}
   {APD-UsePriceShadow}
      {BASKET-PR-PriceShadow}Ursprünglicher Preis: ~BASKET-PR-PriceShadow~ ~WS-Currency~{/BASKET-PR-PriceShadow}
      {BASKET-PR-SetPriceShadow}Ursprünglicher Set-Preis: ~BASKET-PR-SetPriceShadow~ ~WS-Currency~{/BASKET-PR-SetPriceShadow}
   {/APD-UsePriceShadow}
{/BASKET-PR-UseAlternativeProductData}
```

Both examples assume that `UsePriceShadowingVariables = yes` is set in the entry. The `APD-UsePriceShadow` bracket checks exactly that.

## Displaying information about the active entry

Also optional, but very useful for troubleshooting. On any template, this shows which entry is currently taking effect and with which settings.

```html theme={"theme":{"light":"github-light","dark":"github-dark"},"languages":{"custom":["/languages/websale.json"]}}
{ST-AlternativeProductData}
   ID:               {APD-ID}~APD-ID~{/APD-ID}
   Type:             {APD-TypeProductRule}ProductRule{/APD-TypeProductRule}
                     {APD-TypeAPDataFieldsReplacement}APDataFieldsReplacement{/APD-TypeAPDataFieldsReplacement}
                     {APD-TypeAPDataFieldsComplementary}APDataFieldsComplementary{/APD-TypeAPDataFieldsComplementary}
   FileExtension:    {APD-FileExtension}~APD-FileExtension~{/APD-FileExtension}
   UsePriceShadow:   {APD-UsePriceShadow}yes{/APD-UsePriceShadow}
                     {!APD-UsePriceShadow}no{/!APD-UsePriceShadow}
   ValidFrom:        {APD-ValidFrom}~APD-ValidFrom~{/APD-ValidFrom}
   ValidUntil:       {APD-ValidUntil}~APD-ValidUntil~{/APD-ValidUntil}
   ValidSubshopList: {APD-ValidSubshopList}~APD-ValidSubshopList~{/APD-ValidSubshopList}
   Test:             {APD-Test}yes{/APD-Test}
                     {!APD-Test}no{/!APD-Test}
   Priority:         ~APD-Priority~
{/ST-AlternativeProductData}
```

The `FileExtension` line is only filled when using the product data files path.

## Testing and going live

As long as `Test = yes` is set, the entry only takes effect in test mode. Call the shop accordingly and check whether the alternative data is applied as expected.

```text theme={"theme":{"light":"github-light","dark":"github-dark"},"languages":{"custom":["/languages/websale.json"]}}
https://www.xyz.de/?test=on
```

After the test, you end the test mode.

```text theme={"theme":{"light":"github-light","dark":"github-dark"},"languages":{"custom":["/languages/websale.json"]}}
https://www.xyz.de/?test=off
```

If the test is successful, set `Test` to `no` in the entry. It will then take effect in production mode.

```ini theme={"theme":{"light":"github-light","dark":"github-dark"},"languages":{"custom":["/languages/websale.json"]}}
<+Entry>
   ...
   Test      = no
   ...
</+Entry>
```

Guide: Enabling and disabling the shop's test modes&#x20;


## Related topics

- [Alternative product data: tags](https://dokumentation.websale.de/en/v8s/referenz/tags/alternative-produktdaten-tags.md)
- [Configuration product_alternatives.cfg](https://dokumentation.websale.de/en/v8s/referenz/konfigurationen/konfiguration-product-alternatives-cfg.md)
- [Enriching product data](https://dokumentation.websale.de/en/v8s/produkte/anreichern-von-produktdaten.md)
- [PR- (Basics and product data)](https://dokumentation.websale.de/en/v8s/referenz/tags/pr/grundlagen-und-produktdaten.md)
- [ST- (page state and navigation)](https://dokumentation.websale.de/en/v8s/referenz/tags/st/seitenzustand-und-navigation.md)


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.