---
title: "get_metafields"

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

# get_metafields


    获取某个资源对应的元字段对象。

    适用于跟以下对象结合使用：
- [product](https://developer.shopline.com/zh-hans-cn/docs/sline/object/product.md)
- [collection](https://developer.shopline.com/zh-hans-cn/docs/sline/object/collection.md)
- [blog](https://developer.shopline.com/zh-hans-cn/docs/sline/object/blog.md)
- [article](https://developer.shopline.com/zh-hans-cn/docs/sline/object/article.md)
- [page](https://developer.shopline.com/zh-hans-cn/docs/sline/object/page.md)
- [order](https://developer.shopline.com/zh-hans-cn/docs/sline/object/order.md)
- [customer](https://developer.shopline.com/zh-hans-cn/docs/sline/object/customer.md)
- [variant](https://developer.shopline.com/zh-hans-cn/docs/sline/object/variant.md)
- [shop](https://developer.shopline.com/zh-hans-cn/docs/sline/object/shop.md)
- [company](https://developer.shopline.com/zh-hans-cn/docs/sline/object/company.md)

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





    
`obj | get_metafields(namespace)` 返回一个 [`metafields`](https://developer.shopline.com/zh-hans-cn/docs/sline/object/metafields.md) 对象。
    



    
## 必选参数

        
            - `obj` `any`：指定的资源对象。有效值包括以上列出的对象。
        
            - `namespace` `string`：元字段的命名空间。
        
    





    
## 例子

        
            

            


            

            
<SlineExample path={'/products/vip3'} objects={ 
    [""] 
}>
```sline
{{#var mf = product | get_metafields("demo_ns") /}}
{{ mf.demo_key.value }}
```
</SlineExample>
            
        
    
