Skip to content

Instantly share code, notes, and snippets.

View yogeshdubey2006's full-sized avatar
🏠
Working from home

Yogesh Dubey yogeshdubey2006

🏠
Working from home
View GitHub Profile
@yogeshdubey2006
yogeshdubey2006 / command.sh
Last active December 30, 2018 06:21
Magento 2 - Removed your var/generation and var/cache directory
# ERROR: The directory "/chroot/home/username/domain.com/html/generated/code" cannot be deleted Warning!rmdir(/chroot/home/username/domain.com/html/generated/code): Directory not empty
# You need to remove it manually, if it is ubuntu then locate in your magento 2 root directory and run "rm -rf var/generation" and "rm -rf var/cache" command.
# Screenshot: https://www.dropbox.com/s/e786vkgpeuzko67/20181230_generated.jpg?dl=0
rm -rf var/generation
rm -rf var/cache
# and Then try to run below commands in sequence.
php bin/magento setup:di:compile
php bin/magento setup:upgrade
php bin/magento cache:clean
@yogeshdubey2006
yogeshdubey2006 / css3-equal-height.html
Created January 2, 2019 11:01
CSS3 - make equal height of blocks
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<meta name="author" content="[email protected]">
<title>Equal height Blocks</title>
<style type="text/css">
* {
box-sizing: border-box;
-moz-box-sizing: border-box;
@yogeshdubey2006
yogeshdubey2006 / woocommerce-custom-attribute.php
Created January 2, 2019 11:53
WooCommerce - Get values of product custom attribute
<?php
/* When we make custom product attribute in WooCommerce, they are registered as a custom taxonomy.
* So we can use WordPress function get_the_terms() to retrieve them.
* When register these custom taxonomy, WooCommerce adds a prefix of pa_ to our custom product attribute.
* So if we create an attribute called Height, who's slug is 'height', then the custom taxonomy would be 'pa_height'.
* Now we are going to retrieve all terms in this attribute (height) of a product.
*/
$pa_height = get_the_terms( $product->id, 'pa_height');
if ( ! empty( $pa_height ) && ! is_wp_error( $pa_height ) ) {
foreach ( $pa_height as $pa_height_item ) {
@yogeshdubey2006
yogeshdubey2006 / wp-config.php
Created January 3, 2019 05:39
WordPress - auto update
<?php
/* add below code in wp-config.php file.
*
*/ ?>
<?php define( 'WP_AUTO_UPDATE_CORE', true ); ?>
@yogeshdubey2006
yogeshdubey2006 / .htaccess
Last active January 3, 2019 13:00
Redirect to secure URL
# not tested
RewriteCond %{HTTPS} !=on
# This checks to make sure the connection is not already HTTPS
RewriteRule ^/?(.*) https://%{HTTP_HOST}%{REQUEST_URI} [R,L]
# not tested
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
@yogeshdubey2006
yogeshdubey2006 / wordpress-useful-code.php
Last active January 15, 2019 05:44
WordPress - useful code
<img src="<?php echo get_template_directory_uri().'/images/logo.png' ?>" />
<?php echo do_shortcode('[contact-form-7 id="5" title="Footer newsletter"]'); ?>
@yogeshdubey2006
yogeshdubey2006 / index.phtml
Last active June 15, 2021 06:52
Magento 1 - useful code
# Call Media Url in phtml file
<img src="<?php echo Mage::getBaseUrl(Mage_Core_Model_Store::URL_TYPE_MEDIA).'/wysiwyg/portfolio3.jpg';?>" class="class-name" alt="" />
# Get breadcrumbs
<?php echo $this->getChildHtml('breadcrumbs') ?>
# Get Skin Url
<img src="<?php echo $this->getSkinUrl('images/go_btn.png'); ?>" alt="Image name" class="class-name" width="" height="" />
# Get Static Block
@yogeshdubey2006
yogeshdubey2006 / magento-export-categories-with-ids.php
Created January 3, 2019 07:34
Magento - export categories with ids
<?php
ini_set("memory_limit","10000M");
require_once "app/Mage.php";
umask(0);
Mage::app();
$category = Mage::getModel ( 'catalog/category' );
$tree = $category->getTreeModel ();
$tree->load();
$ids = $tree->getCollection()->getAllIds();
if ($ids) {
@yogeshdubey2006
yogeshdubey2006 / catalog-search-form.phtml
Created January 3, 2019 11:44
Magento - show simple calatog search form on CMS page.
<?php
/* There is no widget available for this, but pasting the following code into a CMS page or Static Block will allow you to
* put a search block where you want to have it:
* You may need to add some CSS to display it to your needs.
*/
<form id="search_mini_form_cms" action="{{store url='catalogsearch/result'}}" method="get">
<div class="input-box">
<label for="search_cms">Search:</label>
<input id="search_cms" type="search" name="q" value="" class="input-text required-entry" maxlength="128" placeholder="Search entire store here..." autocomplete="off">
<button type="submit" title="Search" class="button search-button"><span><span>Search</span></span></button>
@yogeshdubey2006
yogeshdubey2006 / disabled-right-click.html
Created January 3, 2019 11:55
Javascript - no right clicking allowed!
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<meta name="author" content="[email protected]">
<title>No Right Clicking Allowed</title>
<style type="text/css">
* {
box-sizing: border-box;
-moz-box-sizing: border-box;