电脑桌面
添加蚂蚁七词文库到电脑桌面
安装后可以在桌面快捷访问

【购物商城】鑫方盛初始化分类改为一、二、四级

来源:金蝶云社区作者:金蝶2024-09-225

【购物商城】鑫方盛初始化分类改为一、二、四级

需求:鑫方盛一共有四级分类,购物商城默认只支持三级,目前鑫方盛分类初始化默认是导入鑫方盛的二、三、四级,客户想要导入鑫方盛的一、二、四级


二开指南:

修改集成管理-集成对象 SRM_XFS_GOODS_getChnCategory_init  的结果转换脚本


将里面的内容替换成一下内容保存

if ($result.success == false) {
	throw $result;
}
var result = [];
var fourth = $result.result;

for (value: fourth) {
	var param = {
		"code": value.code
	};
	//获取鑫方盛四级分类信息作为我们的三级叶子分类
	var fourthCategoryInfo = judgeSuccessAndTryAngain($service("/product/getCategoryInfo", param), $service, param);
	//如果分类已存在就不需要再取获取
	if (!Collection.contains(result, fourthCategoryInfo.parentCode)) {
		//获取鑫方盛三级级分类信息
		param = {
			"code": fourthCategoryInfo.parentCode
		};

		var thirdCategoryInfo = judgeSuccessAndTryAngain($service("/product/getCategoryInfo", param), $service, param);
  			result += {
		catId: fourthCategoryInfo.code,
		parentId: thirdCategoryInfo.parentCode,
		name: fourthCategoryInfo.name,
		catClass: fourthCategoryInfo.level - 1,
		state: fourthCategoryInfo.state,
		isleaf: "1"
			};
  		if (!Collection.contains(result, thirdCategoryInfo.parentCode)) {
            //获取鑫方盛二级级分类信息作为我们的二级分类
			param = {
				"code": thirdCategoryInfo.parentCode
			};
            var secondCategoryInfo = judgeSuccessAndTryAngain($service("/product/getCategoryInfo", param), $service, param);
        	result += {
			catId: secondCategoryInfo.code,
			parentId: secondCategoryInfo.parentCode,
			name: secondCategoryInfo.name,
			catClass: secondCategoryInfo.level,
			state: secondCategoryInfo.state,
			isleaf: "0"
		};
		//如果分类已存在就不需要再取获取
		if (!Collection.contains(result, secondCategoryInfo.parentCode)) {
			//获取鑫方盛一级分类信息作为我们的一级分类
			param = {
				"code": secondCategoryInfo.parentCode
			};

			var firstCategoryInfo = judgeSuccessAndTryAngain($service("/product/getCategoryInfo", param), $service, param);
			result += {
				catId: firstCategoryInfo.code,
				parentId: firstCategoryInfo.parentCode,
				name: firstCategoryInfo.name,
				catClass: firstCategoryInfo.level,
				state: firstCategoryInfo.state,
				isleaf: "0"
			};
		}
        }

	}

}
return result;

function judgeSuccessAndTryAngain(result, $service, param) {
	if (result.success) {
		return result.result;
	} else {
		if (result.resultMessage == "请求频繁,请稍后再试!") {
			Sleep(800);
			result = $service("/product/getCategoryInfo", param);
			if (result.success) {
				return result.result;
			} else {
				throw result;
			}
		}
		throw result;
	}
}


修改集成管理-集成对象 SRM_XFS_GOODS_getCategory_init  的结果转换脚本


将里面内容替换成以下内容

$result = judgeSuccessAndTryAngain($result,$service,param);
//test
//$result = [{"code":"03","parentCode":"0","name":"办公","level":1 ,"state":1 }];
//test
var firstcategory =$params.firstcategory;
var first = $result.filter(code==#.firstcategory).each({catId:code,parentId:"0",name:name,catClass:level,state:state,isleaf:"0"});
var result = [];
var second = [];
var third = [];
var fourth = [];
result = Collection.addAll(first, result);
for(value : first){
   second =Collection.addAll(second, getSecond($service,value));
}
result = Collection.addAll(second, result);

for(value : second){
  third =Collection.ad

【购物商城】鑫方盛初始化分类改为一、二、四级

需求:鑫方盛一共有四级分类,购物商城默认只支持三级,目前鑫方盛分类初始化默认是导入鑫方盛的二、三、四级,客户想要导入鑫方盛的一、二...
点击下载文档文档为doc格式

声明:除非特别标注,否则均为本站原创文章,转载时请以链接形式注明文章出处。如若本站内容侵犯了原著者的合法权益,可联系本站删除。

已经是第一篇
确认删除?
回到顶部
客服QQ
  • 客服QQ点击这里给我发消息
QQ群
  • 答案:my7c点击这里加入QQ群
支持邮箱
微信
  • 微信