Check if product has catalog price rule

If you don't have many rules or many products you can try this:

$website = Mage::app()->getWebsite();
$product = $this->getProduct();
$rules = Mage::getModel('catalogrule/rule')->getCollection()
    ->addWebsiteFilter($website) //filter rules for current site
    ->addIsActiveFilter(1); //filter active rules

foreach ($rules as $rule) {
    $affectedProductIds = $rule->getMatchingProductIds();
    if (in_array($product->getId(), $affectedProductIds)) {
        //product has a price rule set for it
    }
}

The quick and dirty idea would be to search for a record in the table catalogrule_product.
All products that are affected by catalog rules are referenced in that table.

$resource = Mage::getSingleton('core/resource');
$connection = $resource->getConnection('core_read');
$tableName = $resource->getTableName('catalogrule_product');
$count = $connection->fetchOne('SELECT COUNT(1) as c FROM '.$tableName.' WHERE product_id = '. $product->getId());

if ($count == 1) { 
    //you have a rule for the product
}

But this is not the best practice.


Old question, but for others looking, this seems to be an efficient method:

$product = $this->getProduct();
Mage::getModel('catalogrule/rule')->loadProductRules($product);
var_dump($product->getMatchedRules());

See Mage_CatalogRule_Model_Rule for reference.