0

I added custom column 'email_status' in customer_entity table via dc_schema.xml

    <?xml version="1.0"?>
    <schema xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
            xsi:noNamespaceSchemaLocation="urn:magento:framework:Setup/Declaration/Schema/etc/schema.xsd">
        <table name="customer_entity">
            <column xsi:type="tinyint" name="email_status" default="0" unsigned="true" nullable="false"
                    comment="1 = pending | 2 = sent"/>
        </table>
    </schema>

bin/magento setup:db-declaration:generate-whitelist

bin/magento setup:upgrade command.

The field added successfully. But when I am trying to modify it via customer model, It is not modifying. Here is the code.

        $customer = $this->customer->load(2);
        $customer->setData('email_status', 1);
        try {
            $customer->save();
        } catch (\Exception $e) {
            echo $e->getMessage();
        }

Please help me.

1 Answer 1

0

All the columns in customer_entity table should an eav attribute of customer. So for adding any new column in customer_entity table, We must create an eav of the same name with the

backend_type = static

Your Answer

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

Not the answer you're looking for? Browse other questions tagged or ask your own question.