0

I have the raw product price in a variable and i want to be able to apply only a specific rule to it.

Right now what i am doing is iterating over all the rules, conditioning only the ones i want. What i have today (i simplified the code here):

$productPrice = $product->getPrice();
$catRul = Mage::getResourceModel('catalogrule/rule')-getRulesFromProduct(Mage::getModel('core/date')->date('Y-m-d'), $websiteId, $userGroupId, $data['entity_id']);
if(isset($catRul) && !empty($catRul)) {
    foreach($catRul as $rule) {
        $catalogRulObj = Mage::getModel('catalogrule/rule')->load($rule['rule_id']);
        $ruleData = $catalogRulObj->getData();
        if($ruleData['is_active'] === '1'){ // Here i am conditioning with a couple more stuff
              // Here i want to apply this rule conditioned in $ruleData; only, not all like below \/
              $productPrice = Mage::getModel('catalogrule/rule')->calcProductPriceRule($product, $product->getPrice());
        }
    }
}

Thank you very much.

1 Answer 1

0

Just in case, if anyone bump on this same question in the future, i managed to solve this using something like this:

$productPrice = $product->getPrice();
$catRul = Mage::getResourceModel('catalogrule/rule')-getRulesFromProduct(Mage::getModel('core/date')->date('Y-m-d'), $websiteId, $userGroupId, $data['entity_id']);
if(isset($catRul) && !empty($catRul)) {
    foreach($catRul as $rule) {
        $catalogRulObj = Mage::getModel('catalogrule/rule')->load($rule['rule_id']);
        $ruleData = $catalogRulObj->getData();
        if($ruleData['is_active'] === '1'){ // Here i am conditioning with a couple more stuff
              $productPrice = Mage::helper('catalogrule')->calcPriceRule($ruleData['simple_action'], $ruleData['discount_amount'], $productPrice);
        }
    }
}

Your Answer

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

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