Unable to go back to Default Mode getting error Magento2

I was in production mode and was getting an error when trying to go back to default mode

run below commands in sequence.

  • php bin/magento setup:di:compile
  • php bin/magento setup:upgrade
  • php bin/magento cache:clean
  • php bin/magento cache:flush

and then try to det default mode again, it should work now

bin/magento deploy:mode:set default

 

rm -rf var/view_preprocessed/* var/cache/* pub/static/*

Update No Reach Results Page, Magento2

There are 2 templates being used for result, one for simple search ( using top search field ) and other is for advance search field :

For Top search field result :

module_catalog-search/view/frontend/templates/result.phtml

For Advance Search result :

module_catalog-search/view/frontend/templates/advanced/result.phtml

And both search fields search data / record within product catalog, override the template(s), and add your condition in that template to show whatever data you want to show if there is no record is returned.

Easiest way to add Magento2 Goole Tag Manager Without Extensions

You can easily add GTM without third-party extensions. All you need is to add the GTM code to your active theme. The GTM code consist of two parts: script and noscript.
You need to put the GTM snippet into these two phtml templates for head and body:

New File#1

// YourTheme/Magento_Theme/templates/html/gtm_head.phtml
<script>..</script> <!– GTM code –>  add the GTM head code

New File#1

// YourTheme/Magento_Theme/templates/html/gtm_body.phtml
<noscript>..</noscript> <!– GTM code –> add the GTM no script code

To load the files correspondingly you should use the default .xml file:

<!– YourTheme/Magento_Theme/layout/default.xml –>
<referenceContainer name=”head.additional”>
<block class=”Magento\Framework\View\Element\Template” name=”gtm.head” before=”-” template=”Magento_Theme::html/gtm_head.phtml” />
</referenceContainer>

<referenceContainer name=”after.body.start”>
<block class=”Magento\Framework\View\Element\Template” name=”gtm.body” before=”-” template=”Magento_Theme::html/gtm_body.phtml” />
</referenceContainer>

How to Properly set Production Mode and compilation in Magento2

In Magento 2, You do not need to run static:content:deploy command every time when your Magento mode is default or developer, but when you change Magento mode to production at that time Magento will not generate static content file automatically.

So you need to run deploy commands in this sequence..

You can change your Magento mode from developer to production using below command.

php bin/magento deploy:mode:set production --skip-compilation

After running above command your Magento mode will be change from developer to production, then you need to run below commands.

php bin/magento setup:upgrade
php bin/magento setup:di:compile
or php -dmemory_limit=-1 bin/magento setup:di:compile
 php bin/magento cache:clean 
php bin/magento cache:flush 
php bin/magento setup:static-content:deploy -f en_US bg_BG
php -dmemory_limit=-1 bin/magento setup:static-content:deploy -f en_US  
How to remove H1 title from category and CMS pages in Magento 2

Solution: for all category pages

/vendor/magento/module-catalog/view/frontend/layout/catalog_category_view.xml. add line close to bottom of fime

    </referenceBlock>
     <referenceBlock name="page.main.title" remove="true" /> 
</body>

Solution: for individual pages

go to admin->content- > pages ->design section and paste in the xml <referenceBlock name="page.main.title" remove="true" />

Magento2 Server reached max_children setting
WARNING: [pool staging_4pens_com] server reached max_children setting (5), consider raising it

Reaching this limit would be caused by long-running PHP processes, causing additional PHP processes from additional site traffic to begin to stack and queue which can lead to increased site load time, and eventually result in timeouts.

Solution:

increase memory_limit in php.ini to 128M

using root access increase max children setting to 15

sudo grep max_children /var/log/php?.?-fpm-sp.log.1 /var/log/php?.?-fpm-sp.log

If any of your apps have reached their max_children limit, you’ll see output like this:

[24-Apr-2017 19:56:17] WARNING: [pool my-wordpress-app] server reached max_children setting (20), consider raising it

To increase the max_children setting for an app, SSH in to your server as root and rename this file:

/etc/phpX.Y-sp/fpm-pools.d/APPNAME.d/main.conf

to this:

/etc/phpX.Y-sp/fpm-pools.d/APPNAME.d/main.custom.conf

Next, edit the file and change the value on this line to the maximum number of PHP processes you want the app to be able to have running:

pm.max_children = 20

Last step , restart that PHP server version with the command:

sudo service phpX.Y-fpm-sp restart
//www.expertwebsolutionsinc.com/wp-content/uploads/2020/06/expertwebsoutions-bottom.png