Flow Automation: Querying Products in Batches via Action
You can use the Query products in batches action in Flow Automation to retrieve products that match your specified conditions, returning up to 100 products per query. You can then use the results in subsequent workflow actions to automate tasks such as publishing or unpublishing products, managing tags and collections, and updating product information. This helps reduce manual product management.
This article explains when to use the action, how to configure its settings, which triggers to use, how to test your workflow, and provides a practical example.
| Note: The Query products in batches action only retrieves product data. It does not modify product information or publication status. To make changes to products, add the appropriate actions to subsequent workflow steps. |
When to Use the Query Products in Batches Action
You can use the Query products in batches action in the following scenarios:
- Automate product publishing and unpublishing: Schedule workflows to find products that meet specific criteria, such as newly added or archived products, and automatically publish, unpublish, or archive them.
- Manage product tags and collections in bulk: Automatically identify products based on inventory or order changes, then add or remove tags or move products between collections.
- Update SKUs and product information: Automatically retrieve products based on inventory or order events, then create SKUs or update product information using subsequent actions.
Configuring the Query Products in Batches Action
The Query products in batches action lets you define query conditions, sort the results, and specify how many products to return.
| Field | Description | |
| Query conditions |
Specify which products to retrieve. Click + Add condition to add one or more conditions, such as:
|
|
| How to sort query results (Optional) |
Choose how to sort the results:
|
|
| The quantity to keep in the query result (Optional) |
Specify the maximum number of products to return. The action returns the first N products based on the selected sorting order, up to 100 products. For example, select Created Date: Newest to Oldest and enter 10 to retrieve the 10 most recently created products.
|
Supported Triggers
The Query products in batches action is commonly used in workflows started by the following triggers:
- Scheduled trigger
- Product order placed successfully
- Product inventory changed
- Inventory level updated
- Fulfillment request accepted
| Note: For instructions on configuring these triggers, refer to the relevant trigger guides, such as "Flow Automation: Triggering Workflows When Product Inventory Changes." |
Testing the Workflow
To verify that your workflow successfully queries the expected products, follow these steps using the Product inventory changed trigger as an example:
- In Flow Automation, create a workflow using the Product inventory changed trigger and the Query products in batches action. Configure query conditions that you can verify in your test store, then click Publish.
-
From your SHOPLINE Admin, go to Products and click Create product to create a test product. Use a recognizable product title so you can easily find it later.
-
Once the product is created, return to the Products list and click the test product to open its details page. Update its inventory quantity and save your changes to trigger the workflow.
Note: For details on managing product inventory, see "Updating Inventory for Existing Products." -
Return to Flow Automation and check the workflow's run history. Verify that the Query products in batches step returns products that match your specified query conditions, sorting order, and quantity.
Note: For more information on how to monitor the execution of your workflows, refer to the "How to View the Running of a Flow" section in the "Introduction to Flow Automation" guide.
Example Use Case
The following example shows how to use the Query products in batches action to identify and tag low-stock products.
Scenario: When a product's inventory drops to 5 units or fewer, automatically add a "Low Stock Alert" tag so your operations team can quickly identify products that need restocking.
- Trigger: Product inventory changed
-
Action: Query products in batches
- Query conditions: Product ID equals [Product ID]
- The quantity to keep in the query result: 10
- Condition: Inventory quantity is less than or equal to 5
- Action: Add product tags "Low Stock Alert"
- Result: When a product's inventory reaches the specified threshold, the workflow automatically adds the "Low Stock Alert" tag. Your operations team can then filter products by this tag in the SHOPLINE Admin to identify items that need restocking.
| Tip: To insert dynamic values such as [Product ID], click + Add variable and select the corresponding parameter. |