Skip to content

Error on order success page, Warning: Undefined array key 104 #122

@steverobbins

Description

@steverobbins

Preconditions (*)

  1. Magento 2.4.7-p7
  2. Module 1.6.4

Steps to reproduce (*)

  1. Place an order

Expected result (*)

  1. View the success page

Actual result (*)

  1. The Magento error page is shown, "There has been an error processing your request"
  2. The error in the report is Warning: Undefined array key 104 in /var/www/deploy/releases/20251112204937/vendor/meta/module-conversion/Model/Tracker/Purchase.php on line 189

This is the line of code causing the error

if ($order->getCustomerGender()) {
$genderId = $order->getCustomerGender();
$userData[AAMSettingsFields::GENDER] =
$this->magentoDataHelper->hashValue(
$this->customerMetadata->getAttributeMetadata('gender')
->getOptions()[$genderId]->getLabel()
);
}

There probably needs to be an additional condition to make sure the $genderId exists in the array before calling the ->getLabel() method, for example:

if ($order->getCustomerGender()) {
    $genderId = $order->getCustomerGender();
    $gender = $this->customerMetadata->getAttributeMetadata('gender')
        ->getOptions()[$genderId] ?? false;
    if ($gender) {
        $userData[AAMSettingsFields::GENDER] =
            $this->magentoDataHelper->hashValue($gender->getLabel());
    }
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions