0

在后台我有两个节点,如下所示。我只有一个项目类型“绥靖”。那么如何在后台过滤和显示它。

  1. code="PendingAppeasements" id="PendingAppeasements"
  2. 代码="CompletedAppeasements" id="CompletedAppeasements"

参考代码:

custome_backoffice_config.xml :- 
<context component="explorer-tree" merge-by="module">
  <explorer-tree:explorer-tree xmlns:explorer-tree="hybris.com/cockpitng/config/explorertree">
    <explorer-tree:navigation-node id="AppeasementsDetails">
      <explorer-tree:type-node code="PendingAppeasements" id="PendingAppeasements" />
      <explorer-tree:type-node code="CompletedAppeasements" id="CompletedAppeasements" />
    </explorer-tree:navigation-node>
  </explorer-tree:explorer-tree>
</context>
4

1 回答 1

0

我没有完整的分步回答,但是在 6.7 版本的 hybris 中,促销源规则显示两个节点,一个节点显示所有促销源规则,一个节点仅显示状态为已发布或未发布的促销源规则(省略不活动,存档等),因此在两个节点之间进行了一些过滤。(要在后台查看,导航到 Marketing -> Promotion Rules,您会看到两个子节点) 注意:在以后的版本中,这再次更改,只有一个节点。

如果我理解正确,“过滤视图”通过添加初始高级搜索配置来工作,该配置根据其状态过滤掉促销源规则。您可以通过复制和调整方法来实现类似的效果。

关键配置元素似乎在 /promotionenginebackoffice/resources/promotionenginebackoffice-backoffice-config.xml (声明两个资源管理器树节点):

        <explorer-tree:explorer-tree xmlns:explorer-tree="http://www.hybris.com/cockpitng/config/explorertree">
            <explorer-tree:navigation-node id="hmc_treenode_marketing">
                <explorer-tree:navigation-node id="hmc_type_tree_abstractpromotion" merge-mode="remove" />
                <explorer-tree:navigation-node id="hmc_typenode_promotion_rules">
                    <explorer-tree:type-node id="hmc_published_and_unpublished_promotion_rules_only" code="PromotionSourceRule"/>
                    <explorer-tree:type-node id="hmc_all_promotion_rules_only" code="PromotionSourceRule"/>
                </explorer-tree:navigation-node>
                <explorer-tree:type-node id="hmc_typenode_promotion_rule_templates" code="PromotionSourceRuleTemplate"/>
                <explorer-tree:type-node id="hmc_type_tree_promotiongroup" code="PromotionGroup"/>
                <explorer-tree:type-node id="hmc_typenode_promotion_modules" code="DroolsKIEModule"/>
            </explorer-tree:navigation-node>
        </explorer-tree:explorer-tree>
    </context>

并在 /promotionenginebackoffice/resources/promotionenginebackoffice-backoffice-widgets.xml 中(声明过滤 bean):

<widget id="initPromotionSourceRuleAdvancedSearch" widgetDefinitionId="com.hybris.cockpitng.widgets.common.advancedsearchengine.genericinitializer"
                slotId="cockpitWidgetChildrenInvisible" template="false">
            <setting key="requiredTypeCode" type="String" value="PromotionSourceRule"/>
            <setting key="navigationNodeId" type="String" value="hmc_published_and_unpublished_promotion_rules_only"/>
            <setting key="handlerBeanId" type="String" value="sourceRuleAdvancedSearchInitHandler"/>
            <virtual-sockets/>
        </widget>

进行过滤的 bean(在前面的代码片段中提到)定义在:

<alias name="defaultSourceRuleAdvancedSearchInitHandler" alias="sourceRuleAdvancedSearchInitHandler"/>
    <bean id="defaultSourceRuleAdvancedSearchInitHandler" class="de.hybris.platform.ruleenginebackoffice.handlers.SourceRuleAdvancedSearchInitializer"/>

bean 代码本身是这样的:

public class SourceRuleAdvancedSearchInitializer implements AdvancedSearchInitializer
{
    private static final String STATUS = "status";

    @Override
    public void addSearchDataConditions(final AdvancedSearchData searchData, final Optional<NavigationNode> navigationNode)
    {
        if (nonNull(searchData))
        {
            removeExistingStatusCondition(searchData);
            searchData.addConditionList(ValueComparisonOperator.OR, createStatusSearchConditions());
        }
    }

    protected void removeExistingStatusCondition(final AdvancedSearchData searchData)
    {
        final List<SearchConditionData> conditions = searchData.getConditions(STATUS);
        if (isNotEmpty(conditions))
        {
            conditions.clear();
        }
    }

    protected List<SearchConditionData> createStatusSearchConditions()
    {
        return newArrayList(createStatusConditionsList());
    }

    protected SearchConditionDataList createStatusConditionsList()
    {
        final FieldType status = createStausField();
        final List statusConditionsList = new ArrayList();
        statusConditionsList.add(createCondition(status, RuleStatus.UNPUBLISHED));
        statusConditionsList.add(createCondition(status, RuleStatus.PUBLISHED));
        return SearchConditionDataList.or(statusConditionsList);
    }

    protected FieldType createStausField()
    {
        final FieldType status = new FieldType();
        status.setDisabled(Boolean.FALSE);
        status.setSelected(Boolean.TRUE);
        status.setName(STATUS);
        return status;
    }

    protected SearchConditionData createCondition(final FieldType status, final RuleStatus predicate)
    {
        return new SearchConditionData(status, predicate, ValueComparisonOperator.EQUALS);
    }

}

希望这可以帮助 :)

于 2020-01-07T10:40:17.707 回答