Links / downloads are not its entities (therefore, it does not have a price_index table and is not considered as products)
There are 2 ways to use advertising in products.
Catalog price rules
Shopping Cart Rules
As your question stated that you used the catalog price rules, I resolved your question using the catalog price rules.
Create a module and rewrite the model
Mage_Downloadable_Model_Product_Type
======
<global> <models> <downloadable> <rewrite> <product_type>Web_Eproduct_Model_Downloadable_Product_Type</product_type> </rewrite> </downloadable> </models> </global>
and the code below calculates the price of each link on the fly (even if you have more than one rule applied to the same product)
class Namespace_Modulename_Model_Downloadable_Product_Type extends Mage_Downloadable_Model_Product_Type { public function getLinks($product = null) { $product = $this->getProduct($product); $wId = Mage::app()->getWebsite()->getId(); $gId = Mage::getSingleton('customer/session')->getCustomerGroupId(); $catalogRules = Mage::getSingleton('catalogrule/resource_rule')->getRulesFromProduct('',$wId,$gId,$product->getId()); if (is_null($product->getDownloadableLinks())) { $_linkCollection = Mage::getModel('downloadable/link')->getCollection() ->addProductToFilter($product->getId()) ->addTitleToResult($product->getStoreId()) ->addPriceToResult($product->getStore()->getWebsiteId()); $linksCollectionById = array(); foreach ($_linkCollection as $link) { $link->setProduct($product); $link->setPrice($this->calcLinkPrice($catalogRules,$link->getPrice())); $linksCollectionById[$link->getId()] = $link; } $product->setDownloadableLinks($linksCollectionById); } return $product->getDownloadableLinks(); } public function calcLinkPrice(array $rules = array(),$productPrice = 0 ) { foreach($rules as $ruleData) { $productPrice = Mage::helper('catalogrule')->calcPriceRule( $ruleData['action_operator'], $ruleData['action_amount'], $productPrice); } return $productPrice; } }
I tested it and confirmed its work, as you expect :)
Try it and let me know your thoughts :)
There is another way to achieve this if you use the Price Rules in the shopping cart, which I will post later.
source share