November Happy Hour will be moved to Thursday December 5th.
November Happy Hour will be moved to Thursday December 5th.
This is one place that you should use ICatalogSystem. It has a method named GetCatalogEntryByUriDto which is pretty fast and efficient. You can use it to load the CatalogEntryDto, then use referenceConverter to get the contentLink from CatalogEntryDto.CatalogEntry[0].CatalogEntryId, then load the content.
Hi Quan,
Thanks for your suggestion, that worked straight away.
Thanks,
Anurag
Hi Quan,
I just realise that irrespective of what "languageCode" I specify in _catalogSystem.GetCatalogEntryByUriDto(SEOUri, "en-GB"); or "en-CA" I always get "en-US", United State" product.
Do you know what could be the reason as because of the Variants are also "US" language?
Thanks,
Anurag
You don't even need to pass the languageCode, you just need to get the CatalogEntryDto which then you get the CatalogEntryId, then you need to pass "en-GB" into the IContentLoader.Get<EntryContentBase>(contentLink, CultureInfor.GetCultureInfor("en-GB"))
If you don't pass the CultureInfo into Get<T> then it always load the default language, in this case, en-US
Hi,
With below code I can now get proper Product, but the variants are still coming for US version.
var productCatalogEntry = _catalogSystem.GetCatalogEntryByUriDto(SEOUri, ConversionHelpers.GetCultureCode(CountryCode));
var productContentLink = _referenceConverter.GetContentLink(productCatalogEntry.CatalogEntry[0].Code);
var productCatalog = _contentLoader.Get<BookProduct>(productContentLink, ConversionHelpers.GetCultureInfo(CountryCode)); // Correct Product is coming now.
var allRelations = _linksRepository.GetRelationsBySource(productCatalog.ContentLink); // This gives US variant even if "en-GB" is passed.
var bookVariantsList = allRelations.OfType<ProductVariation>().ToList();
var variantsList = new List<BookVariant>();
Any idea?
Thanks,
Anurag
Hi Quan,
I got the Variants correctly now, below is my code snippet, I did the samething with Variant that you suggested for Product.
var allRelations = _linksRepository.GetRelationsBySource<ProductVariation>(productCatalog.ContentLink);
var variantsList = new List<BookVariant>();
foreach(var bookVariant in allRelations)
{
var variantCatalogEntry = _catalogSystem.GetCatalogEntryDto(bookVariant.Target.ID);
var variantContentLink = _referenceConverter.GetContentLink(variantCatalogEntry.CatalogEntry[0].Code);
var variantCatalog = _contentLoader.Get<BookVariant>(variantContentLink, ConversionHelpers.GetCultureInfo(CountryCode));
variantsList.Add(variantCatalog);
}
Thanks,
Anurag
Hi,
I am looking to create a function that will return "Product" for the given SEOURI.
So far I have reached to a point where I can get a product with matching SEOURI if it exists in Root Node.
var RootLink = referenceConverter.GetContentLink(referenceConverter.GetRootLink());(RootLink , new CultureInfo("en-GB")) .Where(pd => pd.SeoUri == SEOURIParam).ToList();
var Product= ContentLoader.GetChildren
Is their a way I can search for Product in entire catalog, irrespective of what hierarchy level product exists.
I don't want to loop through each ProductListingNode to find the matching product.
Thanks,
Anurag