Skip to main content
Tweeted twitter.com/StackMagento/status/853581694787571712
added 173 characters in body
Source Link
Kingshuk Deb
  • 1.2k
  • 2
  • 11
  • 31

As you guys already know that we used to have this below method in magento to save a specific attribute value like this.

// saving product attribute
$product = Mage::getModel('catalog/product')->load('id here');
$product->setName('your name here');
$product->getResource()->saveAttribute($product, 'name');

or

// saving customer attribute
$customer->setData($attrCode, $value)->getResource()->saveAttribute($customer, $attrCode);

Can anyone let me know the alternative of the above in Magento2 .

As you guys already know that we used to have this below method in magento to save a specific attribute value like this.

$product = Mage::getModel('catalog/product')->load('id here');
$product->setName('your name here');
$product->getResource()->saveAttribute($product, 'name');

Can anyone let me know the alternative of the above in Magento2 .

As you guys already know that we used to have this below method in magento to save a specific attribute value like this.

// saving product attribute
$product = Mage::getModel('catalog/product')->load('id here');
$product->setName('your name here');
$product->getResource()->saveAttribute($product, 'name');

or

// saving customer attribute
$customer->setData($attrCode, $value)->getResource()->saveAttribute($customer, $attrCode);

Can anyone let me know the alternative of the above in Magento2 .

Source Link
Kingshuk Deb
  • 1.2k
  • 2
  • 11
  • 31

How to save only specific attribute value rather than saving the whole product in Magento2

As you guys already know that we used to have this below method in magento to save a specific attribute value like this.

$product = Mage::getModel('catalog/product')->load('id here');
$product->setName('your name here');
$product->getResource()->saveAttribute($product, 'name');

Can anyone let me know the alternative of the above in Magento2 .