Steps to resolve this issue is:
- Find the assets which are missing this translation link among assets. In order to do that, compare the <AssetType>_DimP tables between source and destination instances after running the following query using Support Tools or using some utility element:
Select CS_OWNERID, CS_DIMENSIONPARENTID from <AssetType>_DimP where CS_OWNERID!=CS_DIMENSIONPARENTID - Important columns are CS_OWNERID (translated assetid) and CS_DIMENSIONPARENTID (master assetid)
- List down the assets which are not present on your destination instance by comparing. I prefer the following final format to update dimension relationship for multiple assets of a particular assettype: <TranslatedId1>,<MasterId1>;<TranslatedId2>,<MasterId2>...
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<% | |
String ids = "[Your missing translations string]"; | |
//FORMAT: <TranslatedAssetId1>,<MasterAssetId1>;<TranslatedAsset2>,<MasterAssetId2>;... | |
String cpArray [] = StringUtils.split(ids, ";"); | |
for(int i=0; i<cpArray.length; i++){ | |
String cp = cpArray[i]; | |
String masterpageid = StringUtils.split(cp, ",")[1]; | |
String childpageid = StringUtils.split(cp, ",")[0]; | |
if(Utilities.goodString(masterpageid) && Utilities.goodString(childpageid) && Utilities.goodString(ics.GetVar("assetType"))) { | |
%> | |
<asset:load name="translatedAsset" type='<%= ics.GetVar("assetType")%>' objectid="<%=childpageid %>" editable="true"/> | |
<asset:setdimparents name="translatedAsset"> | |
<asset:dimensionparentrelationship group="Locale" type='<%= ics.GetVar("assetType")%>' assetid="<%=masterpageid %>"/> | |
</asset:setdimparents> | |
<asset:save name="translatedAsset"/> | |
<% | |
if(ics.GetErrno==0){ | |
//print success | |
} else { | |
//print error | |
} | |
} | |
%><hr><% | |
}%> |
Hit the url: [hostname]:[port]/[sites context]/ContentServer?pagename=[Sitename where template was created]/[YourTemplateName]&assetType=[AssetType]
for e.g. http://localhost:9080/cs/ContentServer?pagename=FirstSiteII/ResolveMissingTranslations&assetType=Product_C
and wait for the output.
Sometimes, even after running the above code may not update all assets because there can be 2 translated assets supposed to be associated to same master asset and <asset:save> tag will not able to save the asset for both in same request. So, just run the utility again for the failed ones and that should resolve the issue. Compare again by running the same above query and the result should be same. Check in contributor UI to cross-check if dimension relationship was generated or not.
NOTE: You have to run this utility for all the affected assets of different assets types separately.
Disclaimer: Any sample code on this blog is not officially recommended, use at your own risk.
No comments:
Post a Comment