Tuesday 17 December 2019

Create simple tooltip html css

Preview



HTML
<span class="tooltipans" data-tooltip='All your leads will be saved to your Customers tab with a "My Sticky Elements" tag so you can easily find them'>?</span>
CSS

<style>
.tooltipans{
    position: relative;
    background: rgba(0,0,0,0.7);
    padding: 2px 7px;
    border-radius: 100%;
    font-size: 12px;
    cursor: help;
    color: #FFF;
}
.tooltipans::before, .tooltipans::after{
    position: absolute;
    left: 50%;
    opacity: 0;
    transition: allease0.3s;
}
.tooltipans::before{
    content: "";
    border-width: 10px 8px 08px;
    border-style: solid;
    border-color: rgba(0,0,0,0.3) transparent transparent transparent;
    top: -10px;
    margin-left: -8px;
}
.tooltipans::after{
    content: attr(data-tooltip);
    background: rgba(0,0,0,0.7);
    top: -10px;
    transform: translateY(-100%);
    font-size: 14px;
    margin-left: -150px;
    width: 300px;
    border-radius: 10px;
    color: #fff;
    padding: 14px;
}
.tooltipans:hover::before, .tooltipans:hover::after{
    opacity: 1;
}
</style>

Saturday 23 November 2019

How to add/update multiple products in cart in shopify

jQuery(function () {
   
jQuery('body').find(".couponproduct .gf_add-to-cart").click(function (e) {
e.preventDefault();
values = {}
                values[30370850865245] = 0;
                values[31289364840541] = 1;
                jQuery.ajax({
                      type: 'POST',
                      url: '/cart/update.js',
                      data: { updates: values},
                      dataType: 'json',
                      success: function() {
                        location.href = '/checkout';
                     }
               });
});
   
});

Saturday 16 November 2019

Create simple popup using HTML CSS



HTML

<div class="main-chaty-popup-bg"></div>
<div class="main-chaty-popup">
      <div class="main-chaty-box">
              <h4>Chaty is currently off</h4>
              <div class="popup-content">
                       <div class="popup-content-wrapper"> Chaty is currently turned off, would you like to save and show it on your site? </div>
              </div>
              <div class="popup-content-footer">
                      <button type="button" class="btn btn-primary">Yes, Show it on my site</button>
                      <button type="button" class="btn btn-default">Just save and keep it off</button>
              </div>
              <div class="modul-close-btn">
                       <a href="#"> X </a>
              </div>
        </div>
 </div>

CSS

