How to change attribute dropdown type to multi-select in Magento 2?

Short Answer:

Not possible via Magento2 Admin Backend.

Solution:

You need to update eav_attribute table and edit information about backend_source, frontend_input etc.

Simple query for that is:

UPDATE `eav_attribute` SET `backend_model`="Magento\\\Eav\\\Model\\\Entity\\\Attribute\\\Backend\\\ArrayBackend", `backend_type`="varchar", `frontend_input`="multiselect", `source_model`=NULL WHERE `attribute_id`=YOUR_ATTRIBUTE_ID_INTEGER LIMIT 1

Replace YOUR_ATTRIBUTE_ID_INTEGER with your attribute_id like 355

Reference:

https://stackoverflow.com/a/57701845/2229148

How to disable products in Magento2 which dont have any gallery image?

UPDATE `catalog_product_entity_int` SET `value`=2 where `entity_id` in (SELECT a.`entity_id` FROM `catalog_product_entity` AS a LEFT JOIN `catalog_product_entity_media_gallery_value` AS b ON a.entity_id = b.entity_id LEFT JOIN `catalog_product_entity_media_gallery` AS c ON b.value_id = c.value_id WHERE c.value IS NULL) and `attribute_id` = 96

It is SQL query

Assumption:

value=2 means disable and value=1 means enable

attribute_id=96 means “status” attribute

References:

https://gist.github.com/tegansnyder/8464261#gistcomment-2910808

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

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

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.

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

Magento 2 cli commands [continued]

1. Setting GD2 as defualt image adapter from command line 

Magento >= 2.2
php bin/magento config:set dev/image/default_adapter GD2
php bin/magento cache:clean
Magento >= 2.2
 mysql --host=(host) --user=(user) --password=(password) -D (database) -e "\ UPDATE core_config_data SET value = 'GD2' WHERE 'dev/image/default_adapter' = path; \"; 

 2. Disable Minify CSS Files option from command line

Magento >= 2.2
php bin/magento config:set dev/css/minify_files 0
php bin/magento cache:clean
Magento < 2.2
mysql --host= --user= --password= -D  -e "\ UPDATE core_config_data SET value = 0 WHERE 'dev/css/minify_files' = path; \";
php bin/magento cache:clean

3. Disable Merge CSS Files option from command line

 

php bin/magento config:set dev/css/merge_css_files 0
php bin/magento cache:clean
Magento < 2.2
mysql --host= --user= --password= -D  -e "\ UPDATE core_config_data SET value = 0 WHERE 'dev/css/merge_css_files' = path; \";
php bin/magento cache:clean

How to install theme in Magento 2

Download the theme and copy the app folder and paste it in your magento root directory

  1. Open Shell, in the root directory, enter php bin/magento  setup:upgrade . This will upgrade all the magento files.

2. Also, Clear cache ,type  php bin/magento  cache:clean . 

3. Now force deploy the static files by typing  php bin/magento  setup:static-content:deploy -f . It will take a while.

4. Now, Go in the dashboard and select content->configuration.

5. Select the option with default store view and edit.

6. Select your theme from the options and click save and edit. If some problem arises, go to the vendor/magento/module-email/Model/AbstractTemplate.php and comment the “if”  condition of “setForcedArea” function, aprox. at line 535.

7. After changing theme successfully, clear the cache as done before.

Voila, the theme is changed!!

 

 

Magento 2 all cli commands

[~/www]# php bin/magento list
Magento CLI version 2.2.4

Usage:
  command [options] [arguments]

Options:
  -h, --help            Display this help message
  -q, --quiet           Do not output any message
  -V, --version         Display this application version
      --ansi            Force ANSI output
      --no-ansi         Disable ANSI output
  -n, --no-interaction  Do not ask any interactive question
  -v|vv|vvv, --verbose  Increase the verbosity of messages: 1 for normal output, 2 for more verbose output and 3 for debug

