Inhalte aufrufen

Profilbild

Attributes in topic


  • Bitte melden Sie sich an, um eine Antwort zu verfassen.
3 Antworten zu diesem Thema

#1 Yoram

Yoram

    Advanced Member

  • Members
  • PunktPunktPunkt
  • 37 Beiträge

Geschrieben: 04 April 2022 - 15:29

I can't find anything in the documentation about the attributes tab on the topic page. What can you do with that?
 
I was hoping I could put a value in there that I can use in a view. Is that possible?

  • GalenKa und RidgeOi gefällt das

Smartstore: Website | Webshop


#2 Marcus Gesing

Marcus Gesing

    SmartStore AG

  • Administrators
  • 3801 Beiträge

Geschrieben: 04 April 2022 - 20:24

Yes. The attributes are saved as GenericAttributes (with GenericAttribute.KeyGroup = "Topic") and can be loaded via IGenericAttributeService, for example.


  • GalenKa, RidgeOi und Yoram gefällt das

Marcus Gesing

Smartstore AG


#3 Yoram

Yoram

    Advanced Member

  • Members
  • PunktPunktPunkt
  • 37 Beiträge

Geschrieben: 22 April 2022 - 13:18

Thanks for your answer.

I'm a bit struggling to get this working as there is no documentation about this. Can you maybe give an example to show a attribute value in a view?


  • GalenKa gefällt das

Smartstore: Website | Webshop


#4 Marcus Gesing

Marcus Gesing

    SmartStore AG

  • Administrators
  • 3801 Beiträge

Geschrieben: 29 April 2022 - 20:01

@{
	var topicId = 1;
	var genericAttributeService = this.CommonServices.Resolve<SmartStore.Services.Common.IGenericAttributeService>();
	var attributes = genericAttributeService.GetAttributesForEntity(topicId, "Topic");
}

@foreach (var attribute in attributes)
{
	<div>Key: @(attribute.Key). Value: @(attribute.Value).</div>
}

  • GalenKa gefällt das

Marcus Gesing

Smartstore AG