Warning: "continue" targeting switch is equivalent to "break". Did you mean to use "continue 2"? in /home/elitedm1/mageclinics.com/vendor/zendframework/zend-stdlib/src/ArrayObject.php on line 426
System Administrator

System Administrator

  1. Magento2 Installation

    Install Magento2

    • 1st way:

    Install by downloading source code from git repo or Magento download page.

    Download source and run from browser or using the command line.

    • 2nd way(Recommended and best):

    Using composer. follow below step for it

    1. Install composer if not installed yet. you can check it by below command

    composer --help

    if it shows result that means composer is there. if not display result or display error install it by following the way

    a. run below command from terminal

    curl -sS https://getcomposer.org/installer | php
    mv composer.phar /usr/local/bin/composer

    b. Make your composer global

    mv composer.phar /usr/local/bin/composer

    2. Run below command to install Magento community latest version

    composer create-project --repository-url=https://repo.magento.com/ magento/project-community-edition .


    3. Setup proper file and folder permission

    find . -type d -exec chmod 700 {} \; && find . -type f -exec chmod 600 {} \;


    4. create database using command or directly from phpmyadmin
    5. Run below command with proper data filled

    php bin/magento setup:install
    --base-url="http://demo.com/"
    --db-host="localhost"
    --db-name="dbname"
    --db-user="root"
    --db-password="1234"
    --admin-firstname="admin"
    --admin-lastname="admin"
    --admin-email="user@example.com"
    --admin-user="admin"
    --admin-password="admin123"
    --language="en_US"
    --currency="USD"
    --timezone="America/Chicago"
    --use-rewrites="1"
    --backend-frontname="admin"


    6. Install sample data

    Run below command

    php bin/magento sampledata:deploy

    Problem:

    CSS and Js is not loading after installation of fresh Magento

    Enable rewrite using below command

    a2enmod rewrite

    And Open /etc/apache2/apache2.conf

     

    Find <Directory /var/www/>

    Replace rules inside with below rules.


    <Directory /var/www/>
    Options Indexes FollowSymLinks
    AllowOverride All
    Require all granted

    </Directory>

    Read more »
  2. Magento Flat Catalog

    Magento2 Flat Catalog


    Magento stores catalog data in multiple tables, based on the Entity-Attribute-Value (EAV) model. Because product attributes are stored in many tables, SQL queries are sometimes long and complex for fetching different data from different tables.


    Whereas a flat catalog creates new tables and fills data during indexing, where each row contains all the necessary data about a product or category. A flat catalog is updated automatically‚ÄĒeither every minute or according to your cron job for index management. Flat catalog indexing can also speed up the processing of catalog and cart price rules. A catalog with as many as 50k+ SKUs can be indexed quickly as a flat catalog.
    Please note this is best practice for lower magento2 version or Magento1 version but from Magento2.3.0 it's not best practice to use flat tables for catalog.
    From version Magento 2.3.0 and higher, the use of a flat catalog is no longer a best practice and is not recommended. Use of flat table will decrease performance and create an issue for index management and other performance issues due to the indexing problem.

    How to Enable the Flat Catalog?


    On the Admin sidebar, click on Stores. Then under Settings, click on Configuration.
    In the panel on the left under Catalog, choose Catalog.
    Click on the Storefront section. Then, do the following:


    Set Use Flat Catalog Category to Yes. If necessary, clear the Use system value checkbox.
    Set Use Flat Catalog Product to Yes.

    Flat Catalog Configuration


    When complete, tap  Save Config.
    Refresh cache and run indexing.

    You need to make attribute to use in the product listing to use the attribute in flat tables

     

     

    Read more »
  3. Why should i migrate to Magento2?

    Magento announced they will stop support magento1 versions from June 2020. You can see more detail here.https://magento.com/blog/magento-news/supporting-magento-1-through-june-2020

    Apart from these. There are some other benefits which can help you to make the decision.

    1) Better Admin panel

    If you see magento2 store you will see a drastic change in the Magento admin theme. It's a really cool theme with all menu of left sides. They have included more features in grid and sorting. Admin user can add more rows in grid without having technical knowledge. They can also add a field for filtering.

    2) Performance

    The performance was a challenging issue in Magento1. In magento2 Magento team improved performance and they have used the latest technology. Magento2's page loading speed is far better than magento1.

    3) Testing Framework

    Magento2 include testing framework so after development you can create test cases to make sure your functionality work as expected. A developer can write a unit test and automize testing for their own work.

    4) Improved checkout

    Compare to Magento1's checkout Magento2's checkout is very simple and it has only 2 steps. More faster and flexible compare to magento1 that will help store owner to increase conversation rate.

    Read more »
  4. Custom CLI Command

    Magento2 Cli Command


    Today, We will create our custom module to add CLI Command. 
    First of all, you need to have basic knowledge of magento2 module. 
    We will create module : Mageclinics_Command


    1. Module Structure

    Our module structure will be like below.


    Basic module file

    app/code/Mageclinics/Command/registration.ph

    papp/code/Mageclinics/Command/etc/module.xml


    File for our CLI commands

    app/code/Mageclinics/Command/etc/di.xml

    app/code/Mageclinics/Command/Console/Hello.php

    2. Step 1: Command node in di.xml

    create di.xml file, Use a type with name Magento\Framework\Console\CommandList to define the command option.

    File: app/code/Mageclinics/Command/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"> 
     <type name="Magento\Framework\Console\CommandList"> 
         <arguments>         
      <argument name="commands" xsi:type="array">       
           <item name="hello" xsi:type="object">Mageclinics\Command\Console\Hello</item> 
              </argument> 
         </arguments>
       </type>
    </config>

    3. Create Console class file

    File: app/code/Mageclinics/Command/Console/Hello.php


    <?php
    namespace Mageclinics\Command\Console;

    use Symfony\Component\Console\Command\Command;
    use Symfony\Component\Console\Input\InputInterface;
    use Symfony\Component\Console\Output\OutputInterface;
    use Symfony\Component\Console\Input\InputOption;

    class Hello extends Command
    {

    const TEST = 'test';

    protected function configure()
    {
    $options = [ new InputOption( self::TEST, null, InputOption::VALUE_REQUIRED, 'Test' ) ];
    $this->setTest('example:hello')
    ->setDescription('Test command line')
    ->setDefinition($options);
    parent::configure();
    }
    protected function execute(InputInterface $input, OutputInterface $output)
    {
    if ($test = $input->getOption(self::TEST)) {
    $output->writeln("Hello " . $test);

    } else {
    $output->writeln("Hello World");
    }
    return $this;
    }
    }

    configure() : function will set the name, description, command line arguments of the Magento 2 add command line

    execute() : function will run when we run this command line via console.

    4. Run command.

    From Command line run php bin/magento list to see all available commands.
    And you will see example:hello in the list of commands.
    Once you run php bin/magento example:hello --test="John"
    The result will be Hello John

    Read more »