Available commands:
  help                                     Displays help for a command
  list                                     Lists commands
 admin
  admin:user:create                        Creates an administrator
  admin:user:unlock                        Unlock Admin Account
 app
  app:config:dump                          Create dump of application
  app:config:import                        Import data from shared configuration files to appropriate data storage
 cache
  cache:clean                              Cleans cache type(s)
  cache:disable                            Disables cache type(s)
  cache:enable                             Enables cache type(s)
  cache:flush                              Flushes cache storage used by cache type(s)
  cache:status                             Checks cache status
 catalog
  catalog:images:resize                    Creates resized product images
  catalog:product:attributes:cleanup       Removes unused product attributes.
 config
  config:sensitive:set                     Set sensitive configuration values
  config:set                               Change system configuration
  config:show                              Shows configuration value for given path. If path is not specified, all saved values will be shown
 cron
  cron:install                             Generates and installs crontab for current user
  cron:remove                              Removes tasks from crontab
  cron:run                                 Runs jobs by schedule
 customer
  customer:hash:upgrade                    Upgrade customer's hash according to the latest algorithm
 deploy
  deploy:mode:set                          Set application mode.
  deploy:mode:show                         Displays current application mode.
 dev
  dev:di:info                              Provides information on Dependency Injection configuration for the Command.
  dev:profiler:disable                     Disable the profiler.
  dev:profiler:enable                      Enable the profiler.
  dev:query-log:disable                    Disable DB query logging
  dev:query-log:enable                     Enable DB query logging
  dev:source-theme:deploy                  Collects and publishes source files for theme.
  dev:template-hints:disable               Disable frontend template hints. A cache flush might be required.
  dev:template-hints:enable                Enable frontend template hints. A cache flush might be required.
  dev:tests:run                            Runs tests
  dev:urn-catalog:generate                 Generates the catalog of URNs to *.xsd mappings for the IDE to highlight xml.
  dev:xml:convert                          Converts XML file using XSL style sheets
 i18n
  i18n:collect-phrases                     Discovers phrases in the codebase
  i18n:pack                                Saves language package
  i18n:uninstall                           Uninstalls language packages
 import
  import:categories                        Run category importer script
 indexer
  indexer:info                             Shows allowed Indexers
  indexer:reindex                          Reindexes Data
  indexer:reset                            Resets indexer status to invalid
  indexer:set-mode                         Sets index mode type
  indexer:show-mode                        Shows Index Mode
  indexer:status                           Shows status of Indexer
 info
  info:adminuri                            Displays the Magento Admin URI
  info:backups:list                        Prints list of available backup files
  info:currency:list                       Displays the list of available currencies
  info:dependencies:show-framework         Shows number of dependencies on Magento framework
  info:dependencies:show-modules           Shows number of dependencies between modules
  info:dependencies:show-modules-circular  Shows number of circular dependencies between modules
  info:language:list                       Displays the list of available language locales
  info:timezone:list                       Displays the list of available timezones
 maintenance
  maintenance:allow-ips                    Sets maintenance mode exempt IPs
  maintenance:disable                      Disables maintenance mode
  maintenance:enable                       Enables maintenance mode
  maintenance:status                       Displays maintenance mode status
 module
  module:disable                           Disables specified modules
  module:enable                            Enables specified modules
  module:status                            Displays status of modules
  module:uninstall                         Uninstalls modules installed by composer
 sampledata
  sampledata:deploy                        Deploy sample data modules
  sampledata:remove                        Remove all sample data packages from composer.json
 setup
  setup:backup                             Takes backup of Magento Application code base, media and database
  setup:config:set                         Creates or modifies the deployment configuration
  setup:cron:run                           Runs cron job scheduled for setup application
  setup:db-data:upgrade                    Installs and upgrades data in the DB
  setup:db-schema:upgrade                  Installs and upgrades the DB schema
  setup:db:status                          Checks if DB schema or data requires upgrade
  setup:di:compile                         Generates DI configuration and all missing classes that can be auto-generated
  setup:install                            Installs the Magento application
  setup:performance:generate-fixtures      Generates fixtures
  setup:rollback                           Rolls back Magento Application codebase, media and database
  setup:static-content:deploy              Deploys static view files
  setup:store-config:set                   Installs the store configuration. Deprecated since 2.2.0. Use config:set instead
  setup:uninstall                          Uninstalls the Magento application
  setup:upgrade                            Upgrades the Magento application, DB data, and schema
 store
  store:list                               Displays the list of stores
  store:website:list                       Displays the list of websites
 theme
  theme:uninstall                          Uninstalls theme
 varnish
  varnish:vcl:generate                     Generates Varnish VCL and echos it to the command line

Magento File Directory

/app
The etc folder contains the di.xml configuration file
The di.xml file contains class mapping and interface preferences
Contains the design folder for themes.

/bin
The directory contains the magento file or a Command Line Interface script

/dev
Magento 2 testing and development tools are placed in this folder.

/lib
The internal and web subfolders are located here
The internal directory contains server-side libraries and several font files;
The web subfolder contains client-side libraries, jquery, modernizr, requirejs, prototype, scriptaculous

/pub
It should be set as your web root on the server
It contains all the publicly accessible files
index.php controller is also contained in the folder
pub also contains the error pages that will be displayed if your site is showing a 404 or 503 or another report page
Image uploads and imports will appear somewhere within pub/media.

/var
caches and generated classes are all located in the folder
the var folder includes cache, composer_home, generation, log, di, view_preprocessed, page_cache files

/vendor
the folder includes various packages that have been defined under composer.json
Marketplace modules and the core modules are all under vendor.
If you download something from the new Magento Marketplace.