Get Catalog Rule by product ID in Magento

Get Catalog Rule by product ID in Magento:

$product = Mage::getModel(‘catalog/product’)->load($productId);
$storeId = $_product->getStoreId();
$websiteId = Mage::app()->getStore($storeId)->getWebsiteId();
$timeStamp = Mage::app()->getLocale()->storeTimeStamp($storeId);
$customerGroupId = $user->getGroupId();

$resource = Mage::getResourceModel(‘catalogrule/rule’);
$rules = $resource->getRulesFromProduct($timeStamp, $websiteId, $customerGroupId, $productId);
foreach($rules as $ruleval){
echo $catalogRuleID = $ruleval[‘rule_id’]; //If more than one rule

         if($catalogRuleID){
$catalogRulObj = Mage::getModel(‘catalogrule/rule’)->load($catalogRuleID);
print_r($catalogRulObj->getData());
$conditions_serialized = unserialize($catalogRulObj->getConditionsSerialized());
$actions_serialized = unserialize($catalogRulObj->getActionsSerialized());
print_r($conditions_serialized);
}

}

 

————————————————————————————————————————————————————————————-

Corner of Blog:

“Welcome Digital INDIA !!! “

———————————————————————————————————————————————————————————————-