---
title: "get_variants"

doc_type: static
doc_category: static
doc_version: v20270301
source_url:
  html: 'https://developer.shopline.com/zh-hans-cn/docs/sline/filter/get-variants'
  md: 'https://developer.shopline.com/zh-hans-cn/docs/sline/filter/get-variants.md'
---

# get_variants


    获取给定商品下的所有款式对象。

    适用于跟以下对象结合使用：

[product](https://developer.shopline.com/zh-hans-cn/docs/sline/object/product.md)

> **注意**
>
> 为确保商店的性能和响应速度，在渲染一个页面的过程中，该过滤器的调用次数上限是 50 次。如果多次调用的传入参数一致，则这些调用在计数时会被视为一次。调用次数达到上限后，后续调用将会返回 `nil`。



    
`product | get_variants()` 返回一个 [`variant`](https://developer.shopline.com/zh-hans-cn/docs/sline/object/variant.md) 对象数组。
    



    
## 必选参数

        
             `product` [`product`](https://developer.shopline.com/zh-hans-cn/docs/sline/object/product.md)：给定的 `product` 对象。
        
    





    
## 例子

        
            

            


            

            
<SlineExample path={'/products/-a001-striped-off-shoulder---crop-top-collection-2023'} objects={ 
    [""] 
}>
```sline
{{#var myVariants = product | get_variants() /}}
{{#for variant in myVariants}}
  {{ variant.title }}
{{/for}}
```
</SlineExample>
            
        
    
