magento get Catalog Price Rule or Discount Amount programmatically in the front-end by Rule Name
How can I get 开发者_如何学PythonCatalog Price Rule programmatically in the front-end by Rule Name? I need the Discount Amount of a particular price rule.
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();
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();
精彩评论