This guide will walk you through the feed rules and introduce advanced comparison operators available for building powerful feed rules. These operators provide greater flexibility and control when filtering and modifying product data.
Introduction to Feed Rules
Feed rules in GoDataFeed act like SQL queries, allowing you to manipulate and optimize your product data before sending it to various shopping channels and marketplaces. Each rule consists of three key components:
- SET field: Defines the new value or transformation to be applied to the target field.
- TO field: Specifies the target field in your feed that you want to modify or populate.
- WHERE condition: Establishes the criteria for which products the rule should be applied to. This is where comparison operators come into play.
Understanding Comparison Operators
Comparison operators are essential for constructing WHERE conditions in feed rules. They allow you to compare values in your feed data and determine which products meet specific criteria. GoDataFeed offers a variety of comparison operators, including:
- Equals (=): Checks if two values are identical.
- Not Equals (<>): Checks if two values are different.
- Greater Than (>): Checks if the left value is greater than the right value.
- Less Than (<): Checks if the left value is less than the right value.
- Greater Than or Equal To (>=): Checks if the left value is greater than or equal to the right value.
- Less Than or Equal To (<=): Checks if the left value is less than or equal to the right value.
Static Text vs. Variables
In GoDataFeed, WHERE conditions can utilize both static text and variables for comparisons.
-
Static Text: This refers to fixed values like numbers (e.g., 100) or text (e.g., "instock").
-
Variables: These are dynamic values represented as
[P].[Name]
, where "P" signifies "Product" and "Name" refers to the specific field in your product data (e.g.,[P].[Price]
or[P].[ImageURL]
).
Using variables allows you to create more flexible and dynamic rules that adapt to the specific values of each product.
Advanced Comparison Operators
The following table summarizes the new comparison operators and their functions:
Operator Name | Description | Example (with variable) |
---|---|---|
Image Width Less Than | Image Width Less Than (pixels) | [P].[ImageURL] Image Width Less Than 300 |
Image Width Greater Than | Image Width Greater Than (pixels) | [P].[ImageURL] Image Width Greater Than 1000 |
Image Width Equal To | Image Width Equal To (pixels) | [P].[ImageURL] Image Width Equal To 800 |
Image Height Less Than | Image Height Less Than (pixels) | [P].[ImageURL] Image Height Less Than 300 |
Image Height Greater Than | Image Height Greater Than (pixels) | [P].[ImageURL] Image Height Greater Than 1000 |
Image Height Equal To | Image Height Equal To (pixels) | [P].[ImageURL] Image Height Equal To 800 |
File Size Less Than | File Size Less Than (bytes) | [P].[ImageURL] File Size Less Than 1048576 |
File Size Greater Than | File Size Greater Than (bytes) | [P].[ImageURL] File Size Greater Than 5242880 |
File Size Equal To | File Size Equal To (bytes) | [P].[ImageURL] File Size Equal To 2097152 |
HTTP Status Code Equals | HTTP Status Code Equal To | [P].[ProductURL] HTTP Status Code Equals 200 |
HTTP Status Code Not Equals | HTTP Status Code Not Equal To | [P].[ProductURL] HTTP Status Code Not Equal To 404 |
Is Like In List | Checks if a value matches any word in a list | [P].[Description] Is Like In List Red,Green,Blue |
Is Not Like In List | Checks if a value does not match any word in a list | [P].[Description] Is Not Like In List Red,Green,Blue |
Matches Regex | Checks if a value matches a regular expression pattern | [P].[SKU] Matches Regex ^[A-Z]{3}\d{4N}$ |
Is Alpha | Checks if a value consists only of alphabetic characters | [P].[Title] Is Alpha |
Is Not Alpha | Checks if a value contains any non-alphabetic characters | [P].[SKU] Is Not Alpha |
Contains Alpha | Checks if a value contains at least one alphabetic character | [P].[Title] Contains Alpha |
Does Not Contain Alpha | Checks if a value contains no alphabetic characters | [P].[Title] Does Not Contain Alpha |
Is Numeric | Checks if a value consists only of numeric characters | [P].[Price] Is Numeric |
Is Not Numeric | Checks if a value contains any non-numeric characters | [P].[Price] Is Not Numeric |
Contains Numeric | Checks if a value contains at least one numeric character | [P].[Title] Contains Numeric |
Does Not Contain Numeric | Checks if a value contains no numeric characters | [P].[Title] Does Not Contain Numeric |
Is AlphaNumeric | Checks if a value consists only of alphanumeric characters | [P].[Code] Is AlphaNumeric |
Is Not AlphaNumeric | Checks if a value contains any non-alphanumeric characters |
[P].[Code] Is Not AlphaNumeric |
Image Dimension Comparisons
The new Image Width Less Than and Image Height Less Than operators allow you to create rules based on specific image width and height requirements. This is particularly useful for:
-
Ensuring image quality: Target products with small images and replace them with higher resolution versions.
-
Meeting marketplace image guidelines: Filter out products that don't meet specific image dimension requirements of certain channels.
-
Optimizing image sizes: Identify images that are unnecessarily large and resize them for faster loading times.
File Size Comparisons
The File Size Less Than, File Size Greater Than, and File Size Equal To operators enable you to create rules based on file sizes. This can be helpful for:
-
Managing storage space: Identify and remove products with excessively large files.
-
Improving download speeds: Target products with large files and compress them for better user experience.
-
Meeting file size limits: Filter out products that exceed file size restrictions on certain platforms.
HTTP Status Code Comparisons
The HTTP Status Code Equals and HTTP Status Code Not Equal To operators provide the ability to create rules based on HTTP status codes returned when accessing product URLs. This is useful for:
-
Identifying broken links: Target products with 404 status codes and update their URLs or remove them from your feed.
-
Monitoring website availability: Track product URLs returning 500-level errors and investigate potential server issues.
-
Improving data quality: Ensure product URLs are accessible and functioning correctly.
Is Like In List Rules
Operator: Is Like In List
Description: Checks if a value matches any word in a list.
Example: [P].[Description] Is Like In List Red,Green,Blue
Note: If the description attribute contains "Red," "Green," or "Blue," the rule will be applied.
Operator: Is Not Like In List
Description: Checks if a value does not match any word in a list.
Example: [P].[Description] Is Not Like In List Red,Green,Blue
Warning: If the description attribute does not contain "Red," "Green," or "Blue," the rule will be applied.
These rules are beneficial for filtering products based on keywords in attributes like product descriptions or categories:
-
Targeting Specific Products: Identify products with certain keywords (e.g., colors like "Red," "Green," or "Blue").
-
Excluding Irrelevant Items: Exclude products without specific keywords, improving targeting for marketing campaigns.
Example of Use Cases
Filtering Products by Color[P].[Description] Is Like In List "Red", "Green", "Blue"
Excluding Non-Eco-Friendly Products[P].[Description] Is Not Like In List "Plastic", "Synthetic"
Regex Rules
Operator: Matches Regex
Description: Checks if a value matches a regular expression pattern.
Example: [P].[SKU] Matches Regex ^[A-Z]{3}\\d{4}$
Note: If the SKU matches the pattern of three letters followed by four digits, the rule will be applied.
Regex-based rules provide powerful flexibility for enforcing specific formats:
-
SKU Format Validation: Ensure product SKUs follow a specific pattern (e.g., "ELE1234").
-
Data Integrity: Use regular expressions to validate structured data (e.g., phone numbers, postal codes).
Example of Use Cases
SKU Format Validation for Electronics[P].[SKU] Matches Regex ^[A-Z]{3}\\d{4}$
Validate ISBN for Books[P].[ISBN] Matches Regex ^\d{13}$
Alphanumeric Rules
Operator: Is Alpha
Description: Checks if a value consists only of alphabetic characters.
Example: [P].[Title] Is Alpha
Note: If the Title consists only of letters, the rule will be applied.
Operator: Is Not Alpha
Description: Checks if a value contains any non-alphabetic characters.
Example: [P].[SKU] Is Not Alpha
Warning: If the SKU contains any non-letter characters, the rule will be applied.
Alphanumeric checks are crucial in maintaining data consistency, especially for fields like product titles, SKUs, and pricing:
-
Validation of Product Titles and Codes: Ensure proper formatting for fields like product titles or SKUs.
-
Detect Anomalies: Identify products with incorrectly formatted data.
-
Search and Filter Efficiency: Consistent formatting allows easy search and filtering for specific product attributes.
Example of Use Cases
Validating Product Title for Alphabetic Characters[P].[Title] Is Alpha
Validating Product Code for Alphanumeric Format[P].[Code] Is AlphaNumeric
Additional Tips
-
Combine multiple conditions: Use AND/OR operators to create more complex WHERE clauses.
-
Use parentheses for clarity: Group conditions within parentheses to define the order of evaluation.
-
Test your rules: Always test your rules before applying them to your entire feed to ensure they work as intended. You can use the rule preview, or feed preview feature to do so.
-
Explore other operators: GoDataFeed offers a variety of other comparison and logical operators to further refine your feed rules.
Related to
Comments
0 comments
Please sign in to leave a comment.