Question

How can I get Catalog Price Rule programmatically in the front-end by Rule Name? I need the Discount Amount of a particular price rule.

Was it helpful?

Solution

I have found a way to make it but not by name and by id:

$rule = Mage::getModel('catalogrule/rule')->load(1); 
$rule->setWebsiteIds("1"); 
echo $rule->getDiscountAmount();

and for price rule for shopping cart use

$rule = Mage::getModel('salesrule/rule')->load(1); 
$rule->setWebsiteIds("1"); 
echo $rule->getDiscountAmount();

OTHER TIPS

Well, if you go by

$rule = Mage::getModel('catalogrule/rule')->load(1); 
$rule->setWebsiteIds("1");     

Then you can do

echo $rule->name;
echo $rule->description;

the above will give you the rules' name and description fields.

To get the rule name:

$load_rule = Mage::getModel('salesrule/rule')->load($order->getAppliedRuleIds());
$rule_name = $load_rule->getName();
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top