Skip to content

Magento Enterprise Solutions: Troubleshooting Rule Based Product Relations (aka Target Rules)

By GRAYBOX Alumni

Target rules are a killer feature of the Magento Enterprise Solutions platform, but as with many of the great components in the Magento ecosystem, the documentation is a bit lacking in practical examples and the thorough details necessary to get the results you may be looking for.

Here are some quick resources:

Tip #1 - If you have multiple rules,Isolate the problematic rule

If you are getting results that you are not expecting, first turn off all the rules that apply to this product.

"But how do I know which rules apply to a given product?"

  1. Identify a product you are troubleshooting. Note the Product ID.
  2. First, in the admin panel, open the product and save it - don't worry about editing anything yet.
    By saving the product, you initiate the re-indexing of the target rules.
  3. Second, run a quick query to retrieve the rules that apply to this product.

    SELECT * FROM Enterprise Solutions_targetrule, Enterprise Solutions_targetrule_product WHERE Enterprise Solutions_targetrule.rule_id = Enterprise Solutions_targetrule_product.rule_id AND ### replace with your product_id Enterprise Solutions_targetrule_product.product_id = 6731 AND ### 1=related, 2=up-sells, 3=cross-sells Enterprise Solutions_targetrule.apply_to = 2 ORDER BY Enterprise Solutions_targetrule.sort_order; 
    Now you have a list of all the rules that will apply to this product. Turn them off one at a time:
    UPDATE Enterprise Solutions_targetrule SET ### 0 to de-activate, 1 to activate is_active = 0 WHERE ### enter the rule_id from each of the rules from the results above rule_id = 169; 
  4. You now should have all rules turned off for a given product, for a given rule type (related, up-sell, cross-sell).
  5. Turn the first rule on, open and save the product in the admin panel, and check the results.
  6. Now you can either turn that rule off and try the next (to get the discreet results from each rule) or turn on the next one (and see the progressive combination of the rules together).

Tip #2 - "is one of" versus "contains"

Custom product relations can leverage custom product attributes, but don't mix your datatypes! The target rule interface is powerful, and, in many cases, will allow you to break the rules if you want.

For example, we have an attribute "Designer" with a pre-defined list of options to select from. But if I use this attribute for a target rule, it defaults to the operator "contains" and allows me to select an option from this list. THIS WILL NOT WORK! "Contains" is only to be used for text attributes you can enter custom strings into.The proper method is to use "is one of..." and select the option from the list.

Screenshot 120

Tip #3 - Matching by Category can get you into trouble

We have an installation that uses target rules to create up-sell products based on the category of matched products, but all products in the catalog are part of one "All Products" category.

  1. Our selected product was in category 36 and the "all category".
  2. Our desired target was in category 36, category 211 and the "all category".
  3. A product which was showing as a match was part of category 502 and the "all category".

Here is what the config looked like:

Screenshot 121
Screenshot 122

How this reads in English:

"Take all products in category 36 and make a list of ALL categories each of those products are in (this will include the "all category"). Now find all products which are in any of these categories".

This simple target rule now has matched EVERY SINGLE PRODUCT IN THE STORE - and caused me a lot of confusion. How did we solve it?

Because we were matching based on a specific category, we could also set the "products to display" to the same selected category and not fall in the pit of over-matching the target rules.

Blog & Events

Featured Work