0

MiBPHP Fatal error: Declaration of Amasty\Shopby\Model\Source\Attribute\Extended::toOptionArray() must be compatible with Amasty\Shopby\Model\Source\Attribute::toOptionArray($boolean = 1) in /home/ubuntu/environment/the-new-craftsmen/app/code/Amasty/Shopby/Model/Source/Attribute/Extended.php on line 28

public function toOptionArray()
    {
        $allOption = [[
            'value' => self::ALL,
            'label' => strval(__('All Attributes'))
        ]];
        return array_merge($allOption, parent::toOptionArray());
    }

2 Answers 2

2

The declaration of a toOptionArray() function must match with its parent

Try to use $boolean = 1 in your child function like this

app/code/Amasty/Shopby/Model/Source/Attribute/Extended.php

public function toOptionArray($boolean = 1)
{
    $allOption = [[
        'value' => self::ALL,
        'label' => strval(__('All Attributes'))
    ]];
    return array_merge($allOption, parent::toOptionArray());
}

Or Remove $boolean = 1 from parent file's toOptionArray() function

app/code/Amasty/Shopby/Model/Source/Attribute.php

/**
 * Options getter
 *
 * @return array
 */
public function toOptionArray()
{
    $optionArray = [];
    $arr = $this->toArray();
    foreach($arr as $value => $label){
        $optionArray[] = [
            'value' => $value,
            'label' => $label
        ];
    }
    return $optionArray;
}

Hope this will help you!

1
  • Let me know if it helps, thanks. :-) Apr 28, 2020 at 11:13
1

Give a try to add a parameter in the file app/code/Amasty/Shopby/Model/Source/Attribute/Extended.php

public function toOptionArray($boolean = 1)
    {
        $allOption = [[
            'value' => self::ALL,
            'label' => strval(__('All Attributes'))
        ]];
        return array_merge($allOption, parent::toOptionArray());
    }

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.