Search code examples
calculationintershop

Register basket calculation result view


We are trying to implement our own custom basket calculation rule set and register new result view to get basket calculation results, but we are unable to find some info how to register new result view class?

We are using examples from here: https://support.intershop.com/kb/index.php/Display/23V395#Cookbook-BasketCalculation-Recipe:TheResultView

And problem is, how to use/register "TutorialCalculationResultView" class?

Thank you!


Solution

  • You need to create a factory class which creates the result view:

    public class TutorialCalculationResultViewFactoryImpl implements CalculationResultViewFactory
    {
        @Override
        public LineItemCtnrCalculationResultView createCalculationResultView(BaseCalculationResultView view)
        {
            return new TutorialCalculationResultView(view);
        }
    }
    

    Then this implementation needs to be wired via the component framework:

    <implementation name="TutorialCalculationResultViewFactory" implements="CalculationResultViewFactory"
                    class="yourPackageName.TutorialCalculationResultViewFactoryImpl" />
    

    Finally you have to register an instance of this class as described in the cookbook:

    <fulfill requirement="assignment" of="BasketBOCalculationResultViewExtensionFactory">
        <instance with="CalculationResultViewFactoryAssignment">
            <fulfill requirement="ruleSetID" value="yourPackageName.TutorialRuleSet" />
            <fulfill requirement="factory">
                <instance with="TutorialCalculationResultViewFactory" />
            </fulfill>
        </instance>
    </fulfill>