Categories
blog ecommerce magento Nginx

magento 2 permission 2018

sudo chown -R rawi:www-data Magento-CE-2
find /var/www/html/magento/Magento-CE-2 -type f -print0 | xargs -r0 chmod 640
find /var/www/html/magento/Magento-CE-2 -type d -print0 | xargs -r0 chmod 750
chmod -R g+w /var/www/html/magento/Magento-CE-2/app/etc
chmod -R g+w /var/www/html/magento/Magento-CE-2/var
chmod -R g+w /var/www/html/magento/Magento-CE-2/generated
chmod -R g+w /var/www/html/magento/Magento-CE-2/vendor
chmod -R g+w /var/www/html/magento/Magento-CE-2/pub
Categories
blog Storefront WooCommerce wordpress

wordpress woocommerce storefront tab to accordion

tab templates/single-product/tabs

function.php


/**
 * @snippet       Move product tabs beside the product image - WooCommerce
 */
 
remove_action( 'woocommerce_after_single_product_summary', 'woocommerce_output_product_data_tabs', 10 );
add_action( 'woocommerce_single_product_summary', 'woocommerce_output_product_data_tabs', 60 );
add_filter('woocommerce_product_description_heading', '__return_null');
add_filter('woocommerce_product_additional_information_heading', '__return_null');

Categories
blog Storefront WooCommerce wordpress

wordpress Good Good Optimize Stuff




/// Good Good Optimize Stuff ...



// block WP enum scans 
if (!is_admin()) {
    // default URL format
    if (preg_match('/author=([0-9]*)/i', $_SERVER['QUERY_STRING'])) die();
    add_filter('redirect_canonical', 'shapeSpace_check_enum', 10, 2);
}
function shapeSpace_check_enum($redirect, $request) {
    // permalink URL format
    if (preg_match('/\?author=([0-9]*)(\/*)/i', $request)) die();
    else return $redirect;
}

 
add_action( 'wp_default_scripts', function( $scripts ) {
    if ( ! empty( $scripts->registered['jquery'] ) ) {
        $jquery_dependencies = $scripts->registered['jquery']->deps;
        $scripts->registered['jquery']->deps = array_diff( $jquery_dependencies, array( 'jquery-migrate' ) );
    }
} );
/**
 * Optimize WooCommerce Scripts
 * Remove WooCommerce Generator tag, styles, and scripts from non WooCommerce pages.
 */
add_action( 'wp_enqueue_scripts', 'child_manage_woocommerce_styles', 99 );

 

function cc_mime_types($mimes) {
    $mimes['svg'] = 'image/svg+xml';
    return $mimes;
}
add_filter('upload_mimes', 'cc_mime_types');
  
function woo_registration_redirect() {
    return home_url( '' );
}
 
add_filter( 'registration_redirect', 'woo_registration_redirect' );

remove_action( 'wp_head', 'feed_links_extra', 3 ); // Display the links to the extra feeds such as category feeds
remove_action( 'wp_head', 'feed_links', 2 ); // Display the links to the general feeds: Post and Comment Feed
remove_action( 'wp_head', 'rsd_link' ); // Display the link to the Really Simple Discovery service endpoint, EditURI link
remove_action( 'wp_head', 'wlwmanifest_link' ); // Display the link to the Windows Live Writer manifest file.
remove_action( 'wp_head', 'index_rel_link' ); // index link
remove_action( 'wp_head', 'parent_post_rel_link', 10, 0 ); // prev link
remove_action( 'wp_head', 'start_post_rel_link', 10, 0 ); // start link
remove_action( 'wp_head', 'adjacent_posts_rel_link', 10, 0 ); // Display relational links for the posts adjacent to the current post.
remove_action( 'wp_head', 'wp_generator' ); // Display the XHTML generator that is generated on the wp_head hook, WP version
remove_action( 'wp_head', 'print_emoji_detection_script', 7 );
remove_action( 'wp_print_styles', 'print_emoji_styles' );

function optimize_jquery() {
    if (!is_admin()) {
        //wp_deregister_script('jquery');
        wp_deregister_script('jquery-migrate.min');
        wp_deregister_script('comment-reply.min');
        $protocol='http:';
        if($_SERVER['HTTPS']=='on') {
            $protocol='https:';
        }
    }
}
add_action('template_redirect', 'optimize_jquery');

// Defer Javascripts
// Defer jQuery Parsing using the HTML5 defer property
if (!(is_admin() )) {
    function defer_parsing_of_js ( $url ) {
        if ( FALSE === strpos( $url, '.js' ) ) return $url;
        if ( strpos( $url, 'jquery.js' ) ) return $url;
        // return "$url' defer ";
        return "$url' defer onload='";
    }
    add_filter( 'clean_url', 'defer_parsing_of_js', 11, 1 );
}


