Magento – Magento Get Shopping Cart and Catalog Price Rules

cartcatalogcatalog-price-rulesprice-rulesshopping-cart-price-rules

I am trying to get all my Price Rules/Promotions so that I can loop through them and take their descriptions.

I Can't seem to get Shopping-Cart Rules and Catalog Rules in one request

IS it even possible?????

$catalogrules = Mage::getModel('catalogrule/rule')->load
        ->addFieldToFilter('is_active', 1)
        ->addAttributeToFilter('description', 'notnull');
$cartrules = Mage::getModel('salesrule/rule_collection')->load
        ->addFieldToFilter('is_active', 1)
        ->addAttributeToFilter('description', 'notnull');

Best Answer

Try this way:

$catalogrules = Mage::getModel('catalogrule/rule')->getCollection()
        ->addFieldToFilter('is_active', 1)
        ->addAttributeToFilter('description', 'notnull');

$cartrules = Mage::getModel('salesrule/rule')->getCollection()
        ->addFieldToFilter('is_active', 1)
        ->addAttributeToFilter('description', 'notnull');

they will be loaded automatically when you loop them through foreach

Related Topic