Inhalte aufrufen

Profilbild

Web API: Reading product specification attributes

mwst Web API OData

Best Answer Marcus Gesing , 29 September 2023 - 19:05

You can use OData $expand to include navigation properties 

$expand=SpecificationAttributeOption($expand=SpecificationAttribute)
Go to the full post


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

#1 ertank

ertank

    Member

  • Members
  • PunktPunkt
  • 10 Beiträge

Geschrieben: 27 September 2023 - 14:01

Hello,

 

I am using Smartstore V5 web api and I would like to read a single product specification attributes. I know product id information for filtering.

 

I failed to find an example for that. Is it possible to do using web api?

 

Thanks & Regards,

Ertan



#2 Marcus Gesing

Marcus Gesing

    SmartStore AG

  • Administrators
  • 3831 Beiträge

Geschrieben: 28 September 2023 - 20:51

/odata/v1/ProductSpecificationAttributes?$filter=ProductId eq your_product_id
or
/odata/v1/Products(your_product_id)/ProductSpecificationAttributes

  • ertank gefällt das

Marcus Gesing

Smartstore AG


#3 ertank

ertank

    Member

  • Members
  • PunktPunkt
  • 10 Beiträge

Geschrieben: 29 September 2023 - 14:44

/odata/v1/ProductSpecificationAttributes?$filter=ProductId eq your_product_id

 

Hi,

 

Thanks for your reply.

 

Above web api returns json which does not have all columns that I can see in Smartstore web page. I cannot post pictures for better understanding but it basically does not include "Attribute" and "Attribute option" columns.

 

What I receive is below

{                                                                                               
  "@odata.context": "http://www.some_site.com/odata/v1/$metadata#ProductSpecificationAttributes",
  "value": [                                                                                    
    {                                                                                           
      "SpecificationAttributeOptionId": 152,                                                    
      "ProductId": 140542,                                                                      
      "AllowFiltering": null,                                                                   
      "ShowOnProductPage": null,                                                                
      "DisplayOrder": 0,                                                                                    
      "Id": 48875                                                                               
    },                                                                                          
    {                                                                                           
      "SpecificationAttributeOptionId": 904,                                                    
      "ProductId": 140542,                                                                      
      "AllowFiltering": null,                                                                   
      "ShowOnProductPage": null,                                                                
      "DisplayOrder": 0,                                                                        
      "Id": 48876                                                                               
    },                                                                                          
    {                                                                                           
      "SpecificationAttributeOptionId": 337,                                                    
      "ProductId": 140542,                                                                      
      "AllowFiltering": null,                                                                   
      "ShowOnProductPage": null,                                                                
      "DisplayOrder": 0,                                                                        
      "Id": 48877                                                                               
    }                                                                                           
  ]                                                                                             
}                                                                                               

Is it possible to receive a json so it include above two columns? Or, is there a way that I can read them using another web api?

 

Thanks & Regards,

Ertan



#4 Marcus Gesing

Marcus Gesing

    SmartStore AG

  • Administrators
  • 3831 Beiträge

Geschrieben: 29 September 2023 - 19:05   Best Answer

You can use OData $expand to include navigation properties 

$expand=SpecificationAttributeOption($expand=SpecificationAttribute)

Marcus Gesing

Smartstore AG


#5 ertank

ertank

    Member

  • Members
  • PunktPunkt
  • 10 Beiträge

Geschrieben: 29 September 2023 - 21:27

This gave me the data I need in one single request.

Thank you.




Auch markiert mit einem oder mehrerer dieser Schlüsselwörter: mwst, Web API, OData