:::: MENU ::::

Magento 2 remove layered navigation

In this tutorial we will learn about a method in magento 2,Magento 2 remove layered navigation.Before starting the example i suppose you are familiar with magento 2 and are an advanced learner. If you are a beginner please start from the beginning.

Lets come to our topic.

Removing all categories

If you want to remove all the categories then add this code in your default.xml and add this to your theme or module.

 

default.xml

<referenceBlock name="catalog.leftnav" remove="true" />

 

Removing single category

Furthermore if you want to do this for single category you can do that from admin panel.For that,login to admin panel and then go to

Admin Panel > Products > Categories > YOUR PAGE > Design

  and add the following xml.

<referenceContainer name="catalog.leftnav" remove="true" />

That’s it from this tutorial. I hope it has help you in learning.

Author: Qaisar Satti
Category: Magento 2
Last Modified: September 30, 2018


Magento 2 get static url or skin url

Magento is a great ecommerce platform.It is a little complicated at times but it does provides many methods and functionalities to perform some tasks easily.Today we will talk about a method of Magento 2 get view or skin url in your phtml file.I try to explain things simply in this tutorial to make learning easy and simple.

I suppose you are already familiar with magento 2 and its working methodology hence you have reached this point.Below are some methods and examples.Lets start with an example where you want to learn how to get static url and skin url in magento 2.

Suppose your image is located in folder web/images.

Getting Url with image path and name

simply add the following code with image path and image name in your code.

<?php echo $block->getViewFileUrl('images/test.png') ?>

 

Add in CMS

And if you want to add in cms page simply add with image path.

{{view url='images/test.png'}}

Get specific module in a folder

Similarly if you want to get specific module image in web folder,it can be done by following code. In my case Module name is QaisarSatti_HelloWorld.You will have to specify your own module name.

<?php echo $block->getViewFileUrl('QaisarSatti_HelloWorld::images/test.png'); ?>

Image url in block file

Also If you want to get image url in your block file.Following piece of code will get the job done.

$this->getViewFileUrl('QaisarSatti_HelloWorld::images/test.png');

I hope the above examples and codes are simple and effective. Furthermore if you want to see where $block->getViewFileUrl() method is defined. You can see every method Magento\Framework\View\Element\Template file extends from Magento\Framework\View\Element\Template that extends with Magento\Framework\View\Element\AbstractBlock.php.

You will be able to see that on line 762 this method getViewFileUrl is defined.

That’s it from today’s tutorial. I hope this will help you learn.

Author: Qaisar Satti
Category: Magento 2
Last Modified: September 30, 2018


Remove any link from top links Magento 2

 
Hello and welcome to qaisar satti blog. In this tutorial we will try to learn that how one can “remove any link from top links in Magento 2”.Before starting i assume that you are already performing a task and are struck on this problem. So lets get to the point and find the solution.For removing the top-link you must know the name of the link which is to be removed. For example Register-link is for register-link link.

To make it more simpler, easy to learn and for knowledge,below is the list of top-links.

Top Links



register-link                Create Account Link

authorization-link       Sign In Link

 

wish-list-link              WishList Link

 

my-account-link        My Account Link

 

Right then i believe now you know the top links, now add below code in your default.xml to remove the link. For example,if you want to remove the Create Account Link So for that you have to add below xml code.

<referenceBlock name="top.links">
        <referenceBlock name="register-link" remove="true" />          
 </referenceBlock>

 

Similarly other links can be removed too by following the above mentioned method. I hope this tutorial will help you.

Author: Qaisar Satti
Category: Magento 2
Last Modified: September 26, 2018


Override default theme template files Magento 2

In this tutorial we will discuss about the topic how to override default theme template files in magento 2. I am assuming that you are already familiar with magento 2 and has the know how, how things work in magento 2. So i will directly switch to our topic, and if you are not familiar please start from the basics.Having said that lets come to our topic, so if you are doing the custom theme then you must know how to Override default theme template files in magento 2,in your custom theme.And if you want to override all the files then simply go to.

vendor/magento/module-theme/view/frontend/

And copy the templates folder in your theme. In my case theme name is “theme”. So go to my theme folder and create the Magento_Theme Folder. And paste the templates folder there. Now your theme structure will look like this.

app/design/frontend/QaisarSatti/theme/Magento_Theme/templates

If you want to override the single file like header.phtml. Then copy the file from

vendor/magento/module-theme/view/frontend/templates/html/header.phtml

Paste it in your theme.And the file structure then will look like this

app/design/frontend/QaisarSatti/theme/Magento_Theme/templates/html/header.phtml
Author: Qaisar Satti
Category: Magento 2
Last Modified: September 26, 2018