Follow by Email

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();
    }
                                               
 }

2 comments:

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

    ReplyDelete
  2. Magento outsourcing is a Magento based development and IT outsourcing company focusing on magento e-commerce development.Magento DevelopmentThank you for sharing this post about the best techniques for Magento Development, This is very useful for Magento Development and Magento Development Company. Thanks again :)

    eCommerce Web Design Company in India |outsource magento ecommerce services india

    ReplyDelete