Skip to content

Instantly share code, notes, and snippets.

View gelanivishal's full-sized avatar
🎯
Focusing

Vishal Gelani gelanivishal

🎯
Focusing
View GitHub Profile

Magento 2(Customer) Tips, Tricks and Snippets

Add Tab in Customer Dashboard (Frontside)
<?xml version="1.0" encoding="UTF-8"?>
<page xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:View/Layout/etc/page_configuration.xsd">
    <body>
        <referenceBlock name="customer_account_navigation">
            <block class="Magento\Framework\View\Element\Html\Link\Current" ifconfig="helpdesk/frontend/is_active" name="customer-account-navigation-helpdesk-link">
                <arguments>

Magento 2 Tips, Tricks and Snippets

Infos About Store##

inject \Magento\Store\Model\StoreManagerInterface $storeManage
$this->storeManager = $storeManager;

Get Store id
$id = $this->storeManager->getStore()->getId();
@gelanivishal
gelanivishal / 0_reuse_code.js
Created November 26, 2016 15:41
Here are some things you can do with Gists in GistBox.
// Use Gists to store code you would like to remember later on
console.log(window); // log the "window" object to the console
@gelanivishal
gelanivishal / default
Created February 18, 2017 15:12
Ubuntu 16.04: Nginx magento2 configuration
# put following two lines under server node of nginx default
# Load configuration files for the default server block.
include /etc/nginx/default.d/*.conf;
@gelanivishal
gelanivishal / git_change_user.sh
Last active February 21, 2017 01:36
Git: Change user of your local repository
git config --global user.name "Your name"
git config --global user.email "your@email.com"
@gelanivishal
gelanivishal / m1.gitignore
Created February 18, 2017 15:11
M1 - gitignore
.idea/
nbproject/
/var
/media
/app/etc/local.xml
cgi-bin/
/includes/src
@gelanivishal
gelanivishal / mediasync.sh
Created February 18, 2017 15:10
Bash script for auto backup your Magento media directory on specific path.
#!/bin/bash
# clear screen
clear;
# Get current directory, assume this script is locate under Magento root directory
SOURCE="${BASH_SOURCE[0]}"
while [ -h "$SOURCE" ]; do # resolve $SOURCE until the file is no longer a symlink
DIR="$( cd -P "$( dirname "$SOURCE" )" && pwd )"
SOURCE="$(readlink "$SOURCE")"
[[ $SOURCE != /* ]] && SOURCE="$DIR/$SOURCE" # if $SOURCE was a relative symlink, we need to resolve it relative to the path where the symlink file was located
@gelanivishal
gelanivishal / print_transcational_email.md
Created February 18, 2017 15:05
Magento 2 print transcational email before mail send

Open following file :

{root}/vendor/magento/framework/Mail/Template/TransportBuilder.php

and find prepareMessage() function at line number 265

Just echo $body and exit the exceution of code.

@gelanivishal
gelanivishal / prefix.php
Created February 10, 2017 16:27
Get table prefix
<?php
$bootstrap = \Magento\Framework\App\Bootstrap::create(BP, $_SERVER);
$obj = $bootstrap->getObjectManager();
$deploymentConfig = $obj->get('Magento\Framework\App\DeploymentConfig');
$tablePrefix = $deploymentConfig->get('db/table_prefix');
@gelanivishal
gelanivishal / jquery-ver.js
Created February 10, 2017 16:26
Retrieve jQuery Version
// Type one of the next lines and you will obtain jQuery version:
console.log(jQuery.fn.jquery);
// OR
console.log(jQuery().jquery);