Thursday, October 15, 2015

Delete record with condition in custom module in magento



I have create a Model and for some development i had to implement delete method. It is very easy. I also try for conditional delete. But i am using the following code which will fulfill your requirement for conditional delete.

foreach($pid as $spid){
         $items = Mage::getModel('custom/csaabandonedcart')->getCollection()
        ->addFieldToFilter('csa_id', Mage::getSingleton('customer/session')->getCustomerId())
        ->addFieldToFilter('customer_id', $retailer)->addFieldToFilter('product_id', $spid);
         
 foreach($items as $item){
        $item->delete();
    }
                                               
 }

3 comments:

  1. I have bookmarked your blog, the articles are way better than other similar blogs.. thanks for a great blog!
    Newizze

    ReplyDelete
  2. This comment has been removed by the author.

    ReplyDelete
  3. Such a great and most useful information for me! I appreciate this post so much. I save all information and code separatelyy. Thanks for sharing it

    hire Magento developer

    ReplyDelete