Thursday, June 13, 2019

make magento faster

Hello

Use these settings to make magento more faster.

1. Disable Signed content (Don't need for developer mode)

insert into core_config_data (scope, scope_id, path, value) values ('default',0, 'dev/static/sign', 0);


2. Make sure you have used SSD for store Magento 2 Source Code.

3. Make sure you have used the latest MySQL version.

4. You are developing, please enable developer mode and doing step 1.

5. If your site got too many products, please run php bin/magento catalog:image:resize

6. The suggestion is Use Redis cache and saves the session to DB or Redis

These will help you to make fast magento website. 


Thursday, June 6, 2019

Be careful while display show/hide editor in magento 2

Hello.

Please be careful while click on show/hide editor in any page. It removes javascripts from that code.
Now you click on show editor, it looks like this :-

When you once again click it, JavaScript will be removed from your code. See this :-

How to set HTML Auto Indent format on Sublime Text 3?

Hello

To auto indent on Sublime text 3 with a key bind try going to
Preferences > Key Bindings - users

And adding this code between the square brackets

{"keys": ["alt+shift+f"], "command": "reindent", "args": {"single_line": false}}

 it sets shift + alt + f to be your full page auto indent.


Wednesday, June 5, 2019

Magento 2 Useful Commands List

Hello

Here I display some useful commands for magento 2.

If magento website is not loading properly and admin is not open and display as 404 error, Use these commands:-

chmod -R 777 /var/www/html/MAGENTO_2_ROOT_DIRECTORY/

sudo a2enmod rewrite

sudo service apache2 restart

Install php 7, use this command :-
sudo apt-get install php7.1 libapache2-mod-php7.1 php7.1-mbstring php7.1-mysql php7.1-mcrypt php7.1-xsl php-imagick php7.1-gd php7.1-cli php-pear php7.1-intl php7.1-curl php7.1-zip php7.1-gd php7.1-soap php7.1-xml -y
sudo service apache2 restart


Setup Upgrade Using Command Line
php bin/magento setup:upgrade

If you don’t want to remove pub/static files while installing/updating database then use following command.
php bin/magento setup:upgrade --keep-generated

Cache Clean Using Command Line
php bin/magento cache:clean

Cache Flush Using Command Line
php bin/magento cache:flush

View cache status Using Command Line
php bin/magento cache:status

Enable Cache Using Command Line
php bin/magento cache:enable [cache_type]

Disable Cache Using Command Line
php bin/magento cache:disable [cache_type]

Static Content Deploy Using Command Line (Use -f for force deploy on 2.2.x or later)
php bin/magento setup:static-content:deploy

Static Content Deploy For Particular Language Using Command Line
php bin/magento setup:static-content:deploy en_US

Static Content Deploy For Magento Backend Theme Using Command Line (Working on 2.1.1 or later)
php bin/magento setup:static-content:deploy --theme="Magento/backend"

Static Content Deploy For Specific Themes Using Command Line (Working on 2.1.1 or later)
php bin/magento setup:static-content:deploy --theme Magento/luma --theme Magento/second_theme

Exclude Themes on Static Content Deploy and does not minify HTML files Using Command Line (Working on 2.1.1 or later)
php bin/magento setup:static-content:deploy en_US --exclude-theme Magento/luma --no-html-minify


Reindexing Using Command Line
php bin/magento indexer:reindex


View the list of indexers Using Command Line
php bin/magento indexer:info

View indexer status Using Command Line
php bin/magento indexer:status

Show the mode of all indexers Using Command Line
php bin/magento indexer:show-mode

See all modules Status Using Command Line
php bin/magento module:status

Enable module Using Command Line
php bin/magento module:enable Namespace_Module

Disable module Using Command Line
php bin/magento module:disable Namespace_Module

Uninstall Module Using Command Line
php bin/magento module:uninstall Namespace_Module

Check Current Mode Using Command Line
php bin/magento deploy:mode:show

Change To Developer Mode Using Command Line
php bin/magento deploy:mode:set developer

Change To Production Mode Using Command Line
php bin/magento deploy:mode:set production

Run the single-tenant Compiler Using Command Line
php bin/magento setup:di:compile

Unlock Admin User Using Command Line
php bin/magento admin:user:unlock adminusername

Enable Maintenance Mode Using Command Line
php bin/magento maintenance:enable

To enable maintenance mode for all clients except 192.0.0.1 and 192.0.0.2:
php bin/magento maintenance:enable --ip=192.0.0.1 --ip=192.0.0.2

To clear the list of IPs.
php bin/magento maintenance:enable --ip=none

Disable Maintenance Mode Using Command Line
php bin/magento maintenance:disable

Check Maintenance Mode Status Using Command Line
php bin/magento maintenance:status

Allow IP on Maintenance Mode Using Command Line
php bin/magento maintenance:allow-ips --ip=192.0.0.1 --ip=192.0.0.2

Set Magento crontab Using Command Line
php bin/magento cron:install --force

Use --force to rewrite an existing Magento crontab.
To view the crontab, enter the following command as the Magento file system owner.
crontab -l

Remove Magento crontab Using Command Line
php bin/magento cron:remove

It will be updated when I get new commands.
 

Tuesday, June 4, 2019

simple thanos effect by javascript and css

Hello.

Here I present simple thanos effect code. Only css and simple javascript are use to  make this effect. Copy and paste whole html code for see result.

<!DOCTYPE html>
<html>
<head>
<title></title>
<style>
body {
  font-size: 16px;
}

.btn,
.block {
  text-align: center;
  border: 1px solid transparent;
}

.btn {
  margin: 8px auto;
  padding: 6px 12px;
  background-color: #5bc0de;
  color: white;
  display: inline-block;
  border-radius: 3px;
  cursor: pointer;
}

.btn:hover {
  background-color: #1490ac;
}

.block {
  width: 440px;
  height: 200px;
  border-color: #cfd8dc;
  border-radius: 8px;
  box-shadow: none;
  padding: 12px;
  line-height: 40px;
}

.div-hidden {
  transition: opacity 1.75s ease 0s;
  opacity: 0;
  visibility: hidden;
}

.div-show {
  transition: opacity 1.5s ease 0s;
  opacity: 1;
  visibility: visible;
}

.block-container {
  position: relative;
  margin: 8px 0;
}

.div-overlay {
  position: absolute;
  top: 0;
  animation-iteration-count: 1;
  animation-duration: 1.5s;
  visibility: hidden;
}

.div-overlay-left {
  animation-name: slide-left;
}

.div-overlay-right {
  animation-name: slide-right;
}

@keyframes slide-left {
  from {
    left: 0;
    opacity: 1;
    visibility: visible;
  }
  to {
    left: -30px;
    opacity: 0;
  }
}

@keyframes slide-right {
  from {
    left: 0;
    opacity: 1;
    visibility: visible;
  }
  to {
    left: 30px;
    opacity: 0;
  }
}

</style>
</head>
<body>

<div class="block-container">
  <div id="block" class="div-show block-main">
    <div class="block">
      A naive implementation on Google's Thanos effect (Mobile version)
      <br>
      No jQuery or other libaray used
      <br>
      Good bye, the cruel world
      <br>
      Hello, the new world
    </div>
    <button type="button" class="btn" onclick="onBtnClick();" id="btn">Thanos This</button>
  </div>
  <div id="overlay"></div>
</div>
<script type="text/javascript">
function classHas(base, has) {
  const arr = base.split(" ")
  for (let i = 0; i < arr.length; i++) {
    if (arr[i] === has) 
      return true;
  }
}

function classReplace(base, replace, next) {
  return base.replace(replace, next)
}

function onBtnClick() {
  const block = document.getElementById("block");
  const btn = document.getElementById("btn");
  const overlay = document.getElementById("overlay");

  if (classHas(block.className, "div-show")) {
    block.className = classReplace(block.className, "div-show", "div-hidden")
    //btn.innerHTML = "Show"
    const content = block.innerHTML;
    overlay.innerHTML = "<div class=\"div-overlay div-overlay-left\">" + content + "</div>" + "<div class=\"div-overlay div-overlay-right\">" + content + "</div>";
  } else {
    /*block.className = classReplace(block.className, "div-hidden", "div-show")
    btn.innerHTML = "Snap"
    overlay.innerHTML = null;*/
  }
}

</script>
</body>
</html>
I will put real thanos effect in a short time.

Demo:-

Wednesday, May 8, 2019

selection by array


Hello

Here I display : Call one query one time. Save its value in array. Fetch it whenever need it.

/*get stage types*/
$stgsql = "SELECT * FROM stage_t";
$stgrs  = mysql_query($stgsql);
$stageTypes=array();
while($rowStage=mysql_fetch_assoc($stgrs))
  $stageTypes[$rowStage[code]]=$rowStage[edesc];

echo  $todaysstage = $stageTypes[$row[todaysstage]];

Monday, April 29, 2019

select and inset for dropdown list

Here I write code for select from dropdown and insert into new input box.


HTML:
<td>
                            <select name="registration_survey_no1[]" id="registration_survey_no1" style="width:180px;" onchange="addsurvey()" >
                                <option value=0> Select Survey~~Resurveyno </option>
                                <option value=1> Select Survey1~~Resurveyno1 </option>
                                <option value=2> Select Survey2~~Resurveyno2 </option>
                                <option value=3> Select Survey3~~Resurveyno3 </option>
                                <option value=4> Select Survey4~~Resurveyno4 </option>
                            </select>
                        </td>
                        <td>
                            <div class="input_fields_wrap"></div>
                        </td>

Javascript :
function addsurvey(){
            var registration_survey_no1 = $('#registration_survey_no1').val();
            var wrapper           = $(".input_fields_wrap"); //Fields wrapper
            var x = 1; //initlal text box count
            var i = 0 ;
            var random = Date.now();
            //text box increment
            if(registration_survey_no1 != '0'){
                x++;
                $(wrapper).append('<div id="dv_'+random+'"><input type="text" value="'+registration_survey_no1+'" name="mytext[]"/><a href="#" class="remove_field" onclick="deletesurvey('+random+')">Remove</a></div>'); //add input box
                //$('select[name^="input_fields_wrap"]').eq(1).focus();
                $('#registration_survey_no1').trigger("chosen:updated");
                //document.getElementsByName('registration_survey_no1['+i+']')[0].focus();
            }
           
        }
        function deletesurvey(id){
            var divid = "dv_"+id;
            var element = document.getElementById(divid);
            element.parentNode.removeChild(element);
        }