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

  • Thank You, but how would i loop through both of them at the same time? – Newbee Oct 29 '14 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 '14 at 15:33
  • you can make a single collection by union.. check this post: magento.stackexchange.com/a/23777/15499 – Detzler Oct 29 '14 at 15:44

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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