我正在尝试使用WooCommerce REST API V2来获取我们网站销售的每个品牌的URL(永久链接)列表。我正在使用Node.js库,但此问题通常适用于API。现在,我正在使用以下配置。
const config = {
per_page: 10,
page: 1,
status: 'publish',
_fields: 'permalink'
}
最后只是在最终URL中创建查询参数。在Node库中,它是这样传递的。
WooCommerce.get('products', config)
.then(res => {
console.log(res.data)
})
.catch(error => {
console.log(error.response.data)
})
无论如何,我不知道如何通过自定义属性品牌过滤结果。当我们上传产品数据时,此属性称为attribute:pa_brand
。我找不到任何文档说明如何根据此字段过滤结果。