0

I need to update particular field in table using CRUD operation of Magento.

I have tried below for insert new record it is working

$this->_cancelFactory->create()->setData(array('cancel_status'=>'Review'))->save();

I have tried below for update particular row but it does not work

$this->_cancelFactory->create()->setData(array('cancel_status'=>'Canceled'))->where(array('order_id'=>$oid))->save();

What is the right way to update table?

asked May 13, 2016 at 7:54

1 Answer 1

4
$cancelId = 5;//id for entry to update
$cancel = $this->_cancelFactory->create();
$cancel->load($cancelId);
$cancel->setCancelStatus('Review');
$cancel->save();

But as explained in the answers in here: Deprecated save and load methods in Abstract Model, load and save are deprecated. You should create service contracts for your module.

answered May 13, 2016 at 7:58

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

By clicking "Post Your Answer", you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.