2023-05-15 Update
Please mind to provide your custom StoreFinderAdapter
not in the app.module
(not in the root injector), but provide it in your lazy-loaded custom "wrapper" module of the storefinder feature.
For more, see docs of Customizing Lazy Loaded Modules.
It's needed, since the store finder feature became lazy loaded by default in new versions of Spartacus.
2021-06-09 Original answer
Solution
{
provide: StoreFinderAdapter, // not OccStoreFinderAdapter
useClass: ThmOccStoreFinderAdapter
}
Explanation
For the token StoreFinderAdapter
, Spartacus OOTB passes the OccStoreFinderAdapter
via useClass
(but not via useExisting
):
{
provide: StoreFinderAdapter,
useClass: OccStoreFinderAdapter
}
Therefore OccStoreFinderAdapter
is not an injectable and cannot be custom-provided. It was just used as a raw implementation of the abstract StoreFinderAdapter
Note: If StoreFinderAdapter
was provided with OccStoreFinderAdapter
via useExisting
and the OccStoreFinderAdapter
was provided itself as an injectable (i.e. in the root injector: @Injectable({providedIn: 'root'})
), then your code would work as you expected:
{
provide: OccStoreFinderAdapter,
useClass: ThmOccStoreFinderAdapter
}