All posts by Pramod T P

Magento 2 Requested store is not found

This issue can be fixed by issuing the following queries

UPDATE store SET store_id = 0 WHERE code='admin';
UPDATE store_group SET group_id = 0 WHERE name='Default';
UPDATE store_website SET website_id = 0 WHERE code='admin';

It can also be solved by modify StoreManager.php (/vendor/magento/module-store/Model/StoreManager.php)

If $storeId is not defined: It retrive data from COOKIE first, otherwise return the default store code.

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;
}

To

if(!$storeId) {
if(isset($_COOKIE['store']) && $_COOKIE['store'] !== ''){
$storeId = $_COOKIE['store'];
} else {
$storeId = $this->getDefaultStoreView()->getCode();
}
}

Magento 2 css not working

I have fixed the issue by modifying option in config Stores>Configuration -> Advanced -> Developer ->Sign Static Files (dev_static_sign) -> No.

As the admin panel was not accessible I made this change at DB level.

insert into core_config_data (config_id, scope, scope_id, path, value) values (null, 'default', 0, 'dev/static/sign', 0);

vi editor replace all

The syntax for replacing one string with another string in the current line is

:s/pattern/replace/

Here “pattern” represents the old string and “replace” represents the new string. For example, to replace each occurrence of the word “lemon” in a line with “orange,” type:

:s/phpcode/phpcodez/

The syntax for replacing every occurrence of a string in the entire text is similar. The only difference is the addition of a “%” in front of the “s”:

:%s/pattern/replace/

Thus repeating the previous example for the entire text instead of just for a single line would be:

:%s/phpcode/phpcodez/

We can’t find the role for the user you wanted.

Edit the file vendor/magento/module-authorization/Model/Acl/AclRetriever.php at line# 85 and replace the below code

   if (!$role) {
throw new AuthorizationException(
__('We can\'t find the role for the user you wanted.')
);
}
$allowedResources = $this->getAllowedResourcesByRole($role->getId());

With this one

if (!$role) {
            $allowedResources = array();
        }

Once success, please revert back the file.

Import a large sql dump file

1) Set network buffer length to a large byte number. The default value may throw errors for such large data files

set global net_buffer_length=1000000;

2) Set maximum allowed packet size to a large byte number.The default value may throw errors for such large data files.

set global max_allowed_packet=1000000000;

3) Disable foreign key checking to avoid delays,errors and unwanted behaviour

SET AUTOCOMMIT = 0;
SET UNIQUE_CHECKS = 0;
SET foreign_key_checks = 0;

4) Import your sql dump file

source FILEPATH/FILE_NAME

5) Enable foreign key checks when import is done.

SET AUTOCOMMIT = 1;
SET UNIQUE_CHECKS = 1;
SET foreign_key_checks = 1;
innodb_buffer_pool_size    = 1G
innodb_log_buffer_size = 1G
innodb_write_io_threads = 16
innodb_flush_log_at_trx_commit = 0
innodb_log_file_size = 1G