magento2 icon indicating copy to clipboard operation
magento2 copied to clipboard

Warning: Illegal offset type in vendor/magento/framework/App/Config/ScopeCodeResolver.php on line 58

Open raisaev opened this issue 9 years ago • 11 comments

Judging by code the class of ScopeCodeResolver can work with the objects ScopeInterface as a second parameter of the resolve method but it will cause 'Illegal offset type' warning.

Preconditions

  1. Magento v. 2.1.4

Steps to reproduce

` /** @var \Magento\Store\Model\Store $store */ $store = $this->_objectManager->get('Magento\Store\Model\Store'); $store->load(0);

$resolver = $this->_objectManager->get('Magento\Framework\App\Config\ScopeCodeResolver'); $code = $resolver->resolve('store', $store);

echo $code; `

Expected result

  1. The method has to return store code.

Actual result

Exception #0 (Exception): Warning: Illegal offset type in vendor/magento/framework/App/Config/ScopeCodeResolver.php on line 59

#1 Magento\Framework\App\Config\ScopeCodeResolver->resolve('store', Object(Magento\Store\Model\Store\Interceptor))

raisaev avatar Feb 13 '17 13:02 raisaev

Same Issue

anethum avatar Feb 13 '17 15:02 anethum

Same Issue

bobsimage avatar Feb 19 '17 10:02 bobsimage

same here, i got this error while creating orders that we received in M2E pro.

michafn avatar Feb 21 '17 23:02 michafn

@michafn, me too. In order to fix that you can make some modifications to app\code\Ess\M2ePro\Model\Magento\Quote\Store\Configurator.php

find the methods setStoreConfig() and getStoreConfig() and replace $this->getStore() with $this->getStore()->getCode() for theirs arguments

raisaev avatar Feb 22 '17 08:02 raisaev

@raisaev : thank you very much for this fix

michafn avatar Feb 22 '17 08:02 michafn

Nice Raisaev. It works !!! You must have great experience in Magento code $this->storeConfig->setValue($key, $value, \Magento\Store\Model\ScopeInterface::SCOPE_STORE, $this->getStore()->getCode());

lakehavasu avatar Feb 22 '17 18:02 lakehavasu

some modifications to app\code\Ess\M2ePro\Model\Magento\Quote\Store\Configurator.php

This piece of code in Magento never worked or was changed recently?

orlangur avatar Feb 22 '17 19:02 orlangur

We had this issue come up as well as soon as we updated to the latest M2E Pro version. M2E Pro gave us a new Configurator.php file and it solved the issue... it basically just had the fix mentioned above.

EmilyPepperman avatar Feb 24 '17 21:02 EmilyPepperman

Also get this error creating orders in M2E Pro. @raisaev fix works, so is this an M2E issue or a Magento issue? Also an upgrade of M2E will override Configurator.php modifications, so watch out for that.

dunarri avatar Mar 11 '17 02:03 dunarri

@raisaev, thank you for your report. We've created internal ticket(s) MAGETWO-80961 to track progress on the issue.

magento-engcom-team avatar Oct 05 '17 09:10 magento-engcom-team

Steps to reproduce are invalid, $store model obviously cannot be passed to \Magento\Framework\App\Config\ScopeCodeResolver::resolve:

    /**
     * Resolve scope code
     *
     * @param string $scopeType
     * @param string $scopeCode
     * @return string
     */
    public function resolve($scopeType, $scopeCode)

Other issues mentioned in discussion are bugs in third-party code which seem to be already fixed. Thanks for collaboration and help in sorting this out!

orlangur avatar Oct 05 '17 12:10 orlangur