Skip to content

Magento 2 cloud getDefaultStore return null object when multiple store

I have cloud enterprise project with multi website. We are facing issue of null object is returned from getDefaultStore method.

I have created one admin role and given full access but assigned only selected website scope which we need.
enter image description here

And we using magento default login as customer functionality with that role and facing this error.and unable to login successfully.
enter image description here

I checked the default code and try to debug the issue but not get any luck.When we pass here getDefaultGroupId as static for that particular website then it’s working.

/**
     * @inheritdoc
     */
    public function getDefaultStoreView()
    {
        $defaultWebsite = $this->websiteRepository->getDefault();
        $defaultStore = $this->getGroup($defaultWebsite->getDefaultGroupId())->getDefaultStore();
        return $defaultStore ?: null;
    }