Thursday, October 15, 2015

Update record with condition in custom module in magento

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



foreach($cart as $item_id=>$item){
        $olddata_id = Mage::getModel('custom/csaabandonedcart')->getCollection()
                ->addFieldToFilter('csa_id', Mage::getSingleton('customer/session')->getCustomerId())
                 ->addFieldToFilter('customer_id', $retailer)->addFieldToFilter('product_id', $item_id)
                ->getColumnValues('id');
                                                                                               
     $abandonedcart = Mage::getModel('custom/csaabandonedcart')->load($olddata_id[0]);
            $abandonedcart->setQuantity($item['qty']);
             $abandonedcart->save();           
 }
 

10 comments:

  1. Your post urges me to create a business website, of course I will free download magento as soon as possible. Magento is truly the best platform ever. Its extensions is also awesome. Thank you.

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

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

    ReplyDelete
  4. Nice to read this article... Thanks for sharing.....
    magento 2 training

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

    ReplyDelete
  6. I am reading your post from the beginning, it was so interesting to read & I feel thanks to you for posting such a good blog, keep updates regularly.Professional Web design services are provided by W3BMINDS- Website designer in Lucknow.
    Web development Company | Web design company

    ReplyDelete
  7. 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. Pubg Tournament App Development

    ReplyDelete
  8. I read your blog and found it to be pretty instructive. I would like to thank you for sharing an amazing article here.

    Kingston Jamaica Homes For Sale

    ReplyDelete