Anchor to collectionRulesConditionscollection
collectionRulesConditions
query
Lists all rules that can be used to create smart collections.
Anchor to Possible returnsPossible returns
- Anchor to CollectionRuleConditionsCollection•
Rule Conditions This object defines all columns and allowed relations that can be used in rules for smart collections to automatically include the matching products.
- allowed
Relations •[Collectionnon-nullRule Relation!]! Allowed relations of the rule.
- default
Relation •Collectionnon-nullRule Relation! Most commonly used relation for this rule.
- rule
Object •CollectionRule Conditions Rule Object Additional attributes defining the rule.
- rule
Type •Collectionnon-nullRule Column! Type of the rule.
- allowed
Was this section helpful?
- Retrieve a list of collection rule conditions
- Retrieve a list of collection rule conditions along with metafield rule objects
Examples
const { admin } = await authenticate.admin(request);
const response = await admin.graphql(
`#graphql
query {
collectionRulesConditions {
ruleType
allowedRelations
defaultRelation
}
}`,
);
const data = await response.json();
query {
collectionRulesConditions {
ruleType
allowedRelations
defaultRelation
}
}
curl -X POST \
https://your-development-store.myshopify.com/admin/api/2024-10/graphql.json \
-H 'Content-Type: application/json' \
-H 'X-Shopify-Access-Token: {access_token}' \
-d '{
"query": "query { collectionRulesConditions { ruleType allowedRelations defaultRelation } }"
}'
const { admin } = await authenticate.admin(request);
const response = await admin.graphql(
`#graphql
query {
collectionRulesConditions {
ruleType
allowedRelations
defaultRelation
}
}`,
);
const data = await response.json();
const client = new shopify.clients.Graphql({session});
const data = await client.query({
data: `query {
collectionRulesConditions {
ruleType
allowedRelations
defaultRelation
}
}`,
});
session = ShopifyAPI::Auth::Session.new(
shop: "your-development-store.myshopify.com",
access_token: access_token
)
client = ShopifyAPI::Clients::Graphql::Admin.new(
session: session
)
query = <<~QUERY
query {
collectionRulesConditions {
ruleType
allowedRelations
defaultRelation
}
}
QUERY
response = client.query(query: query)
Response
JSON{
"collectionRulesConditions": [
{
"ruleType": "TITLE",
"allowedRelations": [
"EQUALS",
"NOT_EQUALS",
"STARTS_WITH",
"ENDS_WITH",
"CONTAINS",
"NOT_CONTAINS"
],
"defaultRelation": "CONTAINS"
},
{
"ruleType": "VARIANT_TITLE",
"allowedRelations": [
"EQUALS",
"NOT_EQUALS",
"STARTS_WITH",
"ENDS_WITH",
"CONTAINS",
"NOT_CONTAINS"
],
"defaultRelation": "CONTAINS"
},
{
"ruleType": "TYPE",
"allowedRelations": [
"EQUALS",
"NOT_EQUALS",
"STARTS_WITH",