Posting in the Magento forums has been disabled pending the implementation of a new and improved forum solution which should better serve the community.

For new questions please post at magento.stackexchange.com, the community-run support site for the Magento community. We will be providing updates on the new forum solution soon. For questions or concerns please email community@magento.com.

Magento Forum

get rules applied to product
 
abille
Jr. Member
 
Total Posts:  27
Joined:  2008-08-21
 

Hi,

in product view template, i’d like to get the catalog price rules that applies to the product viewed

i tried to use getRulesForProduct , but i assume i didn’t do it right.

does anyone know how to do that ?

 
Magento Community Magento Community
Magento Community
Magento Community
 
abille
Jr. Member
 
Total Posts:  27
Joined:  2008-08-21
 

if anyone interested here is the function i wrote to do that.
it retrieves the rule applied for one product and one customer group, with complete rule informations, including rule name :

public function getRulesForMyProduct($pId,$gId)
{
$resource = Mage::getSingleton(’core/resource’);
$read = $resource->getConnection(’catalog_read’);

$select = $read->select()
->from(array("rp"=>$resource->getTableName(’catalogrule/rule_product’)), ‘*’)
->join(array("r"=>$resource->getTableName(’catalogrule/rule’)),"r.rule_id=rp.rule_id", ‘name’)
->where(’product_id=?’, $pId)
->where(’customer_group_id=?’, $gId);
return $read->fetchAll($select);
}

 
Magento Community Magento Community
Magento Community
Magento Community
 
ykaribou
Jr. Member
 
Total Posts:  4
Joined:  2009-04-08
 

Where did you write this function ? In which class?

 
Magento Community Magento Community
Magento Community
Magento Community
Magento Community
Magento Community
Back to top