I am trying to find out if the condition that I am going to set in the price rule already exists or not. I tried to check if it is valid or not but couldn't find the correct function I think.
if($voucherRule->getConditions()->validate($realProduct)){
echo "<br> Already exists<br>";
$foundamatch = true;
}
if(!$foundamatch){
$item_found = Mage::getModel('salesrule/rule_condition_product_found')
->setType('salesrule/rule_condition_product_found')
->setValue(1) // 1 == FOUND
->setAggregator('any'); // match ANY conditions
$skuCondition = Mage::getModel('salesrule/rule_condition_product')
->setType('salesrule/rule_condition_product')
->setAttribute('sku')
->setOperator('==')
->setValue($realProduct->getSku());
$voucherRule->getConditions()->addCondition($item_found);
$item_found->addCondition($skuCondition);
}
$voucherRule->save();
Did not work, it always creates the same conditions over and over again when ever I run the script.
How can I check this?