Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Unable to clear/remove customer DOB via admin console #4604

Open
massa-man opened this issue Feb 5, 2025 · 0 comments · May be fixed by #4605
Open

Unable to clear/remove customer DOB via admin console #4604

massa-man opened this issue Feb 5, 2025 · 0 comments · May be fixed by #4605

Comments

@massa-man
Copy link
Contributor

Preconditions (*)

  1. OpenMage v20.12.2

Steps to reproduce (*)

  1. Login to admin
  2. Navigate to Customers -> Manage Customers
  3. Create a new customer with a DOB set or select an existing customer that has a DOB set
  4. On the customer detail page -> Account Information tab, clear the customer DOB that was previously set and save the customer

Expected result (*)

  1. The customer DOB should be cleared and the attribute deleted from the DB (table customer_entity_datetime)

Actual result (*)

  1. Nothing happens, the DOB is not removed and the original value is kept

Debug

I debugged this isue and tracked down the issue to the following code:

File: Mage_Eav_Model_Attribute_Data_Date

Line 94-103

    public function compactValue($value)
    {
        if ($value !== false) {
            if (empty($value)) {
                $value = null;
            }
            $this->getEntity()->setDataUsingMethod($this->getAttribute()->getAttributeCode(), $value);
        }
        return $this;
    }

Specifically line 96 if ($value !== false) {. When trying to remove an attribute value in an EAV entity like Customer, the form sets the value of the attribute to false, and this code does not set the value from the form to the customer entity, basically ignoring the attribute update.

The following classes and methods are involved in this request:

Mage_Adminhtml_CustomerController::saveAction()

Which uses:

class Mage_Customer_Model_Form extends Mage_Eav_Model_Form

To load the request data, validate and set the data into the customer entity (via the compactData() method). This method in turn loads the attribute data model for each EAV attribute based on the attribute type, and uses the data model to manipulate the attribute data values from the request, ultimately calling the compactValue function in each attribute data model to set the request data in the customer entity model before saving the model.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
2 participants