function remove ( $id = null, $dumb = null )
 {
     eZPersistentObject::removeObject( eZDiscountSubRule::definition(),
                                       array( "id" => $id ) );
 }
        $customerIDArray = $http->postVariable("CustomerIDArray");
        $db = eZDB::instance();
        $db->begin();
        foreach ($customerIDArray as $customerID) {
            eZUserDiscountRule::removeUser($customerID);
        }
        $db->commit();
    }
    eZContentCacheManager::clearAllContentCache();
}
$membershipList = eZUserDiscountRule::fetchByRuleID($discountGroupID);
$customers = array();
foreach ($membershipList as $membership) {
    $customers[] = eZContentObject::fetch($membership->attribute('contentobject_id'));
}
$ruleList = eZDiscountSubRule::fetchByRuleID($discountGroupID);
$ruleArray = array();
foreach ($ruleList as $rule) {
    $name = $rule->attribute('name');
    $percent = $rule->attribute('discount_percent');
    $limitation = $rule->attribute('limitation');
    $discountRuleID = $rule->attribute('id');
    if ($limitation != '*') {
        $ruleValues = eZDiscountSubRuleValue::fetchBySubRuleID($discountRuleID);
        if ($ruleValues != null) {
            $limitation = ezpI18n::tr('kernel/shop', 'Classes') . ' ';
            $firstLoop = true;
            foreach ($ruleValues as $ruleValue) {
                $classID = $ruleValue->attribute('value');
                $class = eZContentClass::fetch($classID);
                if ($class) {
        $productList[] = $object;
}

if ( $http->hasPostVariable( 'StoreButton' ) )
{
    // remove products stored in the database and store them again
    $db = eZDB::instance();
    $db->begin();
    if ( $discountRuleID )
    {
        $discountRule = eZDiscountSubRule::fetch( $discountRuleID );
        eZDiscountSubRuleValue::removeBySubRuleID ( $discountRuleID );
    }
    else
    {
        $discountRule = eZDiscountSubRule::create( $discountGroupID );
        $discountRule->store();
        $discountRuleID = $discountRule->attribute( 'id' );
    }

    $discountRule->setAttribute( 'name', trim( $http->postVariable( 'discountrule_name' ) ) );
    $discountRule->setAttribute( 'discount_percent', $http->postVariable( 'discountrule_percent' ) );
    $discountRule->setAttribute( 'limitation', '*' );

    if ( $http->hasPostVariable( 'Products' ) && $http->postVariable( 'Products' ) )
    {
        foreach( $productList as $product )
        {
            $ruleValue = eZDiscountSubRuleValue::create( $discountRuleID, $product->attribute( 'id' ), 2 );
            $ruleValue->store();
        }