我创建了一个自定义属性" customer_number"在客户中。 我想使用此自定义属性进行过滤
$userData = array("username" => "abc", "password" => "123");
$ch = curl_init("http://example.com/api/index.php/rest/V1/integration/admin/token");
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "POST");
curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode($userData));
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_HTTPHEADER, array("Content-Type: application/json", "Content-Lenght: " . strlen(json_encode($userData))));
$token = curl_exec($ch);
$ch = curl_init("http://example.com/api/index.php/rest/V1/customers/search?searchCriteria[sortOrders][0][field]=email&searchCriteria[sortOrders][0][direction]=asc&searchCriteria[filter_groups][0][filters][0][field]=customer_number&searchCriteria[filter_groups][0][filters][0][value]=1234567890");
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "GET");
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_HTTPHEADER, array("Content-Type: application/json", "Authorization: Bearer " . json_decode($token)));
$result = curl_exec($ch);
没有结果......
更新我使用的Customer_number
$custom_attribute[] = array('attribute_code'=>'customer_number','value'=>'6666666666');
$customerData = [
'customer' => [
"id" => 2,
"email" => "xxx@gmail.com",
"firstname" => "Umar",
"lastname" => "Rafsan",
"storeId" => 1,
"websiteId" => 1,
"custom_attributes" => $custom_attribute
]
];
//Get customer info
$ch = curl_init("http://example.com/api/rest/V1/customers/me");
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "PUT"); // Get method
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode($customerData));
curl_setopt($ch, CURLOPT_HTTPHEADER, array("Content-Type: application/json", "Authorization: Bearer " . json_decode($token)));
$result = curl_exec($ch);