我试图用REST API php库(比如$ woocommerce-> get('products',array())通过属性的特定值获取我的所有产品,但我无法实现它 . 我不知道我知道如何设置参数 .
(我正在使用这个库https://packagist.org/packages/automattic/woocommerce)
有人能给我一个线索吗?
非常感谢 .
更详细
我想我已经阅读了所有相关的出版物 . 在那些出版物中,它们不使用相同的PHP库(它们仅使用REST API),并且没有按属性过滤的示例(在我的情况下,该属性是专门为该产品创建的) . 当我按类别过滤时我没有问题 . 我发现属性的问题 . 例如:
$ args = array (
'per_page' => "100",
'page' => "1",
// 'category' => '120' This works well
'attribute' => 'source',
'attribute_term' => 'mine',
);
$ woocommerce_client-> get ('products', $ args);
如果我按类别使用过滤(id = 120),它对我来说是正常的 . 但是我已经为“属性”和“attribute_term”尝试了一千个选项而没有过滤 .
就我而言,我有一个具有此特定属性的产品:
public 'attributes' =>
array (size = 1)
0 =>
object (stdClass) [11]
public 'id' => int 0
public 'name' => string 'source' (length = 6)
public 'position' => int 0
public 'visible' => boolean false
public 'variation' => boolean false
public 'options' =>
array (size = 1)
0 => string 'mine' (length = 3)
我无法过滤它 .