0

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');

1 Answer 1

3

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

3
  • Thank You, but how would i loop through both of them at the same time?
    – Newbee
    Oct 29, 2014 at 15:30
  • Would something like this be smart? $collection1 = Mage::getModel('catalog/category')->load(148)->getProductCollection(); $collection2 = Mage::getModel('catalog/category')->load(149)->getProductCollection(); //load an empty collection (filter-less collections will auto-lazy-load everything) $merged = Mage::getModel('catalog/product')->getCollection()->addFieldToFilter('entity_id',-1); //add items from the first collection foreach($collection1 as $item) { $merged->addItem($item); } //add items from the second collection foreach($collection2 as $item) {
    – Newbee
    Oct 29, 2014 at 15:33
  • you can make a single collection by union.. check this post: magento.stackexchange.com/a/23777/15499
    – Detzler
    Oct 29, 2014 at 15:44

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.