London Dev Meetup Rescheduled! Due to unavoidable reasons, the event has been moved to 21st May. Speakers remain the same—any changes will be communicated. Seats are limited—register here to secure your spot!

Obtaining a price for a specific content reference/variant

Vote:
 

Hello all,

I'm working on a feature that requires the lookup of pricing of a particular content reference - here is the code I currently have, based upon the documentation/posts and articles I've read, it looks like I need to use the PriceService to lookup the price based upon a CatalogKey - but I'm unsure on what object, or what service I need to use in order to look up the pricing information?

Currently I have this lookup that is working correctly for retreiving the relevant data:

var contentReference = _referenceConverter.GetContentLink(req.itemCode);

                    List<ContentReference> references = new List<ContentReference>();
                    references.Add(contentReference);

                    var variantContent = _contentRepository.GetItems(references, CultureInfo.InvariantCulture).Cast<VariationContent>()
                                                    .ToList(); ;

Based upon documentation, I was working on gathering the pricing data for the items in reference by:

decimal price = _priceService.GetPrices(Mediachase.Commerce.MarketId.Default, DateTime.UtcNow,{Catalog_Key?} ,  null);

What is the best method to retrieve the relevant CatalogKey for my loaded data?

Thank you!

#219029
Mar 27, 2020 19:11
Vote:
 

You can just use the constructor 

new CatalogKey(entryCode);

#219032
Mar 27, 2020 20:27
Sean Haddy - Mar 27, 2020 21:12
Like this?
var contentReference = _referenceConverter.GetContentLink(req.itemCode);
var catKey = new CatalogKey(contentReference.ID.ToString());

Not sure what "entryCode" refers to?
Vote:
 

You can use ReferenceConverter to get the code from the content link

#219033
Mar 27, 2020 20:31
Sean Haddy - Mar 27, 2020 21:14
What method would I use within Reference converter to get the code from the content link?
Vote:
 

I see you already have the code, so simply

var catKey = new CatalogKey(req.itemCode);

#219055
Mar 28, 2020 8:06
Sean Haddy - Mar 28, 2020 15:18
Item Code in my example is related to a domain entity for our commerce system, the item code for example would be "BB251D00GRY BB30 XTYP" for our catalog system. I believe that this isn't going to work, as if I try to get a catalog key with that particular code, it comes back null for a catalog key. Is there a way to get that code from the content reference?
Vote:
 

ReferenceConverter.GetCode(contentLink) should let you do that

#219083
Mar 29, 2020 10:48
Vote:
 

@Quan I appreciate your help/feedback so far - I actually tried that before, unfortunately the _catalogEntryId on the new Catalog key comes back null when I use Refconv to get the code. Here is some debugging information:

#219088
Mar 29, 2020 15:44
Vote:
 

You don't need the _catalogEntryId there. For getting prices code is enough

#219089
Mar 29, 2020 17:24
Vote:
 

Quan, thank you for your help - after that didn't work I did some more investigation with our solution. Based upon the new implementation that was made with our D365 integration, our partner setup a custom pricing system that queries our ERP retail server directly for the pricing information. Due to this, the pricing information isn't available on the item/sku level within Episerver - which is why my retrieval methods were unsuccessful using the out-of-the-box methods. Sorry for wasting your time, I appriciate your replying and providing information about this lookup.

#219090
Mar 29, 2020 19:03
Quan Mai - Mar 30, 2020 6:56
No worries, glad that you solved the problem
This topic was created over six months ago and has been resolved. If you have a similar question, please create a new topic and refer to this one.
* You are NOT allowed to include any hyperlinks in the post because your account hasn't associated to your company. User profile should be updated.