Skip to content

Instantly share code, notes, and snippets.

View gelanivishal's full-sized avatar
🎯
Focusing

Vishal Gelani gelanivishal

🎯
Focusing
View GitHub Profile
@gelanivishal
gelanivishal / wp-fix-file-permission.sh
Created December 25, 2016 03:07
Wordpress fix file permission
wget https://gist.github.com/Adirael/3383404/raw/6c5446d56477426faeb709e5b807f00422acdea2/fix-wordpress-permissions.sh # <-- Check below code wp-permissions.sh
chmod +x fix-wordpress-permissions.sh
sudo ./fix-wordpress-permissions.sh /your/wordpress/path
@gelanivishal
gelanivishal / m2_commands.sh
Last active February 21, 2017 01:39
M2: Useful commands
# deploy static content
php bin/magento setup:upgrade
rm -rf var/cache/ var/generation/ var/page_cache/ var/view_preprocessed/ pub/static var/composer_home
php bin/magento setup:static-content:deploy
chmod -Rf 777 pub/ var/
# enable language pack for any language
php bin/magento cache:clean
php bin/magento setup:static-content:deploy et_EE
$.ajax({
url: "http://www.example.com/api",
beforeSend: function(xhr) {
xhr.setRequestHeader("Authorization", "Basic " + btoa("username:password"));
},
type: 'POST',
dataType: 'json',
contentType: 'application/json',
processData: false,
data: '{"foo":"bar"}',
@gelanivishal
gelanivishal / lnmp.sh
Last active February 21, 2017 01:39
Ubuntu 16.04: Install Nginx + PHP7 + MySql
# Nginx
sudo apt-get update
sudo apt-get install nginx
sudo nano /etc/nginx/sites-available/default
# PHP
sudo apt-get update
sudo apt-get install php7.0-fpm php-mysql
sudo apt-get install php7.0-mysql php7.0-mysqli php7.0-curl php7.0-json php7.0-mcrypt php7.0-zip php7.0-dom php7.0-intl
sudo nano /etc/php/7.0/fpm/php.ini
find . -type f -exec chmod 644 {} \; // 644 permission for files
find . -type d -exec chmod 755 {} \; // 755 permission for directory
find ./var -type d -exec chmod 777 {} \; // 777 permission for var folder
find ./pub/media -type d -exec chmod 777 {} \;
find ./pub/static -type d -exec chmod 777 {} \;
chmod 777 ./app/etc
chmod 644 ./app/etc/*.xml
@gelanivishal
gelanivishal / product_by_id.php
Created December 31, 2016 17:45
Load product by product id in listing #M2
<?php
// PS: Do not use *load/save* methods directly, instead use related repositoryinterface.
$objectManager = \Magento\Framework\App\ObjectManager::getInstance();
$load_product=$objectManager->get('Magento\Catalog\Api\ProductRepositoryInterface');
$_product = $load_product->getById($_single_product_id);
@gelanivishal
gelanivishal / validation.md
Last active February 21, 2017 01:38
Magento 2 xml validation

Check updates to the GitHub today, Magento 2 introduced new command to automatically generate all the URN resolutions for the PhpStorm.

To use it: have Magento installed on the same machine as PhpStorm go to the root directory execute command

$ php bin/magento dev:urn-catalog:generate .idea/misc.xml
<?php
$objectManager = \Magento\Framework\App\ObjectManager::getInstance();
$reviewFactory = $objectManager->create('Magento\Review\Model\Review');
$storeId = $this->_storeManager->getStore()->getId();
$reviewFactory->getEntitySummary($product, $storeId);
$ratingSummary = $product->getRatingSummary()->getRatingSummary();
Find the PHP binary and php.ini path
To display the path to your PHP binary, enter
which php
A sample result follows:
/usr/bin/php
Create the cron job
@gelanivishal
gelanivishal / in_cms_content.txt
Created January 6, 2017 03:12
Display Static Block in Phtml file & CMS page
{{block class="Magento\\Cms\\Block\\Block" block_id="block_identifier"}}