/
Tips on Logic Customization

Tips on Logic Customization

Configure Your Custom Logic

  1. Locate Live Price Grid you want to use for testing your changes. If you do not have one, create a new one.

  2. Update the price grid configuration.

    1. Select the Live Price Grid, and use Configure to open the configuration dialog for the existing price grid.

    2. In the price grid configuration, update several settings:

      1. Allow column type change – Select YES.
        Note: This is needed because we added a new field and so we need to regenerate the meta-data about columns during full recalculation of the price grid.

      2. Default Pricing Logic – Select Training_ParentPriceListLogic.

      3. Parent Level Name – Select Global (it may be different in every installation, so use whatever dependency level name you have configured during deployment).
        Note: When you change the default logic, the content of this input field will be wiped, so you need to set the value again.

      4. Output Elements – Make sure that the new element named TrainingCustomField is checked too.

    3. Save the changes in price grid configuration.

    lpg configuration

Approach to Modifications

All Price Setting Accelerator modifications best practices are built on top of modularization-first approach. Thanks to that, it should be relatively easy to replace parts of the accelerator implementation. E.g. if you want to change how you load competition data, you can just replace the code inside tryToExecuteElement in the CompetitionData element and the rest of the app will still work fine as long as the structure you return is the same as the original one.

One thing to keep in mind is how to modify behavior of the PriceBuilderCommonElementUtils library. It is usually safer to create your own library with your own version of the util and call it from the element in a parent/dependent logic. It will make it easier to re-apply the changes if you want to upgrade the accelerator. Also, it will make it much easier to check if issues you are experiencing are related to the accelerator or your custom code.

Element Structure

Both extension methods do not restrict how you write your code, so you can develop whatever is in your requirements. That is why the example code is very basic. The point of this article is to show you how to plug it in into the accelerator.

You can completely ignore the tryToExecuteElement method, but if you want your code to fail gracefully, the recommended structure for a new or modified element is:

/** * Ideally some doc should be here */ return out.WarningManager.tryToExecuteElement("YourElementName") { // Your code goes here }

Actual Price Lookup - Special Case

Both approaches suggest cloning Price Setting Accelerator logic. While doing so, it is important to pay attention to the element ActualPriceLookup which retrieves the actual price of the product.

There are different modes to get the actual price:

  • Live Price Grid mode – Commonly used mode in Live Price Grids. It takes the last approved price of the Live Price Grid, and if there is no approved one (e.g. because you are in the initial state), it will take the actual or the new price.

  • You can store the actual price in a Product Extension or other data source, e.g. if you have an ERP, you usually have your reference price list there.

  • From the latest approved price list of your level. This is used mostly when working with price lists (and not the price grids) where you want to make a new price list for a new season or next year, and you want the actual price to be taken from the year before. So it will always find the latest approved price list. When using dependency levels (like global and countries) it will always use the same dependency level – i.e. when calculating a new global price list, it will always look for the last approved global price list.

The last of the mentioned modes is the reason why you need to override the ActualPriceLookup element. This is how to do it:

  1. Modify the name of the logic in the element ActualPriceLookup.

    1. Edit your cloned/inherited version of ParentPriceListLogic.

    2. Select the element ActualPriceLookup.

    3. Find the line of code which defines the logic name to be ParentPriceListLogic and change the logic name to your new logic name.

      actual price lookup
    4. Save the logic.

  2. Test the change. To be able to test it, you need to simulate the scenario above which is actually using this logic name.