How to wipe all the tables and data in MySQL? Clean whole database

SET FOREIGN_KEY_CHECKS = 0;
SET GROUP_CONCAT_MAX_LEN=32768;
SET @tables = NULL;
SELECT GROUP_CONCAT('`', table_name, '`') INTO @tables
  FROM information_schema.tables
  WHERE table_schema = (SELECT DATABASE());
SELECT IFNULL(@tables,'dummy') INTO @tables;
 
SET @tables = CONCAT('DROP TABLE IF EXISTS ', @tables);
PREPARE stmt FROM @tables;
EXECUTE stmt;
DEALLOCATE PREPARE stmt;
SET FOREIGN_KEY_CHECKS = 1;

Will not work via phpmyadmin or any script. this has to be run in cmd/terminal

Quick Command

wget https://gist.githubusercontent.com/harshvardhanmalpani/e670a8de7aa81673364dd48f125cb9ac/raw/ce04b319bf1594d148d3346e1474119fe1cd1b3f/flushdb.sql

mysql -hYOUR_DATABASE_HOSTNAME -uYOUR_DATABASE_USER -p YOUR_DATABASE_NAME < flushdb.sql

Source:
https://gist.github.com/harshvardhanmalpani/e670a8de7aa81673364dd48f125cb9ac

How to remove sign in popup from Magento 2 checkout page?

Magento2 has this authentication pop up on checkout page, which many store owners wont like to see on their checkout page.

Background of this pop up area and Related files

The pop up itself is generated by Magento_Customer::account/authentication-popup.phtml

But this pop up works very differently on checkout page. In fact this is a separate pop up than the one you see in header area. It is embedded in a series of js files which are governed by knockout-js

Other file responsible is: vendor/magento/module-checkout/view/frontend/web/js/proceed-to-checkout.js

Here is how to remove it finally

Edit file or overload the file

app/design/frontend/YourVendor/YourTheme/Magento_Checkout/web/template/onepage.html

delete the following lines and save the file

<!-- ko foreach: getRegion('authentication') -->
<!-- ko template: getTemplate() --><!-- /ko -->
<!--/ko-->

Reference:

https://github.com/magento/magento2/blob/2.2/app/code/Magento/Checkout/view/frontend/web/template/onepage.html

https://github.com/magento/magento2/blob/fc66fe443d87c4e69fe9022d7c95fe66e0565978/app/code/Magento/Checkout/view/frontend/layout/checkout_index_index.xml#L39

How to show correct item count in Magento 2 Checkout Order summary?

By default, app/design/Magento/Checkout/view/frontend/web/template/summary/cart-items.html file is being used
Or vendor/magento/module-checkout/view/frontend/web/template/summary/cart-items.html

To overload this file, create file cart-items.html in your theme folder. Make sure you place the file in Magento_Checkout/web/template/summary/

Edit the line

<span data-bind="text: getCartLineItemsCount()"></span>

And replace it with

<span data-bind="text: getItemsQty()"></span>

Reference Files:

vendor/magento/module-checkout/view/frontend/web/js/view/summary/cart-items.js

https://github.com/magento/magento2/blob/2.2/app/code/Magento/Checkout/view/frontend/web/template/summary/cart-items.html

https://github.com/magento/magento2/blob/2.2/app/code/Magento/Checkout/view/frontend/web/js/view/summary/cart-items.js

How to dump all options for any attribute in Magento 2 programmatically?

The following code does not adhere to Magento’s developer recommendations. Using object manager in such a way externally is a TERRIBLE idea.

Comment out line number 2 and then run the script. Edit line 11 and put the attribute code you want to dump

<?php
header("Location: /");exit;
use \Magento\Framework\App\Bootstrap;
error_reporting(E_ALL);
ini_set("display_errors", 1);
include('./app/bootstrap.php');
$bootstrap     = Bootstrap::create(BP, $_SERVER);
$objectManager = $bootstrap->getObjectManager();

$eavConfig = $objectManager->get('\Magento\Eav\Model\Config');
$attribute = $eavConfig->getAttribute('catalog_product', 'manufacturer');
$options   = $attribute->getSource()->getAllOptions();
$options   = array_slice($options, 1);
usort($options, function($a, $b)
{
    return strcasecmp($a['label'], $b['label']);
});
if (count($options))
    $v = "<table>";
foreach ($options as $option) {
    $v .= "<tr><td>" . $option['value'] . '</td><td>' . $option['label'] . '</td></tr>';
}
if (count($options))
    $v .= "</table>";
