1

Running Magento 2.3.4 and encountering an issue with Magento core code.

For the past couple of days I've been battling terrible performance on my site, especially when serving uncached content via pub/static.

Investigating this by enabling Magento's profiler, I noticed that the store.resolve event was taking upwards of 12 seconds to process when fetching a single JavaScript file via pub/static:

enter image description here

Looking at the code, this event is located in the Magento\Store\Model\StoreManager class:

    public function getStore($storeId = null)
    {
        if (!isset($storeId) || '' === $storeId || $storeId === true) {
            if (null === $this->currentStoreId) {
                \Magento\Framework\Profiler::start('store.resolve');
                $this->currentStoreId = $this->storeResolver->getCurrentStoreId();
                \Magento\Framework\Profiler::stop('store.resolve');
            }
            $storeId = $this->currentStoreId;
        }
        if ($storeId instanceof \Magento\Store\Api\Data\StoreInterface) {
            return $storeId;
        }

        $store = is_numeric($storeId)
            ? $this->storeRepository->getById($storeId)
            : $this->storeRepository->get($storeId);

        return $store;
    }

storeResolver is an instance of Magento\Store\Api\StoreResolverInterface, the direct usage of which I notice has been deprecated by Magento, maybe because of performance issues.

Following the code further, it looks like Magento tries to determine the current store code from the current HTTP request, eventually ending up in Magento\Store\App\Request\StorePathInfoValidator->getValidStoreCode().

However I haven't been able to find out why the performance is so poor.

Does anyone have any ideas why this is happening?

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.