I want to create a page which shows all products affected by a catalog price rule since these products are on sale at the moment they receive a catalog price rule. Currently I have a piece of code which can show me products from one catalog price rule:
$rule = Mage::getModel('catalogrule/rule')->load(12); /* catalog price rule id */
$rule->setWebsiteIds("1");
$productIdsArray = $rule->getMatchingProductIds();
$productsCollection = Mage::getModel('catalog/product')
->getCollection()
->addAttributeToSelect("*")
->addAttributeToFilter('visibility', 4)
->addAttributeToFilter("entity_id", array("in", $productIdsArray));
I would like to expand this piece of code so I receive all catalog price rules and show all products on sale on a page. Any help would be appreciated.
I have 0 experience with Magento but here is my suggestion.
Can you put this code into a loop which loops through all the catalog price rules id's and then add the products to one general productsCollection?
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.