通过PUT请求更新商品并添加排除客户组的问题求助
I’ve run into similar head-scratching issues with Shopware’s excluded customer group associations before, so let’s break down the most common fixes and checkpoints to get this working:
Double-check your field naming and request structure
Shopware’s API is particular about exact field names depending on your version. Chances are you’re usingcustomerGroupswhen you should be targetingexcludedCustomerGroupsdirectly for this specific exclusion logic. Here’s a working example of a PATCH request body for Shopware 6.x:{ "excludedCustomerGroups": [ { "id": "your-customer-group-uuid", "type": "customer_group" } ] }Make sure you’re using the UUID of the customer group, not its display name or technical identifier—this is a super common gotcha.
Verify your HTTP method and endpoint
If you’re using a PUT request, you’ll need to include the full product object (all existing associations and fields) to avoid overwriting or dropping data accidentally. PATCH is far safer for partial updates like adding excluded groups—stick to the endpoint:PATCH /api/product/{product-id}.Check your API user permissions
Don’t overlook permission issues! Your API user needs these enabled to make the association stick:product:update(to modify the product)customer_group:read(to fetch valid group IDs and link them)
Without these, the API might return a 200 OK but silently skip applying the excluded group.
Dig into the response for hidden errors
Even if you get a success status code, check the full response body for warning messages or partial failures. Sometimes the API accepts the request but rejects the association because of invalid data (like a non-existent group ID or malformed object structure).Account for Shopware version quirks
For versions before 6.4, you might need to use theassociationsparameter to explicitly declare the excluded groups. Here’s how that would look:{ "associations": { "excludedCustomerGroups": { "ids": ["your-customer-group-uuid"] } } }
If none of these resolve the issue, sharing your exact redacted request body and Shopware version would help narrow down the problem further!
内容的提问来源于stack exchange,提问作者sHamann

