Remove new duplicates from any sql table

DELETE FROM yourTable WHERE id NOT IN (SELECT MIN(id) FROM yourTable GROUP BY anotherColumn) If you want to remove older rows, use the following: DELETE FROM yourTable WHERE id NOT IN (SELECT MAX(id) FROM yourTable GROUP BY anotherColumn)

July 28, 2021 · 1 min · Harshvardhan Malpani

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

July 26, 2021 · 1 min · Harshvardhan Malpani

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

June 12, 2021 · 1 min · Harshvardhan Malpani

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.

May 25, 2021 · 1 min · Harshvardhan Malpani

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. ...

May 6, 2021 · 1 min · Harshvardhan Malpani

prevent sticky header jumping in css or js

jQuery(document).ready(function(){var header=jQuery("header .fusion-header");var headerHeight=0; var shouldWrite=1; jQuery(window).on("scroll",function(){ headerHeight=header.height(); console.log(headerHeight); if(shouldWrite && headerHeight!==undefined){ jQuery("#headerjumpfixer").html(".fusion-header-wrapper.fusion-is-sticky{padding-top:"+headerHeight + "px}"); shouldWrite=0;} }); jQuery(window).on("resize",function(){shouldWrite=1;}); }); <style id="headerjumpfixer">.fusion-header-wrapper.fusion-is-sticky{padding-top:88px}</style>

April 12, 2021 · 1 min · Harshvardhan Malpani

Installing a testing instance for Magento CLI only

Prerequisite: Magento repo access keys Mysql Database, username and password a domain name pointing to a server if you dont have access key, get a pair here : https://marketplace.magento.com/customer/accessKeys/\ php -d memory_limit=-1 /bin/composer create-project --repository-url=https://repo.magento.com/ magento/project-community-edition=2.2.11 ./ In the above command, you can change version/subversion of magento repo. You can also change the install directory After the successful run of above command:\ bin/magento setup:install \ --base-url=https://testmagento.domain.com \ --db-host=localhost \ --db-name=testmage_x1 \ --db-user=testmage_x1 \ --db-password=WEux3dxxxxw \ --admin-firstname=xxx \ --admin-lastname=yyy \ [email protected] \ --admin-user=admin \ --admin-password=WwKhxxxxxxEK \ --language=en_US \ --currency=USD \ --timezone=America/Chicago \ --use-rewrites=1 YOu will see Magento Admin URI: /admin_10lf7y after successful run ...

February 4, 2021 · 1 min · Harshvardhan Malpani

Basic Authentication with Nginx with proxy port (react/node app etc)

Reference:https://docs.nginx.com/nginx/admin-guide/security-controls/configuring-http-basic-authentication/ Requirements: apache2-utils or httpd-tools Use htpasswd utility and create a .htpasswd file, see reference\ htpasswd -c /etc/nginx/.htpasswd usernamethatyouwant chmod 644 /etc/nginx/.htpasswd After that, just add lines in nginx conf 1 2 3 4 5 6 7 8 9 10 location / { auth_basic "Backend Area"; auth_basic_user_file /etc/nginx/.htpasswd; ## path to your passwd file ## ... ## xyz code ##... proxy_pass http://127.0.0.1:4000; ## Proxy port for your app proxy_set_header Authorization ""; ## DONT FORGET THIS. reset the auth header include proxy.inc; } Restart nginx now or test first using “nginx -t”

January 22, 2021 · 1 min · Harshvardhan Malpani

Fixing broken “screen options” in wordpress site

SELECT * from wp_usermeta where `meta_key` like 'edit_%_per_page' So probably you chose “Number of items per page” as 1000 or 200 and now the page doesnt load anymore because your database ran out of memory. If that is the case, run the above query on phpmysql or any other way, edit the numbers and fixed!

January 18, 2021 · 1 min · Harshvardhan Malpani

How to limit ajax apis for your origins (Access-Control-Allow-Origin headers)

$allowed_domains = ["https://www.YOURDOMAIN.com","https://YOURDOMAIN.com","https://staging.YOURDOMAIN.com","https://www.YOURDOMAIN.com/","https://YOURDOMAIN.com/","https://staging.YOURDOMAIN.com/"]; // echo $_SERVER['HTTP_ORIGIN']; if (in_array($_SERVER['HTTP_ORIGIN'], $allowed_domains)) { header('Access-Control-Allow-Origin: ' . $_SERVER['HTTP_ORIGIN']); } else{ if(in_array($_SERVER['HTTP_REFERER'], $allowed_domains)){ header('Access-Control-Allow-Origin: ' . $_SERVER['HTTP_REFERER']); } }

December 11, 2020 · 1 min · Harshvardhan Malpani