Reputation: 21
suppose i have created a price rule that all product which have price more than Rs.1000 they will get 30% off. Now what i should do to make a list of those product which are under that catalog price rule
Upvotes: 2
Views: 2438
Reputation: 21
I have been looking for the same thing, found the following piece of code you can paste in your list.phtml and it shows you the products under a particular 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));
Be sure to change the price rule id and $productsCollection in the rest of the code in list.phtml
Should you be able to pull all the rules please let me know, been looking for a solution for a couple of days now.
Upvotes: 1
Reputation: 5443
Quite odd that there is no simple functionality for that indeed. What I can think of is the following to get a list of all ids of the selected products:
This works only when the rules have been applied already.
SELECT DISTINCT product_id FROM catalogrule_product WHERE rule_id=<id>;
where you replace <id> by the id found in step 1.There might be something easier though..
Upvotes: 1