<style type="text/css">
    .main-chaty-popup-bg {position: fixed;left: 0;top: 0;width: 100%;height: 100%;overflow: auto;background-color: #000; opacity: 0.5;z-index: 111;}
    .main-chaty-popup {margin:0;width: 100%;text-align: center;z-index: 1;}
    .main-chaty-box {margin: auto; padding: 0px; width: 660px; height: 170px; background: #FFF; position: fixed; top: 0; right: 0; left: 0; bottom: 0;z-index: 999;}
    .main-chaty-box h4 {background: #FCFCFC; margin: 0;padding: 10px 0 10px 10px;font-size: 22px;color: #626262;line-height: 22px;text-align: left;border-bottom: 1px solid #e5e5e5;}
    .modul-close-btn {position: absolute; right: 18px; top: 20px; transform: translate(50%, -50%); background: linear-gradient(0deg, #333, #333), linear-gradient(153.18deg, #6371DB 7.07%, #FF89C4 90.47%); border-radius: 50%; width: 22px; height: 22px; display: flex; align-items: center;justify-content: center;padding: 0; border: 0; z-index: 1; box-shadow: 0 4px 14px rgba(0, 0, 0, .15); cursor: pointer;}
    .popup-content-footer{position: absolute;bottom: 0; width: 100%; padding: 10px 0;border-top: 1px solid #e5e5e5;}
    .popup-content-footer .btn-primary{background:#00C67C;border: none;padding: 10px;color: #FFF;cursor: pointer;box-shadow: 1px 1px 2px 1px #000;border-radius: 5px;margin-right: 15px;}   
    .popup-content-footer .btn-default{background:#F7F7F7;border: none;padding: 10px;color: #655d5d;cursor: pointer;box-shadow: 1px 1px 2px 1px #000;border-radius: 5px;}
   .popup-content-wrapper{margin-top: 25px;}
 </style>

Friday 4 October 2019

Cannot add a new addondomain in WHM panel

(XID a57bw8) Sorry, the domain is already pointed to an IP address that does not appear to use DNS servers associated with this server. in WHM panel

Visit this area in WHM panel:

1. WebHost Manager »Server Configuration »Tweak Settings, Domains tab:

2. Enable the following setting


Saturday 28 September 2019

How to create/write code in text/json file and get content of file in PHP | Codeigniter

Create file and directory
public function createfileanddir() {
    $directoryname = 'directoryname';
    $filename = 1;
    $directory = APPPATH . 'uploads/cache/'.$directoryname;
    if (!file_exists($directory)) {
        mkdir($directory, 0777, true);
    }
    $file = APPPATH . 'uploads/cache/'.$directoryname.'/'.$filename.'.json';
    if (file_exists($file)) {
        unlink($file);
    }
    if (!file_exists($file)) {
        $settings = [
            'settings'=>[],
            'socialSettingsArr'=>[],
            'pageSettings'=>[],
        ];
        $fh = fopen($file, 'w');
        fwrite($fh, json_encode($settings));
        fclose($fh);
    }
}
Get content from file and directory
public function getfiles() {
    $directoryname = 'directoryname';
    $directory = 'uploads/cache/'.$directoryname;
    $files = array_diff(scandir($directory), array('.', '..'));
    if(count($files) > 0){
        foreach ($files as $file):
            $file = $directory . '/'.$file;
            $storedata = file_get_contents($file);
            $storedata = json_decode($storedata, true);
            echo '<pre>';print_r($storedata);
        endforeach;
    }
}

Friday 27 September 2019

Magento 2 Missing Table when transfer server Error "inventory_stock_1"

Error
Exception #0 (Zend_Db_Statement_Exception): SQLSTATE[42S02]: Base table or view not found: 1146 Table 'inventory_stock_1' doesn't exist, query was:........
Solution
1) Open your phpmyadmin
2) Remove your current "inventory_stock_1" if available
3) Run following query on sql
CREATE
SQL SECURITY INVOKER
VIEW `inventory_stock_1`
  AS
    SELECT
    DISTINCT 
      legacy_stock_status.product_id,
      legacy_stock_status.website_id,
      legacy_stock_status.stock_id,
      legacy_stock_status.qty quantity,
      legacy_stock_status.stock_status is_salable,
      product.sku
    FROM `cataloginventory_stock_status` `legacy_stock_status`
      INNER JOIN `catalog_product_entity` product
        ON legacy_stock_status.product_id = product.entity_id;

3) Reindex your store data then check your store.

Tuesday 24 September 2019

How to create pagination in shopify rest api using php

Shopify new API next page issue | page_info => invalid value

Shopify API version 2019-07 you do indeed need to use cursor-based pagination.

First make a normal API call, include the header response.

Then in the header response API, you will see the "link" parameter with rel next or previous.

Extract the page_info and then make another call with page_info.
The first API call is something like this:

https://.....@abc.myshopify.com/admin/api/2019-10/products.json?limit=2&published_status=published
To get header response from API response :
function getheaderarray($apiresponse){
       
        $data = explode("\n",$apiresponse);
        $headers['status'] = $data[0];
        array_shift($data);
        foreach($data as $part){
            $middle = explode(":",$part,2);
            if ( !isset($middle[1]) ) { $middle[1] = null; }
            $headers[trim($middle[0])] = trim($middle[1]);
        }
       
        return $headers;
  }  
Then the second API call is something like this:
https://.....@abc.myshopify.com/admin/api/2019-10/products.json?limit=2&page_info=abcdsf21asdf3afdfdfd1safd51s3f1x32ref4asdj
When you make the second call, do not add any filers as the filters will be applied from the first call.
FYI: if your testing in a browser due to the way the link is in angle brackets, it will be hidden, so just view source code in your developer environment.

Friday 20 September 2019

How to change root password of mysql

sudo service mysql stop
sudo mkdir -p /var/run/mysqld

sudo chown mysql:mysql /var/run/mysqldsudo /usr/sbin/mysqld --skip-grant-tables --skip-networking &
mysql -u rootmysql> FLUSH PRIVILEGES;
mysql> USE mysql;mysql> UPDATE user SET authentication_string=PASSWORD("<Your Password>") WHERE User='root';mysql> UPDATE user SET plugin="mysql_native_password" WHERE User='root';
mysql> exit
sudo pkill mysqldsudo service mysql start

Saturday 14 September 2019

Simple zoom effect with mouse hover with HTML, CSS and JS

Preview



HTML
<div class="gallery-placeholder">
    <div class="fotorama__stage__frame fotorama__active">
        <img class="fotorama__img" src="<?php echo 'https://kansagra/jaydip/jaydip.jpg'; ?>" >
    </div>
</div>
<div class="gallery-popup fixed-full-popup-model">
    <div class="gallery-zoom-img">
        <div class="gallery-main-img" style=""></div>
    </div>
</div>
CSS
<style>
.gallery-popup {
    cursor: url(../images/zoom-out.svg),pointer;
}
body .gallery-placeholder .fotorama__stage__frame.fotorama__active .fotorama__img {
    cursor: url(../images/zoom-in.svg),pointer;
}
.gallery-popup .gallery-zoom-img .gallery-main-img {
    width: 100%;
    height: 100vh;
    background-position: 0 0;
    background-repeat: no-repeat;
    background-size: cover;
}
.fixed-full-popup-model {
    position: fixed;
    top: 0;
    left: 0;
    z-index: 21;
    background: #FFF;
    width: 100%;
    height: 100%;
    display: none;
}
</style>
JS
<script type="text/javascript">
$(document).ready(function(){
$('body .gallery-placeholder').on('click', '.fotorama__stage__frame.fotorama__active .fotorama__img',function(){
var $this = $(this);
var img = $this.attr('src');
$('.gallery-popup .gallery-zoom-img .gallery-main-img').css("background-image", "url(" + img + ")")
$(".gallery-popup").fadeIn();
$("body").css("overflow", "hidden");
});
$(".gallery-popup").on("mousemove",".gallery-main-img",function(e){
var pixelToMove=100;
var height=$(this).innerHeight();
var newValueY=(e.clientY / height)*pixelToMove;
$(this).css('background-position',0+' '+newValueY+'%');
});
$(document).keyup(function(e) {
if (e.keyCode == 27) {
    $(".gallery-popup").fadeOut();
    $("body").css("overflow-y", "inherit");
}
});
$(".gallery-popup .gallery-main-img").click(function(){
$(".gallery-popup").fadeOut();
$("body").css("overflow-y", "inherit");
$('.gallery-popup .gallery-zoom-img .gallery-main-img').css("background-image", "");
});
});
</script> 

After installed Magento 2, got Internal server error due to IfVersion < 2.4

Following .htaccess code is not working in Magento 2

<Files composer.json>
        <IfVersion < 2.4>
            order allow,deny
            deny from all
        </IfVersion>
        <IfVersion >= 2.4>
            Require all denied
        </IfVersion>
    </Files>

Ans.  Just enabled "mod_version" from your server

Friday 13 September 2019

How to install Postman in Ubuntu 18.04

Step 1 : Download postman from : https://www.getpostman.com/downloads/
Step 2 : Open terminal : #cp -r /home/jaydip/Downloads/Postman/ /usr/local/
Step 3 : #sudo nano /usr/share/applications/Postman.desktop
Step 4 : Paste following text into the terminal screen

[Desktop Entry]
Encoding=UTF-8
Name=Postman
Exec=/usr/local/Postman/app/Postman
Icon=/usr/local/Postman/app/resources/app/assets/icon.png
Terminal=false
Type=Application
Categories=Development;

FYI: Just goto Exec path and check there is Postman available or not?

Tuesday 10 September 2019

How to get null attribute product value in magento 1 addAttributeToFilter Filter Query | Where condition

$collection = Mage::getModel('catalog/product')->getCollection()
        ->addAttributeToSelect(['entity_id'])
        ->addAttributeToFilter(
        array(
            array('attribute'=> 'pricegroup','null' => true),
            array('attribute'=> 'pricegroup','eq' => ''),
            array('attribute'=> 'pricegroup','eq' => 'NO FIELD')
        ),
        '',
        'left')
        ->addAttributeToFilter('status', ['eq' => 1]);
echo $collection->getSelect();
echo '<pre>';print_r($collection->getData());exit;

Thursday 5 September 2019

How to upload image file with ajax

jQuery("form#add-group-form").submit(function(e){
        e.preventDefault();
        var formData = new FormData(jQuery(this)[0]);
       
        jQuery.ajax({
            type:"POST",
            url:jQuery(this).attr("action"),
            data:formData,
            processData: false,
            contentType: false,
            dataType: "json",
            success: function(response){
                alert(response);
            }
        });
    });

Friday 30 August 2019

How to create multidimensional array in jQuery | Javascript

var jaydip = {};
for(var i=0; i < items.length; i++){
   jaydip[items[i]] = items[i]+'123';
}
console.log(jaydip);
alert(JSON.stringify(jaydip));

Wednesday 28 August 2019

Re-index primary key in Mysql database table

set @ROW = 0;
UPDATE `visitorhistory` SET `id` = @ROW := @ROW+1 ORDER BY `id` ASC;

How to Eliminate render-blocking JavaScript and CSS on WordPress

https://www.hostinger.in/tutorials/how-to-fix-eliminate-render-blocking-javascript-and-css-in-above-the-fold-content-on-wordpress

How to work async in jQuery ajax | Does it have something to do with preventing other events on the page from firing?

Yes, async to false means that the statement you are calling has to complete before the next statements of your function can be called. If you set async: true then that statement will begin it's execution the same time and the next statement will be called regardless of whether the async statement has completed yet.

jQuery('body #pricegroup-products-container').on('click', '.saveimage' , function (e) {
        var returnHtml = '';
        jQuery.ajax({
            type: "POST",
            async: false,
            cache: false,
            url: url,
            data: {id: '12345'},
            dataType: "html",
            success: function (response) {
                returnHtml = response;
            }
        });
        alert(returnHtml);
    });

Friday 2 August 2019

How to set cron job in heroku in PHP | Codeigniter

Step 1:  Install Heroku Scheduler add-ons from Heroku.


Step 2: Goto Heroku Scheduler page and add Job, set time interval and add command " php /app/index.php orderupdate crontset jaydip "
  1. php = server language
  2. /app/index.php = Path of the project root index.php
  3. orderupdate = name of controller
  4. crontset = name of function
  5. jaydip = variable name which you want to get into crontset function
Step 3: open Orderupdate.php controller

public crontset function($name){

echo $name;

}

Thursday 18 July 2019

How to run composer install in another PHP version

How to tell Composer to use Different PHP Version
#ea-php72 /opt/cpanel/composer/bin/composer install
You can get list of php by using following command
# ls /usr/bin/ | grep php 

Check list of Installed PHP versions and PHP CLI version into cpanel

# ls /usr/bin/ | grep php
Result
alt-php-mysql-reconfigure@
alt-php-mysql-reconfigure.py*
ea-php54@
ea-php54-pear@
ea-php54-pecl@
ea-php55@
ea-php55-pear@
ea-php55-pecl@
ea-php56@
ea-php56-pear@
ea-php56-pecl@
ea-php70@
ea-php70-pear@
ea-php70-pecl@
ea-php71@
ea-php71-pear@
ea-php71-pecl@
ea-php72@
ea-php72-pear@
ea-php72-pecl@
lsphp*
php*
php5@
php5-cli@
php-cgi@
php-cli@



Friday 5 July 2019

How to add file into gitignore which is already push into github

Step 1 : You need to soft remove from git : $ git rm --cached tax.txt
Step 2 : Add tax.txt file in .gitignore
Step 3 : commit and push.
Step 4 : Finished!

Saturday 29 June 2019

How to change startSymbol endSymbol of Angular JS

I face the issue when use Angular JS in shopify liquid file at that time I have use following script.

var fetch = angular.module('myapp', []).config(function ($interpolateProvider) {
    $interpolateProvider.startSymbol('{[{').endSymbol('}]}');
});

Friday 28 June 2019

How to disable Right click inside the Iframe

<iframe style="pointer-events:none;" src="https://jaydip+kansagra.com/landscape.pdf#toolbar=0&navpanes=0"/>

Monday 24 June 2019

How to concat string and variable in Liquid Shopify in PHP with proxy URL

<script type="text/javascript">
{% if customer  %}
    {% assign customerid = '"<?php echo base_url('checkout?id='.$postdata['cart_id']); ?>' | append: '&customer=' | append: customer.id | append: '"' %}
{% else %}
    {% assign customerid = '"<?php echo base_url('checkout?id='.$postdata['cart_id']); ?>' | append: '"' %}
{% endif %}
var checkouturl = {{customerid}};
window.location.replace(checkouturl);
</script>

Wednesday 19 June 2019

How to Install FREE SSL certificate into your howsting usign zerossl

Step 1 : Open : https://zerossl.com/free-ssl/#crt
Step 2 : Add your domains

Step 3 : After Click Next in previous step you can see like below image and Click Next

Step 4 : Now You can get both key like below image 

Step 5 : Click Next and you can get two files, see like below image

Step 6 : Download both key and upload into your server (like : public_html/.well-known/acme-challenge ) 


Step 7 : Click Next, You can see something like below image

Step 8 : Now Download certificate and private key file

Step 9 : Upload certificate into cpanel into see below image

Step 10 : Upload your certificate (domain-crt.txt) and save certificate code see below image

Step 11 : Install certificate see below image

Step 12 : Upload private key (domain-key.txt)

Step 13 : Click Install Certificate and Enjoy with FREE SSL

Friday 14 June 2019

How to open simple HTML CSS popup



HTML

<div class="main-roomle-popup-bg"></div>
<div class="main-roomle-popup">
     <div class="main-roomle-box">
        <h4>Popup heading</h4>
        <p>You can put message here.</p>
        <div class="modul-close-btn"><a href="#"><img src="close.png"/></a></div>
     </div>
</div>

CSS

<style type="text/css">
body {margin: 0;padding: 0;width: 100%;} .main-roomle-popup-bg {position: fixed;left: 0;top: 0;width: 100%;height: 100%;overflow: auto;background-color: #000; opacity: 0.5;} .main-roomle-popup {margin:0;width: 100%;text-align: center;z-index: 1;} .main-roomle-box {margin: auto;padding: 20px;width: 360px;height: 130px;background: #000;position: absolute;top: 0;right: 0;left: 0;bottom: 0;} .main-roomle-box h4 {margin: 0;padding: 0 0 40px 0;font-size: 22px;color: #fff;line-height: 22px;} .main-roomle-box p {margin: 0;padding: 0;font-size: 18px;color: #fff;} .modul-close-btn {margin: 0;padding: 0;width: 30px;height: 30px;position: absolute;right: -10px;top: -10px;}
</style>


Thursday 13 June 2019

Wednesday 12 June 2019

How to check URL and server OR SSL error and using terminal and curl

There are several way to check issue of URL and server OR SSL error and using terminal and curl

curl https://cdn.example.com/assets/storetheme/version2.3/new_theme.js -L
curl -vo /dev/null https://cdn.example.com/assets/storetheme/version2.3/new_theme.js -L
curl -I https://cdn.example.com/assets/storetheme/.htaccess.txt -L
curl -v /dev/null https://cdn.example.com/assets/storetheme/version2.3/new_theme.js -L

Saturday 8 June 2019

How to add Language of custom plugin in Admin dashboard in wordpress



Add text for language like this "<?php echo __('General options', 'roomle'); ?>"

Step 1 : Create plugin like "roomle"
Step 2 : Set domain path into plugin file like following screenshot

Step 3 : Create "roomle.pot" inside /wp-content/plugins/roomle/languages/
Step 4 : Add like following text inside "roomle.pot" file (FYI : Don't add any translation language just add as (msgstr = ""))
msgid ""
msgstr ""
"Project-Id-Version: PACKAGE VERSION\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2019-06-08 12:08+0100\n"
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
"Language-Team: LANGUAGE <LL@li.org>\n"
"Language: \n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=CHARSET\n"
"Content-Transfer-Encoding: 8bit\n"
#: functions.php:29
#, php-format
msgid "Roomle"
msgstr ""
#: functions.php:47
#, php-format
msgid "Select"
msgstr ""
#: functions.php:56
msgid "Roomle product type"
msgstr ""
Step 5 : Download the free plugin called Loco Translate from here. Or add directly from the WordPress administration via Plugins > Add New. (https://wordpress.org/plugins/loco-translate/)
Step 6 : Install and Activate Loco plugin
Step 7 : Click on Plugin inner menu of Loco after that click into your plugin from list.

Step 8 : Click on New language
Step 9 : Choose a language which you wish to translate (Here translate from English to Spanish)

Step 10 : See Source text (its from "roomle.pot" ) you need to add text of translate language.

Step 11 : After create all text to Spanish language, Check "/roomle/wp-content/languages/plugins/" directory. your 2 file is created here like "roomle-es_ES.mo" and "roomle-es_ES.po"
Step 12 : If you wish to check so you need to download wordpress in spanish language and setup wordpress and check

Also this answer for following question

  • How to Change the Admin plugin Language
  • How to add language into your plugin
  • How to add language into your custom plugin

AWS SSH and SFTP Disconnected: No supported authentication methods available (server sent: publickey)

Disconnected: No supported authentication methods available (server sent: publickey)

Could not connect to server

Step 1 : Login aws console
Step 2 : Go to instance list
Step 3 : Stop instance which have issue
Step 4 : After stop instance, Click and open "View/Change User Data" (See image)



Step 5 : Add Following code into textarea
 Content-Type: multipart/mixed; boundary="//"
MIME-Version: 1.0
--//
Content-Type: text/cloud-config; charset="us-ascii"
MIME-Version: 1.0
Content-Transfer-Encoding: 7bit
Content-Disposition: attachment; filename="cloud-config.txt"
#cloud-config
cloud_final_modules:
- [scripts-user, always]
--//
Content-Type: text/x-shellscript; charset="us-ascii"
MIME-Version: 1.0
Content-Transfer-Encoding: 7bit
Content-Disposition: attachment; filename="userdata.txt"
#!/bin/bash
ls -Al
ls -Al /home
ls -Al /home/ubuntu
ls -Al /home/ubuntu/.ssh
sudo cat /home/ubuntu/.ssh/authorized_keys
chown root:root /home
chmod 755 /home
chown ubuntu:ubuntu /home/ubuntu -R
chmod 700 /home/ubuntu
chmod 700 /home/ubuntu/.ssh
chmod 600 /home/ubuntu/.ssh/authorized_keys
ls -Al
ls -Al /home
ls -Al /home/ubuntu
ls -Al /home/ubuntu/.ssh
sudo cat /home/ubuntu/.ssh/authorized_keys
sudo ufw disable
sudo service sshd restart
--//
Step 6 : Click on save button
 Step 7 : Finish! Check your SSH and SFTP detail

Wednesday 5 June 2019

How to install letsencrypt SSL certificate on Ubuntu 14.04 apache

Download the Let’s Encrypt Client
Step 1 : sudo add-apt-repository ppa:certbot/certbot
Step 2 : sudo apt-get update
Step 3 : sudo apt-get install python-certbot-apache
Set Up the SSL Certificate
Step 4 : 

sudo certbot --apache -d jaydipkansagra.com
OR
sudo certbot --apache -d jaydipkansagra.com -d www.jaydipkansagra.com
Verifying Certbot Auto-Renewal
Step 5 : sudo certbot renew --dry-run

Tuesday 28 May 2019

How to connect ssh using PPK file into Cpanel from terminal Ubuntu

Connection command without PPK file
ssh username@146.66.87.208 -p18765
 Connection command with PPK file
ssh -i privatekey.ppk username@146.66.87.208 -p18765 (if not connect with PPK or give an error like "Load key "privatekey.ppk": invalid format" so please use the direct file without PPK format (See the following screenshot) ) (Supported port : 22, 18765, 18675)

Thursday 9 May 2019

Access denied for user 'root'@'localhost' even password is correct

Error : SQLSTATE[HY000] [2002] Can't connect to local MySQL server through socket
Step 1 : For backup = cp -rfv /var/lib/mysql /var/lib/mysql$(date +%s)
Step 2 : sudo /etc/init.d/mysql stop
Step 3 : sudo mysqld_safe --skip-grant-tables & (If process will not complete after 5 minuts keep this window open and open another terminal window)
Step 4 :  mysql -u root -p 
Step 5 : FLUSH PRIVILEGES;
Step 6 : UPDATE user SET Grant_priv = 1, Super_priv = 1 WHERE user = 'root'
Step 7 : update user set password=PASSWORD("Franki3r0s3") where User='root';
Step 8 : GRANT ALL PRIVILEGES ON . TO 'root'@'localhost' IDENTIFIED BY 'anki8f0s3';

Additional commands : 
1. mysql# show users;
2. mysql# SELECT User FROM mysql.user;
3. ps -e | grep mysqld
4. kill -kill 16300
5. ps -x



Friday 22 March 2019

How to make backgroud process in php using shell_exec

Create background.php file
<?php
$post_id = ['post_id'=>10];
$post_id = json_encode($post_id);
$pid = shell_exec("php /var/www/html/magento/dump/exportfile.php $post_id alert >> /var/www/html/magento/dump/test.log & echo $!");
echo $pid;
Create checkprocess.php file
$pid = 1254; // Copy pid from background.php
if (file_exists("/proc/$pid" )){
    echo "process with a pid = $pid is running";
}
 Create exportfile.php file
//Create this file with high time taking script

Friday 8 March 2019

How to create CloudFront Distributions / CDN in AWS with Origin EC2 / Loadbalancer

Origin Settings

Step 1 : Login AWS console ( https://console.aws.amazon.com )
Step 2 : Open CloudFront console ( https://console.aws.amazon.com/cloudfront/ )
Step 3 : Click on "Create Distribution" 
Step 4 : Click on "Get started" on Web
Step 5 : "Origin Domain Name" = Select your load balancer for EC2 
Step 6 : Origin Path = Blank (add cdn file directory path if specific dir add for CDN )
Step 7 : Origin SSL Protocols = default selection
Step 8 : Origin Protocol Policy = HTTP Only
Step 9 : Origin Response Timeout = 30 (default) 
Step 10 : Origin Keep-alive Timeout = 5 (default)
Step 11 : HTTP Port = 80  (default)
Step 12 : HTTPS Port = 443 (default)
Step 13 : Origin Custom Headers = Blank (like default) 

Default Cache Behavior Settings 

Step 14 : Viewer Protocol Policy = HTTP and HTTPS
Step 15 : Allowed HTTP Methods = GET, HEAD
Step 16 : Field-level Encryption Config = blank (default)
Step 17 : Cache Based on Selected Request Headers = None (default)
Step 18 : Object Caching = Use Origin Cache Headers (default)
Step 19 : Forward Cookies = None (default)
Step 20 : Query String Forwarding and Caching = None (default)
Step 21 : Smooth Streaming = No (default)
Step 22 : Restrict Viewer Access (Use Signed URLs or Signed Cookies) = No (default)
Step 23 : Compress Objects Automatically = No (default)
Step 24 : Lambda Function Associations = (default)

Distribution Settings

Step 25 : Price Class = Use U.S., Canada, Europe, Asia and africa (You can select ALL for best performance world wide)
Step 26 : AWS WAF Web ACL = None (default)
Step 27 : Alternate Domain Names (CNAMEs) = Subdomain like cdn.jaydipkansagra.com (you can add multiple domain here)
Step 28 : SSL Certificate = Select custom if you want SSL on cdn url ( If option disable you need to create Certificates into N.Virginia ) 
Step 29 : Supported HTTP Versions = HTTP/2, HTTP/1.1, HTTP/1.0
Step 30 : Default Root Object = Blank (default)
Step 31 : Logging = Off (default)
Step 32 : Enable IPv6 = Checked (default)
Step 33 : Comment = Blank (default)
Step 34 : Distribution State = Enabled (default)
Step 35 : Click on Create Distribution button (default)

Pointout domain 

Step 36 : Point subdomain cdn.jaydipkansagra.com to d111111abcdef8.cloudfront.net
Step 37 : open the Route 53 console at https://console.aws.amazon.com/route53/
Step 38 : Click Hosted Zones
Step 39 : Click Create Record Set
Step 40 : Name = cdn, Type = CNAME, Alias = NO, TTL (Seconds) = 300, Value = d2m9sh2v6fo5gb.cloudfront.net
Step 41 : Click on save button
Step 42 : Finish : Open http://cdn.jaydipkansagra.com thats done

Tuesday 29 January 2019

How To Migrate Magento 1 To Magento 2

Step 1 : Get full backup of your Magento 1 store including all files, folders, and the database

Step 2 : Create a clone of your Magento 1 store. Do not use your live store for Magento migration process

Step 3 : Check your store. Keep what you think is necessary and delete the rest

Step 4 : Check whether your current theme(s), extensions and custom code are compatible with the Magento 2 or not.

Step 5 : Create clone of Magento 1 database and connect with new(clone) magento 1.

Step 6 : Remove useless data from the database including logs, recently viewed products, compared products, etc.

Step 7 : To make Magento migration process as hassle-free as possible, install a fresh and latest copy of Magento 2 on the same hosting server where your Magento 1(cloned) store is located.

Step 8 : To find the version of your store, navigate to the root directory of your Magento 2 via SSH and enter the following command:
php bin/magento --version
Step 9 :
composer config repositories.magento composer https://repo.magento.com
composer require magento/data-migration-tool:2.3.0
You will be asked to enter your developer authentication keys. Go to the Magento Marketplace. Sign in using your login credentials, go to your profile and then click Access Keys under My Products section.

If you already have keys then, your public key will be your username and the private key will be your password. Otherwise, create a new key pair by clicking the Create a New Access Key button.

In a few seconds, the Data Migration Tool will be successfully installed on your Magento 2 store.

Configure Magento 2 Data Migration Tool


Step 10 : Goto <Magento 2 root dir>/vendor/magento/data-migration-tool/etc/opensource-to-opensource/<Magento 1.x version> and rename config.xml.dist to config.xml

Step 11 :

Next, open config.xml in your favorite code editor and specify the following:

<source>

<database host="localhost" name="Magento1-DB-name" user="DB-username" password="DB-password"/>

</source>

<destination>

<database host="localhost" name="Magento2-DB-name" user="DB-username" password="DB-password"/>

</destination>

<options>

<crypt_key>Magento1-Encrypted-Key</crypt_key>

</options>

In the above code, <source> has the database information of Magento 1 and <destination> has the relevant database information of Magento 2. <crypt_key> is mandatory and needs to be filled prior run. It is the encryption key of Magento 1 store and can be found in the <Magento 1 root dir>/app/etc/local.xml file, within the <key> tag.

When finished, save the config.xml and you are done.

Migrate Settings Using Magento 2 Data Migration Tool


Here is how you can use the Data Migration Tool to migrate settings from Magento 1 to Magento 2. These settings include stores, websites, system configurations such as shipping, payment, tax settings, etc.

According to the Magento Data Migration Order, you should migrate settings first. To start migrating the settings, navigate to your Magento 2 root directory via SSH terminal and run the following command:
php bin/magento migrate:settings --reset <path to your config.xml>
where <path to your config.xml> this would be vendor/magento/data-migration-tool/etc/opensource-to-opensource/<Magento 1.x version>/config.xml. I have used --reset argument in the above command which forces the Data Migration Tool to start from the beginning.

Once the settings migration is over, a successful message will be displayed.


Migrate Data Using Magento 2 Data Migration Tool


Data migration from Magento 1 platform to Magento 2 platform includes products, categories, orders, customers, wish lists, ratings, etc. To migrate data, run the following CLI command:
php bin/magento migrate:data --reset <path to your config.xml>
As this command runs, the Magento 2 Data Migration Tool saves its current progress, and in the case of an error, stop the process and resume from the last known good state. Also, the Magento 2 Data Migration Tool may report some errors during the migration. In such a case, refer to the Troubleshooting page of the Magento 2 Data Migration Tool for further assistance.

Step 12 : Finish and check Your Magento 2 store


How to install Extension in PHP 7.2 | PHP 7.1 | PHP 7.0 in Ubuntu 16.04 | Ubuntu 18.04

Open terminal or cmd and put following command
apt install php7.2-soap
apt install php7.2-bcmath

Thursday 24 January 2019

How to dump Magento 2 Enterprise Edition Database

  1. curl -sS https://accounts.magento.cloud/cli/installer | php
  2. magento-cloud list
  3. login without root
  4. magento-cloud db:dump
  5. Open login URL in browser like : http://127.0.0.1:5000
  6. Update to version 1.23.0? [Y/n] y
  7. Continue? [Y/n] y
  8. Enter a number to choose a project:
    1.  [0] ProjectName (Project) (tx2ia23dv5uk)
    2.   Environment ID [staging]: (Press enter key)
  9. Enter a number to choose a relationship:
    1.   [0] database
    2.   [1] database-slave
  10. (Press 0 and Enter key)