检索 Spartacus 中客户的当前 B2B 单位
我想在标题中显示当前的 B2B 单位名称。 为当前客户检索 B2B 单位的正确方法是什么?
到目前为止我发现,/current 有一个有效负载?在初始页面加载时加载的端点,它包含 orgUnit:
当我尝试通过 CurrentUnitService 检索单位时,我得到了 null 值。
单元.组件.ts:
orgUnit$: Observable<B2BUnit> = this.currentUnitService.item$;
constructor(
protected currentUnitService: CurrentUnitService,
) {}
单元.组件.html:
<ng-container *ngIf="orgUnit$ | async as unit">
<p class="d-inline-block">{{unit.name}} </p>
<a href="#" class="d-inline-block">
({{unit.uid}})
</a>
</ng-container>
I want to show current B2B Unit name in the header.
What would be the correct way to retrieve B2B Unit for current customer?
What I found so far, there is a payload for /current? endpoint which is loaded on initial page load and it contains the orgUnit:
When I was trying to retrieve the Unit via CurrentUnitService, I got null value.
unit.component.ts:
orgUnit$: Observable<B2BUnit> = this.currentUnitService.item$;
constructor(
protected currentUnitService: CurrentUnitService,
) {}
unit.component.html:
<ng-container *ngIf="orgUnit$ | async as unit">
<p class="d-inline-block">{{unit.name}} </p>
<a href="#" class="d-inline-block">
({{unit.uid}})
</a>
</ng-container>
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我能够使用 UserAccountFacade 并通过使用 orgUnit 扩展用户模型来检索当前客户的 B2BUnit,如下所示:
unit.component.ts
unit.component.html
结果:
I was able to retrieve the B2BUnit for current customer using UserAccountFacade and by extending User model with orgUnit as follows:
unit.component.ts
unit.component.html
Result: