I want to override mone method prepare of class


I tried to do with preference but there is no effect

I also tried using plugin but it throws error

below is my plugin code

<type name="Magento\Ui\Component\Form\Element\AbstractOptionsField">
        <plugin name="aroundPrepare_override" type="Vendor\Custom\Plugin\AbstractOptionsField"/>

AbstractOptionsField file

namespace Vendor\Custom\Plugin;

use Magento\Framework\Data\OptionSourceInterface;
use Magento\Framework\View\Element\UiComponent\ContextInterface;

class AbstractOptionsField extends \Magento\Ui\Component\Form\Element\AbstractElement

    public function __construct(
        ContextInterface $context,
        $options = null,
        array $components = [],
        array $data = []
    ) {
        $this->options = $options;
        parent::__construct($context, $components, $data);

    public function aroundPrepare(
        \Magento\Ui\Component\Form\Element\AbstractOptionsField $subject,
        \Closure $proceed
    ) {

        $writer = new \Zend\Log\Writer\Stream(BP . '/var/log/customer123.log');
        $logger = new \Zend\Log\Logger();


Can anyone help me what I missing.


Class Vendor\Custom\Plugin\AbstractOptionsField contains 1 abstract method and must therefore be declared abstract or implement the remaining methods

1 Answer 1


Your plugin should not extend the original class. I think just by removing the extend it should work.


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.