Post by Sm00dE » Mon Oct 14, 2024 5:11 am

I'm testing OpenCart version 4.0.2.3 and created several product options for a product. However, the options are not showing up, and now I can't access the product at all. I get the following error:

Code: Select all

Opencart\Admin\Model\Catalog\Option::getValue(): Argument #1 ($option_value_id) must be of type int, null given in /home//domains//public_html/zwobce7tn6hmwsdp/model/catalog/option.php on line 
I tried updating to the GitHub 4.1.0.0 version, thinking that an update might have fixed a similar bug, but the same problem persists. Has anyone encountered this issue or found a solution?

New member

Posts

Joined
Wed Feb 01, 2012 4:32 am

Post by Sm00dE » Mon Oct 14, 2024 5:31 am

Solution:
To fix this issue, I edited the getValue() method in the admin/model/catalog/option.php file to add a check for NULL values. Here is what I did:

I modified the getValue() function to make sure that $option_value_id is not NULL before it is used. I added this check at the beginning of the function:

Code: Select all

public function getValue(?int $option_value_id): array {
    if (is_null($option_value_id)) {
        error_log("Warning: option_value_id is NULL, setting it to 0.");
        $option_value_id = 0;
    }
}
After making this change, the error was resolved and I could access the product edit without issues.

New member

Posts

Joined
Wed Feb 01, 2012 4:32 am
Who is online

Users browsing this forum: No registered users and 1 guest