cancel
Showing results for 
Search instead for 
Did you mean: 

How to write in ClassificationClass.classificationAttributes collection?

superpalmi
Explorer
0 Kudos
91

Hi,

I'm putting hands on some custom logic that uses the method de.hybris.platform.catalog.model.classification.ClassificationClassModel#getClassificationAttributes to retrieve the list of classificationAttributeModels assigned to a specific ClassificationClass (Classifying Categories tab in the backoffice), what is the right way to populate this collection? I see that the attribute is writable=false inside catalog-items.xml:

<attribute qualifier="classificationAttributes" type="ClassificationAttributeList">
						<description>list of all attributes available within this class</description>
						<modifiers read="true" write="false" search="false" optional="true"/>
						<persistence type="jalo"/>
					</attribute>

So I was wondering what was the right way to populate this the ClassificationAttributeList collection, the only way I could insert data is using forceWrite=true via impex. Has someone experienced this?

superpalmi_0-1738072314038.png

 

Thank you

 

View Entire Topic
mansurarisoy
Contributor

The attribute classificationAttributes is defined with Jalo persistence, so how it is retrieved can be found in the Jalo class de.hybris.platform.catalog.jalo.classification.ClassificationClass.

In the Jalo class, the getClassificationAttributes() method calls getClassificationAttributeAssignments(), which adds ClassificationAttribute objects from ClassAttributeAssignments to a list and returns it. The getClassificationAttributeAssignments() method, in turn, calls getDeclaredClassificationAttributeAssignments() for the ClassificationClass and its supercategories of type ClassificationClass.

When you check the getDeclaredClassificationAttributeAssignments() method, you'll see the following FlexibleSearch query:

SELECT {PK} FROM FROM {ClassAttributeAssignment} 
WHERE {classificationClass}= ?me 
ORDER BY {position} ASC, {creationtime} ASC

Therefore, you should create ClassAttributeAssignment records for the ClassificationClass and ClassificationAttribute. After doing so, you should see classificationAttributes populated in Backoffice..