Dimension values can be accessed from any Oracle Commerce record returned from a record query (R parameter).
If dimensions have been configured as in the previous section, they can
also be accessed from records returned from a navigation query
(N
parameter).
To access a dimension value directly on an
ERec
object, use:
These return an
AssocDimLocationsList
object that contains all the
values in a record for a particular dimension.
The following code snippets show how to retrieve the dimension values from a list of records.
Example 7. Java example
ERecList recs = eneResults.getERecs(); // Loop over record list to get the dimension values for (int i=0; i < recs.size(); i++) { ERec rec = (ERec)recs.get(i); // Get list of tagged dimension location groups for record AssocDimLocationsList dims = (AssocDimLocationsList)rec.getDimValues(); for (int j=0; j < dims.size(); j++) { // Get individual dimension and loop over its values AssocDimLocations dim = (AssocDimLocations)dims.get(j); for (int k=0; k < dim.size(); k++) { // Get attributes from a specific dim val DimLocation dimLoc = (DimLocation)dim.get(k); DimVal dval = dimLoc.getDimValue(); String dimensionName = dval.getDimensionName(); long dimensionId = dval.getDimensionId(); String dimValName = dval.getName(); long dimValId = dval.getId(); // Enter code to display the dimension name and // dimension value name. The Dimension ID and // dimension value ID may be needed for URLs. } } }
Example 8. .NET example
ERecList recs = eneResults.ERecs; for (int i=0; i < recs.Count; i++) { ERec rec = (ERec)recs[i]; // Get list of tagged dimension location groups for record AssocDimLocationsList dims = rec.DimValues; // Loop through dimensions for (int j=0; j < dims.Count; j++) { // Get individual dimension AssocDimLocations dim = (AssocDimLocations) dims[j]; // Loop through each dim val in the dimension group for (int k=0; k < dim.Count; k++) { // Get specific dimension value and path DimLocation dimLoc = (DimLocation) dim[k]; // Get dimension value DimVal dval = dimLoc.DimValue; String dimensionName = dval.DimensionName; Long dimensionId = dval.DimensionId; String dimValName = dval.Name; Long dimValId = dval.Id; // Enter code to display the dimension name and // dimension value name. The Dimension ID and // dimension value ID may be needed for URLs. } } }