How to install Magento 2 via Commnad line interface(CLI)?

In Magento 2, We can install Magento with different techniques. Like, Via Command Line, Using the Websetup wizard.

For installation with CLI, you just need to run below command, from your Magento instance path,

Before installation through CLI, You just need to set the following commands in the order shown to set permission:

cd /var/www/html/{Magento_Package}

find var vendor pub/static pub/media app/etc -type f -exec chmod u+w {} \; && find var vendor pub/static pub/media app/etc -type d -exec chmod u+w {} \; && chmod u+x bin/magento

Now run the command below,

php bin/magento setup:install --base-url=http://127.0.0.1/magento2/ --db-host=localhost --db-name=graphql --db-user=root --db-password=root --admin-firstname=Rakesh --admin-lastname=Jesadiya --admin-email=user@example.com --admin-user=admin --admin-password=admin123 --language=en_US --currency=USD --timezone=America/Chicago --use-rewrites=1

base-url is your URL of Magento 2 site
db-host is your hostname of database
db-name is your database name
db-user is your database username
db-password is your database password
admin-firstname is your admin user firstname
admin-lastname is your admin user lastname
admin-email is your email id of admin user
admin-user is your username for adminpanel
admin-password is your password for adminpanel
currency is your currency value like, USD,GBP,INR
language is your language like en_US,en_GB,nl_NL
timezone is your timezone of sites like America/Chicago or any.

How to set page title in Magento 2?

In Magento 2, We can set page titles using Controller as well as Using XML.

I have given examples for setting page titles using Controller and XML Way.

Using Controller,

public function execute() {
    $title = __('Page Title Name');
    $this->_view->getPage()->getConfig()->getTitle()->prepend($title);
}

Using Controller, You can set the title by just calling line  $this->_view->getPage()->getConfig()->getTitle()->prepend(‘title name’)

Using XML,

<head>
    <title>title name of page</title>
</head>

Using XML you can set your page title by <title> tag in <head> section.

Magento 2 display out of stock products at the end of the list page.

You can display out of stock product at end of catalog page in Magento 2 using just simple way. All the Out of stock product will be displayed at end of listing page.

You need to create module for display out of stock product at end of the page.

Create registration.php and module.xml file for creating a module. I hope you have created both file for define module,

For Collection of product generate from Magento\CatalogSearch\Model\ResourceModel\Fulltext\Collection file. We need to create a plugin for load() function. we need to set our custom condition for out of stock product to beforeLoad() function.

Create a di.xml file,

Path, app/code/Rbj/OutOfStock/etc/di.xml

<?xml version="1.0"?>
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:ObjectManager/etc/config.xsd">
    <!--  out of stock product at end of list -->
    <type name="Magento\CatalogSearch\Model\ResourceModel\Fulltext\Collection">
        <plugin name="Rbj_OutOfStock::OutofstockEnd" type="Rbj\OutOfStock\Plugin\Product\ProductList\Toolbar"/>
    </type>
</config>

Need to override Stock.php file from Magento\CatalogInventory\Helper\Stock class.

Create Toolbar.php file, File Path, app/code/Rbj/OutOfStock/Plugin/Product/ProductList/Toolbar.php

<?php
/**
 * @author Rakesh Jesadiya
 * @package Rbj_OutOfStock
 */

namespace Rbj\OutOfStock\Plugin\Product\ProductList;

class Toolbar
{
    /**
     * @param \Magento\CatalogSearch\Model\ResourceModel\Fulltext\Collection $subject
     * @param bool $printQuery
     * @param bool $logQuery
     * @return array
     */
    public function beforeLoad(\Magento\CatalogSearch\Model\ResourceModel\Fulltext\Collection $subject, $printQuery = false, $logQuery = false)
    {
        $orderBy = $subject->getSelect()->getPart(\Zend_Db_Select::ORDER);
        $outOfStockOrderBy = array('is_salable DESC');
        /* reset default product collection filter */
        $subject->getSelect()->reset(\Zend_Db_Select::ORDER);
        $subject->getSelect()->order($outOfStockOrderBy);

        return [$printQuery, $logQuery];
    }
}

Clear Cache and Check in front. All the Out of stock product will display at end of listing page.