1
$discounted_price = Mage::getResourceModel('catalogrule/rule')->getRulePrice(
    Mage::app()->getLocale()->storeTimeStamp($store_id),
    Mage::app()->getStore($store_id)->getWebsiteId(),
    Mage::getSingleton('customer/session')->getCustomerGroupId(),
    $_product->getId()
);

I used this to get the catalog rule price for a product. Now i want to get the toDate of the catalog rule applied to a product how can i achieve it? And also as a developer is there a documentation which i can refer to find functions like these?

1 Answer 1

0

It doesn't look like the method you're using will let you do that, as it returns a price from a rule that matches the input you provide.

I've only had a quick look at these classes, but it looks like you may be able to load rules for the product then use that to get the toDate fields from them:

// Add catalog rules to the product
Mage::getModel('catalogrule/rule')->loadProductRules($product);

// Get matched rule IDs
foreach ($product->getMatchedRules() as $ruleId=>$ruleval) {
    /** @var Mage_CatalogRule_Model_Rule $rule */
    $rule = Mage::getModel('catalogrule/rule')->load($ruleId);
    echo $ruleId . ' has a toDate of: ' . $rule->getToDate() . ' and matches my product.', PHP_EOL;
}

This would give you any rule that matches the product (I believe). It may be what you need, but may also be unhelpful if you have multiple rules that end up at the same price (if you're comparing your value to the value in this loop).

It would be much more useful if the method you're using returned the rule model or ID that matched rather than just the price of it, but oh well - you will need to do what you can do.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.