5

i want to delete catalog price rule after order placed

how to delete catalog price rule after order placed help of event observer Method

2
  • Mage::getModel('catalogrule/rule')->load($rulesId)
    – Amit Bera
    Jan 5 '15 at 7:33
  • Are you sure, you want to delete a catalog price rule as soon as it has been used once and not a shopping cart price rule? Catalog price rules are the rules which are visible in the catalog as special prices and recalculated each night. If you can elaborate what you need this for, you might get better answers. Sep 17 '15 at 7:25
1

Vaibhav,You can use checkout_submit_all_after event.This event is occur after order place.

Step1:You need load catalog rules by Id and then remove

  $model = Mage::getModel('catalogrule/rule');
        $model->load($rulesId) );
        $model->delete();

Step2: remove catalog rules.

Mage::getModel('catalogrule/flag')->loadSelf()
            ->setState(1)
            ->save();

Edit: delete by name

  $collection = Mage::getModel('catalogrule/rule')
        ->getResourceCollection()->addFieldToSelect('*')->addFieldToFiler('name',$rulesName);
    $collection->addWebsitesToResult();

foreach($collection as $each){
$model = Mage::getModel('catalogrule/rule');
$model->load($each) )->getId(;
$model->delete();

}
Mage::getModel('catalogrule/flag')->loadSelf()
        ->setState(1)
        ->save();
5
  • at which event ? Jan 5 '15 at 7:36
  • 1
    and what to do if we want to delete by name of rule Jan 5 '15 at 7:54
  • 1
    yes.you can do this
    – Amit Bera
    Jan 5 '15 at 8:08
  • 1
    i need to change price of product at cart . on product page it's displayed original price but after click on add to cart it's display custom price on cart page with help of event observer u have any idea how to do this Jan 5 '15 at 9:35
  • I want to delete catalog price rule in magento 2 Mar 26 '18 at 12:00

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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