Any ideas how to make sure the item in the cart / quote was affected by CATALOG price rule (not shopping cart rule)? There is a similar question without an answer: Do not apply catalog price rules on a product already on sale

2 Answers 2


Product to catalog price rules data is stored in the table catalogrule_product In that table you will find the product_id field that relates back to your product.

You should be able to build a query that checks the table for the product in question.

Not 100% what your intended functionality would involve, but doing a separate query for each product to check if they have an ACTIVE rule applying to them would slow your cart display down a fair bit. It would thus be better to make one query with all the products IDS you are interested in, and then use the resulting collection data to work your magic.

In case it helps you get a query built, I include below some code that I use in my Dynamic Category Products Extension which finds all products with an active rule. You should be able to adjust this and limit it to your products ids alone. It also takes the date range of the rule into consideration. Remember to consider that rules can be of two possible types: BY_PERCENT or FIXED Some bits are out of context, but you should get the jest of it.

$category below is the current active category. $value is simply the value of the discount I am interested in. $operator is self explanatory ;)

$collection = $category->getProductCollection();
$value = $this->getValueParsed();
$operator = $this->_operatorMapToSql[$this->getOperator()]; 
$conditions = " (price_rule.product_id = e.entity_id) ";
if (strpos($value, '%') > 0) {
            $value = str_replace('%', '', $value);
            $conditions .= " AND action_operator = '" . Mage_SalesRule_Model_Rule::BY_PERCENT_ACTION . "' ";
        } else {
            $conditions .= " AND action_operator = '" . Mage_SalesRule_Model_Rule::BY_FIXED_ACTION . "' ";
        $storeDate = Mage::app()->getLocale()->storeTimeStamp($this->getStoreId());
        $conditions .= " AND (from_time = 0
                    OR from_time <= " . $storeDate . ")
                    AND (to_time = 0
                    OR to_time >= " . $storeDate . ") ";
        $conditions .= " AND action_amount " . $operator . " " . $value;
            array('price_rule' => $collection->getTable('catalogrule/rule_product')), $conditions

I hope this get you closer to your solution


I think database can be a help here:

In the table sales_flat_quote_item you have the column applied_rule_ids. Here you can get the rules being applied.

Also I checked and found here is a discussion on something like this. Try this LINK

  • 1
    Thanks, but seems the applied_rule_ids are for shopping_cart_rules only. Correct me if I'm wrong.
    – Amasty
    Jul 29, 2014 at 12:43

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.