使用6.4在后台产品主控室中克隆产品

2020-08-24 12:17发布

点击此处---> 群内免费提供SAP练习系统(在群公告中)加入QQ群:457200227(SAP S4 HANA技术交流) 群内免费提供SAP练习系统(在群公告中)我正在尝试在后台克隆产品。 我可...

         点击此处--->   EasySAP.com群内免费提供SAP练习系统(在群公告中)

加入QQ群:457200227(SAP S4 HANA技术交流) 群内免费提供SAP练习系统(在群公告中)


我正在尝试在后台克隆产品。 我可以创建一个productCloneAction,然后在编辑器区域添加一个克隆图标。 当我单击克隆时,它进入该类的操作方法,并给我一个无标题的弹出窗口。 我在这里想念什么? 我尝试使用create action作为模型。 我还为产品定义了一个clonewizard组件。

definition.xml

  克隆产品操作
  克隆产品操作
   PGade 
   0.1 
   org.backoffice.product.actions.ProductCloneAction 
 
   <插座>
       
       
       
   

    de.hybris.platform.core.model.product.ProductModel 
  

  <!-必须在以下目录中创建带有图标的文件夹图标:/backoffice/resources/widgets/actions/myaction->
   icons/clone.png 
   icons/clone_hover.png 
   icons/clone_disabled.png 




  

Widgets.xml

  
      
  

backoffice-config.xml

  
                  
                       targetComponent 
                       editorArea 
                  
                  
                       initializeEntity 
                       true 
                  
                  
                       contextComponentName 
                         sampleComponent 
                  
              
  
7条回答
一只江湖小虾
2020-08-24 13:16

  @Override
  公共ActionResult 执行(最终ActionContext  ctx)
  {
      ActionResult 结果= null;
      如果([[ctx.getData()ProductModel的实例))
      {
          最终的ProductModel数据=(ProductModel)ctx.getData();
          最终Map  contextMap = new HashMap <>();
          contextMap.put(ConfigurableFlowContextParameterNames.TYPE_CODE.getName()," InsightProduct");

          contextMap.put(" code",data.getCode()+" Clone");
          contextMap.put(" name",data.getName());
          contextMap.put(" catalogVersion",data.getCatalogVersion());
          contextMap.put(" supercategories",data.getSupercategories());
          contextMap.put(" summary",data.getSummary());

          contextMap.put(" approvalStatus",data.getApprovalStatus());
          contextMap.put(" description",data.getDescription());

          尝试
          {
              this.sendConfiguredInsightOutput(ctx," cloneContext",contextMap," InsightProduct");
          }
          捕获(最终ObjectCreationException e)
          {
              LOG.error(e.getLocalizedMessage(),e);//80
          }
          LOG.info(" ctx.code ::" + data.getCode());
          结果=新的ActionResult <>(ActionResult.SUCCESS,数据);
      }
      其他
      {
          结果=新的ActionResult <>(ActionResult.ERROR);
      }
      返回结果;
  }

  protected void sendConfiguredInsightOutput(final ActionContext  ctx,final String socketId,
          最终Map  contextMap,最终String typeCode)抛出ObjectCreationException
  {
     //this.sendOutput("cloneContext",context);
      对象上下文;
      如果(this.shouldInitializeEntity(ctx))
      {//98
          最终对象newInstance = this.objectFacade.create(typeCode);//100
          最终对象组件= ctx.getParameter(" contextComponentName");//101
          最后的字符串componentName = ObjectUtils.toString(component,(String)null);//102
          最终字符串configCtx = StringUtils.defaultIfBlank(componentName,"");//103
          context = new ObjectWithComponentContext(newInstance,configCtx);//104

          对于(最终字符串键:contextMap.keySet())
          {
              (((ObjectWithComponentContext)上下文).setParameter(key,contextMap.get(key));
          }
      }
      其他
      {
          context = new CreateContext(typeCode);//108
          LOG.info("创建的对象类::::" +(typeCode));
      }

     //获取默认目录版本
      最终的CatalogVersionModel catalogVersion = catalogVersionService.getCatalogVersion(" insightProductMaster"," Staged");

     //设置目录版本
      LOG.info("创建的对象的类::::");

      如果(catalogVersion!= null)
      {
          LOG.info(" catalogVersion不为null");
          (((ObjectWithComponentContext)上下文).setParameter(" catalogVersion",catalogVersion);
          (((ObjectWithComponentContext)上下文).setParameter(" catalogVersionType"," CatalogVersion");
      }
      其他
      {
          LOG.info(" catalogVersion为null");
      }

      this.sendOutput(socketId,context);//112

  }

  受保护的布尔值shouldInitializeEntity(final ActionContext  ctx)
  {
      最终对象参数= ctx.getParameter(" initializeEntity");//117
      返回参数!= null && Boolean.valueOf(parameter.toString())。booleanValue();//118
  }

  @Override
  公共无效的initializeDefaultEventListeners()
  {
      this.addSocketInputEventListener(" clonededObject",(event)-> {//124
          this.sendOutput(" clonededObject",event.getData());//125
      });
  }//126
                                                                      

一周热门 更多>