I have created a few custom product attributes in Magento 2.2.6 and have no problem saving a new product with these new attributes, load this created product, and update the standard Magento attributes. But if I try to update a custom attribute, it just will not update the value. It won't even throw an error, it looks like everything went fine, but the value did not change.

Example custom attribute creation:

$eavSetup = $this->eavSetupFactory->create();
    'protein', [
        'group'      => $this->attributeGroupName,
         type'       => 'varchar',
        'label'      => 'Protein',
        'input'      => 'text',
        'required'   => false,
        'visible'    => true,
        'sort_order' => 50,
        'global'     => \Magento\Eav\Model\Entity\Attribute\ScopedAttributeInterface::SCOPE_STORE

Creating and updating product:

$this->product = $this->productFactory->create();
$this->product = $this->product->loadByAttribute('sku', $data['sku']) ?: $this->product;

// $this->product->setData('protein', $data['protein']);


If anyone has any idea why the value of the custom attributes won't update, I would be grateful!

  • Did you find any solution to this? I'm stuck with this problem. – Manish Shrestha Jun 10 at 7:34
  • As far as i remember I did not, sorry. – leepe Jun 11 at 10:51

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.