How to fix Magento2 apis not working? fix coupon apis and other PUT OPTIONS APIs

The issue is actually related to your server’s configuration. By default all types of requests are not allowed. Please add the following to your .htaccess file

<Limit GET POST OPTIONS PUT DELETE PROPFIND>
    Order allow,deny
    Allow from all
    Require all granted
</Limit>

CSS Flashy button with glaze effect

.flashybtn
{
    display: block;
    text-align: center!important;
    text-decoration: none!important;
    font-weight: 800!important;
    font-size: 1.5em;
    text-transform: uppercase!important;
    color: #fff!important;
    padding: 1em 0.1em 1em 0.1em!important;
    background-size: 200% auto!important;
    box-shadow: 0 4px 6px rgba(50,50,93,.11),0 1px 3px rgba(0,0,0,.08)!important;
    background-image: linear-gradient(to right,#ff473d 0%,#ff379d 50%,#f13790 100%)!important;
    animation: gradient 1.5s ease infinite!important;
    width: 100%;
    position: relative; //change to fixed to make it sticky
    bottom: 0;
    left:0;
    z-index: 9999;
	}
.flashybtn:before {
    content: "";
    display: inline-block;
    position: absolute;
    background: rgb(255,255,255);
    width: 30px;
    height: 2em;
    left: 0;
    bottom: 0;
    filter: blur(1.5em);
    animation: 2s glaze infinite;
}
@keyframes glaze{
    from{
        transform: translateX(0) skewX(-15deg);
        opacity:1;
        }
    to {
        transform: translateX(100vw) skewX(-15deg);
        opacity:1;
       }
}

I am FLASHY

How to put a site in maintenance? [Apache web server]

ErrorDocument 403 /index.html
DirectoryIndex index.html
<Files ~ "index\.html">
	Order Allow,Deny
	Allow from all
</Files>
Deny from all

Content of your .htaccess file

If you want to whitelist any IP, use this

ErrorDocument 403 /index.html
DirectoryIndex index.html
<Files ~ "index\.html">
	Order Allow,Deny
	Allow from all
</Files>
Order Allow,Deny
Allow from xx.xxx.xx.xx
Deny from all

Here is a sample htaccess for a wordpress website with 1 IP whitelisted 4.129.45.44 and all others are banned. So you only will be able to load the website while everyone else will see contents of index.html with HTTP Status code 403

ErrorDocument 403 /index.html
DirectoryIndex index.php
<Files ~ "index\.html">
    Order Allow,Deny
    Allow from all
</Files>
RewriteEngine On
RewriteBase /
RewriteCond %{REMOTE_ADDR} !^4\.129\.45\.44$
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REMOTE_ADDR} !^4\.129\.45\.44$
RewriteRule . /index.php [L]

Allow from 4.129.45.44
Deny from all

How to generate a patch with edited files? How to zip latest committed changes only

zip archive.zip $(git diff-tree --no-commit-id --name-only -r latest-commit-id)

Reference: https://stackoverflow.com/a/42971972/2229148

sometimes you need all the files that were updated so you can patch an external app which doesnt uses same git project or many other scenarios in which we need a zip or tar of those files. Use the above command to do so

Basic Authentication in nginx for any domain, server or location block

sudo yum install httpd-tools
sudo htpasswd -c /etc/nginx/conf.d/vhosts/.htpasswd USERNAME
Enter Password: xxxxx
sudo chmod 644 /etc/nginx/conf.d/vhosts/.htpasswd

Update the domain.conf file like /etc/nginx/conf.d/vhosts/myrestricteddomain.com.ssl.conf

Ideally, use it in server config

server {
satisfy all; 
auth_basic "Restricted Area";
auth_basic_user_file /etc/nginx/conf.d/vhosts/.htpasswd; 
	location / {

Save and restart nginx

How to fix Invalid template file error in Magento2 after version upgrade?

This is a very common issue you will face if you using windows machine for development.

Usual error message is:

Invalid template file: '/vendor/magento/module-theme/view/frontend/templates/page/js/require_js.phtml' in module: '' block's name: 'require.js'

So whats the solution?

In case of windows, just replace this function isPathInDirectories in vendor/magento/framework/view/element/template/file/validator.php

protected function isPathInDirectories($path, $directories)
{
    $realPath = str_replace('\\', '/', $this->fileDriver->getRealPath($path));
    if (!is_array($directories)) {
        $directories = (array)$directories;
    }

    foreach ($directories as $directory) {
        if (0 === strpos($realPath, $directory)) {
            return true;
        }
    }
    return false;
}

Reference:

https://magento.stackexchange.com/a/255585/32283

How to update customer password in Magento 2 database?

UPDATE `customer_entity`
SET `password_hash` = CONCAT(SHA2('SaltPASSWORD', 256), ':SALT:1')
WHERE `entity_id` = 7615;

Please note that if SPJ9WIp7 is the salt and User’s password is 7qLzX33ETxYE, the following will be your query:

UPDATE `customer_entity`
SET `password_hash` = CONCAT(SHA2('SPJ9WIp77qLzX33ETxYE', 256), ':SPJ9WIp7:1')
WHERE `entity_id` = 7615;

7615 is the customer id

How to export multiple selected tables in PMA phpmyadmin (but not all tables)

Click on export, and choose “custom” export method.

Lets say you want to export first 20 tables only.

Open chrome or browser console [ctrl+shift+j], enter the following:

$("input[name='table_data[]']").slice(0,20).click();


For next 20, use 20,50 as arguments in slice function used above.

Where are customizer settings stored in db for wordpress theme?

How to clone customizer settings in child theme from parent theme?

The customizer data is stored in table wp_options under option_name theme_mods_THEME-NAME

you can view all such settings via the following query:

SELECT * FROM `wp_options` WHERE `option_name` LIKE "theme_mods_%"

In some cases, you just want to use parent theme’s settings in newly added child theme. If that is your case too, use the following queries to utilize and close those settings for your child theme also.

update `wp_options` set `option_name`="theme_mods_YOURCHILDTHEME_backup" where `option_name`="theme_mods_YOURCHILDTHEME";
insert into `wp_options` (`option_name`,`option_value`,`autoload`) select "theme_mods_YOURCHILDTHEME",`option_value`,"yes" from `wp_options` where `option_name`="theme_mods_PARENTTHEME";

The following one is a bit risky one. If you understand what is going on here, go ahead.

delete from `wp_options` where `option_name`="theme_mods_YOURCHILDTHEME";
insert into `wp_options` (`option_name`,`option_value`,`autoload`) select "theme_mods_YOURCHILDTHEME",`option_value`,"yes" from `wp_options` where `option_name`="theme_mods_PARENTTHEME";