// Disable Heartbeat
add_action( 'init', 'stop_heartbeat', 1 );
function stop_heartbeat() {
wp_deregister_script('heartbeat');
}

 

// Remove WP Version From Styles    
add_filter( 'style_loader_src', 'sdt_remove_ver_css_js', 9999 );
// Remove WP Version From Scripts
add_filter( 'script_loader_src', 'sdt_remove_ver_css_js', 9999 );

// Function to remove version numbers
function sdt_remove_ver_css_js( $src ) {
    if ( strpos( $src, 'ver=' ) )
        $src = remove_query_arg( 'ver', $src );
    return $src;
}

Categories
blog ecommerce Storefront WooCommerce wordpress

WooCommerce Storefront Child Theme: Remove Sidebar @ Single Product Page

Hide the sidebar on product pages of Woocommerce Storefront child theme. The following snippet disables the sidebar with no additional CSS required, whilst still making the product page content area 100% wide.

/**
 * Disable sidebar on product pages in Storefront.
 *
 * @param bool $is_active_sidebar
 * @param int|string $index
 *
 * @return bool
 */
function product_remove_sidebar( $is_active_sidebar, $index ) {
	if( $index !== "sidebar-1" ) {
		return $is_active_sidebar;
	}
if( ! is_product() ) {
return $is_active_sidebar;
}

return false;
}

add_filter( 'is_active_sidebar', product_remove_sidebar', 10, 2 );

 

code to the functions.php file in your Storefront child theme.

Categories
blog ecommerce magento magento 2

Importing product with images in Magento 2

Add new Product if no existing product is there in existing Magento store.

Go to System > Data Transfer > Export

Select entity type as product and click on on continue button that is in the bottom of the page. Once you click on continue button you can download the csv file of exported products . Use the exported sheet for reference to fill the values and then fill yours values accordingly , fill image name with file extension as .jpg or .png etc as mentioned in this screenshot:

then go to var folder create one folder having name ( import ) and place the image having same name as mentioned in the import csv file and then

Go to System > Data Transfer > Import

and select entity type as an product select import behavior as per yours need and then browse for file from Select File to Import browse option after this enter the path of import folder in our case it is var/import in the Images File Directory text box as mentioned in the following screenshot :

Then click on check data button on top right corner. If you did everything correct you will get this screen

enter image description here

Click import button and then do reindexing using CMD:

php bin/magento indexer:reindex

and then flush the cache:

php bin/magento cache:flush

and then check yours frontend it will show imported products with images.

http://magento.stackexchange.com/questions/85292/have-any-idea-how-can-create-or-import-product-in-magento-2?rq=1

Categories
blog ecommerce magento magento 2

Updating/Upgrading to Magento 2.0.6 (via composer)

Updating/Upgrading to Magento 2.0.6 (via composer)

composer require magento/product-community-edition 2.0.6 --no-update
composer update
rm -rf var/di var/generation
php bin/magento cache:clean
php bin/magento cache:flush
php bin/magento setup:upgrade
php bin/magento setup:di:compile
php bin/magento indexer:reindex
Categories
blog ecommerce magento magento 2

Moving Product Tabs – Magento 2

app/design/frontend/Vendor/theme_name/Magento_Catalog/page_layout/catalog_product_view.xml

<move element="product.info.details" destination="product.info.main" after="product_options_wrapper_bottom"/>
Categories
blog magento magento 2 SSH

php -f bin/magento setup:upgrade

php -f bin/magento setup:upgrade
Categories
blog ecommerce magento magento 2 mysql

magento 2 installation on digitalocean #bookmark

last part.

go to bin

php magento sampledata:deploy
php magento setup:di:compile
php magento setup:upgrade 
 

Categories
blog ecommerce magento magento 2 mysql

magento 2 installation digitalocean lamp bookmark

magento 2 installation digitalocean lamp #bookmark

apt-get update
apt-get install git wget
wget -O /usr/local/bin/composer http://getcomposer.org/composer.phar
chmod +x /usr/local/bin/composer
cd /var/www/html

download and upload magento file https://www.magentocommerce.com/download

upload and unzip 
tar xjf file.tar.bz2
cd /var/www/html/theory
composer install
chown -R root:www-data /var/www/html/theory
find /var/www/html/theory -type f -print0 | xargs -r0 chmod 640
find /var/www/html/theory -type d -print0 | xargs -r0 chmod 750
chmod -R g+w /var/www/html/theory/{pub,var}
chmod -R g+w /var/www/html/theory/{app/etc,vendor}

DATABASE

https://www.digitalocean.com/community/tutorials/a-basic-mysql-tutorial

mysql -u root -p
SHOW DATABASES;
CREATE DATABASE database name;
 DROP DATABASE database name;
 
GRANT ALL PRIVILEGES ON databasename.* TO 'databaseuser'@'localhost' IDENTIFIED BY 'passwordfordatabase';