美文网首页SAPSAP 实用篇
SAP Spartacus和product相关的标准normal

SAP Spartacus和product相关的标准normal

作者: _扫地僧_ | 来源:发表于2020-12-01 10:30 被阅读0次

    以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地址:



    相关文章

      网友评论

        本文标题:SAP Spartacus和product相关的标准normal

        本文链接:https://www.haomeiwen.com/subject/rmeoektx.html