echo $v;
?>
   <style>
    table tr:nth-child(odd){background:#444;color:#fff}
   </style>

How to customize Magento 2 Maintenance mode page?

Edit the file pub/errors/default/503.phtml and put the following code

<?php
/**
 * How to edit and customize code of Magento 2 Maintenance 503 Page
 * Add analytics if any
 * Replace <COMPANY NAME> with your Organization Name
 */
?>
<!doctype html>
<title>Site Maintenance</title>
<style>
  body { text-align: center; padding: 150px; }
  h1 { font-size: 50px; }
  body { font: 20px Helvetica, sans-serif; color: #333; }
  article { display: block; text-align: left; width: 650px; margin: 0 auto; }
  a { color: #dc8100; text-decoration: none; }
  a:hover { color: #333; text-decoration: none; }
</style>

<article>
    <h1>We&rsquo;ll be back soon!</h1>
    <div>
        <p>Sorry for the inconvenience but we&rsquo;re performing some maintenance at the moment. If you need to you can always <a href="mailto:abcd@COMPANY NAME">contact us</a>, otherwise we&rsquo;ll be back online shortly!</p>
        <p>&mdash; Team COMPANY NAME</p>
    </div>
</article>

How to hide a specific category from Google Index in Magento 2?

In Magento Admin Panel, Go to Catalog in Left Menu > Categories
Select the category you want to edit and in Design Section > Layout Update XML, put this value:

<head>
    <meta name="robots" content="NOINDEX,NOFOLLOW"/>
</head>
How to add noindex nofollow on specific category page in Magento2

Save the category and then Clear the cache

Top CMS out there in 2018.

CMS:

A content management system is a software that helps us to manage our content and site.

You can literally manage everything from a blog to an e-commerce site, using CMS. You can manage an article if you have a blog, or manage your product if it is an e-commerce business.

It has made our life so easier that we just can’t imagine having a site without CMS. You can operate most CMS out there even if you have no prior technical knowledge.

Today we are going to talk about the top CMS in 2018, there features, flexibility and specifications because that’s what they are known for.

So, without any further delay let’s begin.

Top CMS:

  1. WordPress: This one goes without saying. Probably the best one out there. WordPress can make almost any kind of site either it is a blog, a real state site or an e-commerce. It can make anything under the sun. WordPress is the framework behind many of the websites and blogs you visit every day, including this one. .org Few of the key features are responsive design, social sharing features, multiple page styles, auto upgrade, and standard compliant coding. The one thing that makes it a CMS beast is plugins.
  2. Joomla: Joomla is a popular Content Management System. It is much more than just a powerful content management system. Besides, hundreds of extensions to enhance the functionality of any Joomla website, Joomla itself includes some powerful built-in features (or core features). Many times ranked as the 2nd best CMS after WP. zoomla Few key features are Rss, media manager, web links, search, banner management and, user management.
  3. Drupal: Drupal 8 takes an already terrific content management framework to ever greater heights for users, administrators, and developers. There’s a seriously sharp focus on user-friendliness, but the content presentation, new ways to create data structures, build APIs, multilingual capabilities, and the delivery of mobile accessibility out of the box? Drupal 8 brings those to the table too.  Few of the features are mobile first, multilingual ready, loading speed, javascript automated testing.
  4. Magento: Specific to make an e-commerce site. The large array of features is one of the main benefits of Magento. Through them, you can easily develop and manage a successful online store. Magento features like different payment engines and shipping options along with the international support and high security using an  SSL certificate will make your shop an attractive place for e-commerce.  The core features are checkout payment and shipping, analytics and reporting, marketing and promotional tools, and order management.
  5. OpenCart: OpenCart is an open-source shopping cart built on PHP/MySQL code. Distributed as a free eCommerce solution, OpenCart is a very user-friendly and effective platform that comes with a very intuitive and well-designed user-interface as well as a higher selection of extensions. Perfect for small businesses and medium-sized e-commerce stores, OpenCart is loaded with all the basic functions a user would need from an e-commerce solution.  Main features are, Product Reviews, Product Ratings, open source, multi-currency, automated image resize, 20+ payment gateways, and 8+ shipping methods.

One honorable mention is WIX. Very user-friendly having drag and drop interface.

SO, these were the top of 2018 CMS. You should choose one according to your needs.  Keep visiting for such more articles.

Thank You.

How to change PHP versions in VestaCP Ubuntu – Downgrade Upgrade 5.6, 7.1 and 7.2

For Downgrading 7.2 (default) to 7.1 PHP

sudo add-apt-repository ppa:ondrej/php
sudo apt-get update
sudo apt-get install libapache2-mod-php7.1 php7.1 php7.1-bcmath php7.1-bz2 php7.1-cgi php7.1-cli php7.1-common php7.1-curl php7.1-dba php7.1-dev php7.1-enchant php7.1-fpm php7.1-gd php7.1-gmp php7.1-imap php7.1-interbase php7.1-intl php7.1-json php7.1-ldap php7.1-mbstring php7.1-mcrypt php7.1-mysql php7.1-odbc php7.1-opcache php7.1-pgsql php7.1-phpdbg php7.1-pspell php7.1-readline php7.1-recode php7.1-snmp php7.1-soap php7.1-sqlite3 php7.1-sybase php7.1-tidy php7.1-xml php7.1-xmlrpc php7.1-xsl php7.1-zip
sudo a2dismod php7.2
sudo a2enmod php7.1
sudo service apache2 restart
sudo update-alternatives --set php /usr/bin/php7.1

Reference: Sandy B @ mysterydata.com

Fix Magento 2 – php cli error on cpanel or other hostings

The problem:

On a fresh install of Magento2 on cpanel based hosting, you receive the following error while running any command on SSH

[eee@e1 www]$ php bin/magento cache:clean
X-Powered-By: PHP/7.0.31
Content-type: text/html; charset=UTF-8

bin/magento must be run as a CLI application
[eee@e1 www]$ php bin/magento setup:upgrade
X-Powered-By: PHP/7.0.31
Content-type: text/html; charset=UTF-8

bin/magento must be run as a CLI application

The Solution:

You have to point php to correct binary;
Use the following code in order:
First, open the file which can alter the runtime variables like .bash_profile or .bashrc

cd ~ ; nano .bash_profile
OR
cd ~ ;nano .bashrc

Go to last line and paste this (depending upon php version change ea-php71 or ea-php70):

alias php='/opt/cpanel/ea-php71/root/usr/bin/php'

Save the file and exit the editor.
Log out and login again OR use the following command

$ source ~/.bashrc

If you are not sure about current php version, use which php or php -v command. If you think the cpanel configuration is the issue, fix EasyApache 4 PHP cli issue. With this way you can fix the setting and enable the new php version