I have found that magento has two separate ways of handling special prices but I don't know which is the best for my case. I found that catalog price rules are very powerful but I don't know how to loop through them without hardcoding the ID of the rule.
My client needs to have two kinds of special prices: normal discounts (20-30% off some products) and "flash sales" that last a short time (1-2 days). I need to have them show up in the home page and in the category pages, the ones in the home need to be selected by the admin from the backend and the ones in the category pages too, they will be set of 4 products on each page (the ones in the category pages need to be from said category). Then I have a link to a page with all the products that have special prices on them.
The "selecting" part of the deal I really don't know how to do but so far I can't even get the products with a catalog price rule to show up on my home page. I have a block for them and I found this code:
$rule = Mage::getModel('catalogrule/rule')->load(1);
$rule->setWebsiteIds("1"); $productIdsArray = $rule->getMatchingProductIds();
$productsCollection = Mage::getModel('catalog/product')->getCollection() ->addAttributeToSelect("*") ->addAttributeToFilter("entity_id", array("in", $productIdsArray));
$this->setProductCollection($collection);
But I'm guessing the ->load(1);
is hardcoding the ID of the promo, what if the user creates a new price rule then? How do I loop all through all the products that have a rule in them?
I do know how to loop through special price products and maybe I could use them for the flash promos but I think I'll be complicating it with the rest of the features that I need to implement.
Also if you have any advice on how to handle the fact that the user needs to select the 4 featured products I would be very thankful.