Product interface implementations
Magento provides multiple product types, and most of these product types have specialized attributes that are not defined in the ProductInterface
.
Product type | Implements | Has product-specific attributes? |
---|---|---|
* BundleProduct | ProductInterface, PhysicalProductInterface, CustomizableProductInterface | Yes |
* ConfigurableProduct | ProductInterface, PhysicalProductInterface, CustomizableProductInterface | Yes |
* DownloadableProduct | ProductInterface, CustomizableProductInterface | Yes |
* GroupedProduct | ProductInterface, PhysicalProductInterface, CustomizableProductInterface | Yes |
* SimpleProduct | ProductInterface, PhysicalProductInterface, CustomizableProductInterface | No |
* VirtualProduct | ProductInterface, CustomizableProductInterface | No |
Query for product-specific attributes
To return attributes that are specific to a product type, append a structure similar to the following to the end of the Products
output object:
... on <ProductType> {
items{
<ProductType-attribute1>
<ProductType-attribute2>
...
}
}
For example, to return GroupedProduct
attributes, construct your query like this:
{
products(filter:
{sku: {eq: "24-WG085_Group"}}
)
{
items {
id
name
sku
type_id
... on GroupedProduct {
items{
qty
position
product{
sku
name
type_id
url_key
}
}
}
}
}
}