Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow additional data to be passed to product adaptors #445

Open
seanrockster opened this issue Oct 27, 2023 · 2 comments
Open

Allow additional data to be passed to product adaptors #445

seanrockster opened this issue Oct 27, 2023 · 2 comments
Labels
enhancement New feature or request

Comments

@seanrockster
Copy link

Is your feature request related to a problem? Please describe.
Not a problem perse but I do have to pass the product reference a specific way so the adapter can handle the request. Not ideal and very error prone.

Describe the solution you'd like
Have an overload for .GetProduct() that takes, for example an IDictionary<string,string>(), that can contain additional information for a custom adapter to retrieve product data.

Describe alternatives you've considered
Before we call .GetProduct() we have to build a new string with the portions of the sku separated by a space. In the adapter, it can then use those separated values to retrieve all the data from the various data stores.

Additional context
Product adaptors are fairly limited given all you get is the product reference to work with. In my situation all product data is split between 2 or 3 locations. Some information is from one location (database) and other data, i.e. price and stock are coming from another location (erp export). To get the product data we need only a portion of the product reference (sku) but unfortunately the client does not have a defined structure for their skus. In the adapter we don't have a way to determine the parts of the sku so we have to pass in the parts separated by a space.

@seanrockster seanrockster added the enhancement New feature or request label Oct 27, 2023
@mattbrailsford
Copy link
Contributor

It's not out of the question, but the problem is, product adapter is called from within the AddProduct method on an order and all this knows is the product reference. The question is how should that info get passed through, without exposing implementation details. The AddProduct shouldn't need to know about "extra info to pass to the product adapeter".

Where are those extra parts of the SKU coming from?

@seanrockster
Copy link
Author

Hi Matt

In my case, I cannot reliably parse a sku to determine its constituent parts, those being style + colour code + size. Unfortunately the client does not have a set schema, e.g. first 5 are the style, next 4 are the colour and anything after that is the size. The data is all over the place.

The bulk of the product information is coming from their erp (navision) and we import into Ravendb. We import the data from several different sql tables and create a single document per product for searching and aggregation. For the product data we only need the style, but to retrieve the price and stock (and discounts), we need the full sku. As I said above, from a given sku there is no reliable way to break it apart. Currently I have to separate them with a space, e.g. PR123 BLK 16/17 so I can pull all the product data from raven and then remove the spaces and look up price and stock with the full sku.

2 suggestions

  1. I guess it goes against the default implementation knowing about extra information.
    Possibly an overload on the AddProduct that accepts a dictionary to pass in additional information. The default implementation could ignore it but if the developer has implemented a custom adaptor they will have the flexibility of passing additional information if necessary.

  2. Possibly a ValueObject as the reference instead of a literal. I could then subclass that and add any additional properties I need. The default implement need not know about it but I can cast the product reference to my type. Could be misused however in some cases.

Just a suggestion as what I'm doing is a bit hacky, but works.

Thanks.

@seanrockster seanrockster changed the title All additional data to be passed to product adaptors Allow additional data to be passed to product adaptors Sep 17, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants