zl程序教程

您现在的位置是:首页 >  其他

当前栏目

SAP Spartacus和product相关的标准normalizer

SAP标准 相关 Spartacus product
2023-09-14 09:02:55 时间

以product name normalizer为例:

路径:C:\Code\SPA\spartacus\projects\core\src\occ\adapters\product\converters\product-name-normalizer.ts

拷贝下类的名称:
ProductNameNormalizer

如果想运行时调试,在Spartacus-core.js里,根据这个名称搜索,找到对应的JavaScript function:ProductNameNormalizer_Factory:

/**
 * Construct an `InjectableDef` which defines how a token will be constructed by the DI system, and
 * in which injectors (if any) it will be available.
 *
 * This should be assigned to a static `ɵprov` field on a type, which will then be an
 * `InjectableType`.
 *
 * Options:
 * * `providedIn` determines which injectors will include the injectable, by either associating it
 *   with an `@NgModule` or other `InjectorType`, or by specifying that this injectable should be
 *   provided in the `'root'` injector, which will be the application-level injector in most apps.
 * * `factory` gives the zero argument function which will create an instance of the injectable.
 *   The factory can call `inject` to access the `Injector` and request injection of dependencies.
 *
 * @codeGenApi
 */
function ɵɵdefineInjectable(opts) {
    return {
        token: opts.token,
        providedIn: opts.providedIn || null,
        factory: opts.factory,
        value: undefined,
    };
}


随着构造函数一起传进来的配置对象:

这个配置对象的赋值是通过eeinject(OccConfig)进行的:

converter调用的地方:Pipeable operator to apply converter logic in a observable stream


 convertSource(source, injectionToken) {
        return this.getConverters(injectionToken).reduce((target, converter) => {
            return converter.convert(source, target);
        }, undefined);
    }

向Commerce Cloud后台发起请求:



得到完整的occ地址:



要获取更多Jerry的原创文章,请关注公众号"汪子熙":