November Happy Hour will be moved to Thursday December 5th.
November Happy Hour will be moved to Thursday December 5th.
actually entry is filled for product and from product i can get variation but not vice versa
this:
http://world.episerver.com/Modules/Forum/Pages/thread.aspx?id=54275
helped me resolve this
In R2SP2 you can use
CatalogRelationDto relation = CatalogContext.Current.GetCatalogRelationDto(childId);
if (relation != null && relation.CatalogEntryRelation != null)
{
int parentid = relation.CatalogEntryRelation[0].ParentEntryId
}
in my opinion this will be faster compared to your solution of getting parentId and then geting entry for parent id, cos there is one request to db and db does the joining:
public static Entry GetParent(this Entry entry, CatalogEntryResponseGroup.ResponseGroup responseGroup)
{
var searchOptions = new CatalogSearchOptions {CacheResults = true};
var searchParams =
new CatalogSearchParameters
{
JoinType = "Inner Join",
JoinSourceTable = "CatalogEntry",
JoinTargetQuery =
"(Select ParentEntryId, ChildEntryId, RelationTypeId From CatalogEntryRelation) CatalogEntryRelation",
JoinSourceTableKey = "CatalogEntryId",
JoinTargetTableKey = "CatalogEntryRelation.ParentEntryId",
SqlWhereClause = "CatalogEntryRelation.ChildEntryId=" + entry.CatalogEntryId +
" And CatalogEntryRelation.RelationTypeId=N'" + EntryRelationType.ProductVariation + "'"
};
var catalogEntryResponseGroup = new CatalogEntryResponseGroup(responseGroup);
var result = CatalogContext.Current.FindItems(searchParams, searchOptions, catalogEntryResponseGroup);
if (result.Entry == null || !result.Entry.Any())
{
return null;
}
return result.Entry.First();
}
am i wrong, why?
I have not tested which one would be faster but they would be both be making two database calls as FindItems first gets a group of catalog entry ids and stores those ids in catalogsearchreults with a search set guid. Another call is made to populate the catalogentrydto bases on the ids stored with the catalogsearchresults.
Also just showing there was a new overload to get parententryids for a child entry id as it has been a requested method. Although you will still need to check the RelationType as it brings back all EntryRelationTypes
this is how im geting variation(SKU), there are fields: Entry and ParentEntry, both are always null, nomatter what i change in CatalogEntryResponseGroup.
So if i have Variation what are the ways to get product?