I know that there is a function called getRuleProductIds($ruleID), which should return an array of product IDs by rule ID, but I don’t know where to use it and which collection Related to it and so on.
I have the following code in the products_in_promotion.phtml template:
$rules = Mage ::getModel('catalogrule/rule');
$collection = $rules->getCollection();
$sale_items = $collection->getRuleProductIds(1); # ??????? this throws an error
?>
$collection correctly stores an array of all Catalog Price rules, but this rule is as close as possible. There is no product list.
I am here Any thoughts on what I did wrong?
$catalog_rule = Mage::getModel('catalogrule/rule')->load(1); // Rule ID
$skus = $catalog_rule->getMatchingProductIds();
var_dump($skus);
Heart to Heart
< /p>
I need a way to retrieve product IDs associated with catalog price rule promotions (for example, 50% of the price of all items in the BICYCLES category). I want to do this without having to traverse the entire product database. < p>
I know there is a function called getRuleProductIds($ruleID), which should return an array of product IDs by rule ID, but I don’t know where to use it, which collection is associated with it, etc. Etc.
I have the following code in the products_in_promotion.phtml template:
$rules = Mage::getModel(' catalogrule/rule');
$collection = $rules->getCollection();
$sale_items = $collection->getRuleProductIds(1); # ??????? this throws an error< br />?>
$collection correctly stores an array of all Catalog Price rules, but this rule is as close as possible. There is no product list.
What thoughts am I doing wrong here? ?
You don’t have to use it as a collection. Just load the rules you want and use getMatchingProductIds in Mage_CatalogRule_Model_Rule (aka catalogrule/rule).
$catalog_rule = Mage::getModel('catalogrule/rule')->load(1); // Rule ID
$skus = $catalog_rule- >getMatchingProductIds();
var_dump($skus);
Heart to Heart