I'm trying to upgrade an existing Magento 2.2.4 installation to 2.3.4. The initial step performed was to update to 2.3.0 first, which went fine and without any errors, but when I'm trying to update from 2.3.0 to 2.3.4 I am getting the following error when compiling:

    Compilation was started.
    Repositories code generation... 1/7 [====>-----------------------]  14% < 1 sec 72.0 MiBPHP Fatal error:  Declaration of Rokanthemes\OpCheckout\Block\Checkout\AttributeMerger::getDefaultValue($attributeCode) must be compatible with Magento\Checkout\Block\Checkout\AttributeMerger::getDefaultValue($attributeCode): ?string in /var/www/html/app/code/Rokanthemes/OpCheckout/Block/Checkout/AttributeMerger.php on line 56

Here are the contents of the mentioned file:


    namespace Rokanthemes\OpCheckout\Block\Checkout;

    use Magento\Directory\Helper\Data as DirectoryHelper;
    use Magento\Customer\Model\Session;
    use Magento\Customer\Api\CustomerRepositoryInterface as CustomerRepository;
    use Magento\Customer\Helper\Address as AddressHelper;
    use Rokanthemes\OpCheckout\Helper\Config as OneStepConfig;
    use Magento\Directory\Model\ResourceModel\Region\Collection as RegionCollection;

    class AttributeMerger extends \Magento\Checkout\Block\Checkout\AttributeMerger

        protected $_oneStepConfig;

        protected $_regionCollection;

        protected $_directoryHelper;

        public function __construct(
            AddressHelper $addressHelper,
            Session $customerSession,
            CustomerRepository $customerRepository,
            DirectoryHelper $directoryHelper,
            OneStepConfig $oneStepConfig,
            RegionCollection $regionCollection
            $this->_oneStepConfig = $oneStepConfig;
            $this->_regionCollection = $regionCollection;
            $this->_directoryHelper = $directoryHelper;
            parent::__construct($addressHelper, $customerSession, $customerRepository, $directoryHelper);

        protected function getDefaultValue($attributeCode)
            if ($this->_oneStepConfig->getFullRequest() == 'checkout_index_index') {
                switch ($attributeCode) {
                    case 'firstname':
                        if ($this->getCustomer()) {
                            return $this->getCustomer()->getFirstname();
                    case 'lastname':
                        if ($this->getCustomer()) {
                            return $this->getCustomer()->getLastname();
                return null;
            } else {
                return parent::getDefaultValue($attributeCode);

I am really looking for a solution or fix to have this work properly, some expert advise would therefore be greatly appreciated. Thank you very much.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.