Skip to main content
25 votes

How to add or remove header.links in magento2?

I Hope this is useful for you, if you want to remove top.links Add default.xml file in this path app/design/frontend/vendor/theme/Magento_Theme/layout/default.xml <page xmlns:xsi="...
Rajkumar .E's user avatar
  • 3,580
16 votes
Accepted

Removing Welcome message from magento 2 - just xml

The welcome message is in html/header.phtml and the block is referenced from this XML file: /vendor/magento/module-theme/view/frontend/layout/default.xml. The template is referenced by the $_template ...
bassplayer7's user avatar
  • 2,216
10 votes

Override header Content and adding block

you use referenceBlock logo <referenceBlock name="logo"> <block class="Magento\Cms\Block\Block" name="test_links"> <arguments> <argument name="...
Fme Extensions's user avatar
10 votes
Accepted

Override header Content and adding block

You can do this by putting DIV over your logo and search box Also create a "container" for your static block (inside this you can call your static block) in logo.phtml. Now assign a class to each ...
Manoj Deswal's user avatar
  • 5,805
9 votes

How to add or remove header.links in magento2?

You can add and remove top links by add this line in your in Magento_Theme/layout/default.xml <referenceBlock name="header.links"> <block class="Magento\Framework\View\Element\Html\...
Bilal Usean's user avatar
9 votes

Adding a class to block Magento 2

There are 2 ways to do that:- 1- Add wrapping container to your block, like :- <container name="div.header.links" htmlTag="div" htmlClass="header_links" after="-"> <block class="...
Akhilesh Singh's user avatar
9 votes
Accepted

Magento 2: Add block above page-header

Change your default.xml to <?xml version="1.0"?> <page xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:View/Layout/etc/...
Prince Patel's user avatar
  • 22.8k
9 votes
Accepted

How to use customer token to access my account Query or Mutation in GraphQl

Please try this: Step 1: Get a bearer token: You can get a token by executing the signup mutation in the playground to create a new user. This is the signup mutation I ran: Request: mutation { ...
Narendra Vyas's user avatar
8 votes

how to add minicart in custom header block in magento2

Not Tried but you can add directly in phtml with below code <?php echo $this->getLayout() ->createBlock('Magento\Checkout\Block\Cart\Sidebar') ->setTemplate('...
Qaisar Satti's user avatar
  • 32.5k
8 votes

Magento 2: get customer().lastname in header.phtml

TLDR; You need to create a plugin in a custom module to override the Magento\Customer\CustomerData\Customer class. In your module's di.xml file: app/code/Vendor/LastName/Plugin/etc/di.xml <?xml ...
circlesix's user avatar
  • 4,323
7 votes
Accepted

Adding a class to block Magento 2

You can add css as described below by the element name="class" <block class="Magento\Framework\View\Element\Html\Links" name="header.links"> <arguments> <...
Krishna ijjada's user avatar
7 votes

cannot read property 'section loadurl' of undefined

The data that code references (sectionLoadUrl) is usually set in the following snippet that (should) be on every Magento front-end page <script type="text/x-magento-init"> {"*":{"...
Alana Storm's user avatar
  • 44.4k
7 votes
Accepted

Varnish - Error 503 Backend fetch failed (Header too long)

Please check if your runtime parameter changes actually took effect. Please run the following command to validate this: sudo varnishadm param.show | grep "^http_" This will display all ...
Thijs Feryn's user avatar
  • 1,081
6 votes

Adding a class to block Magento 2

Looking at the Magento\Framework\View\Element\Html\Link\Current code for version 2.2.6, there is no class argument supported (as documented in the previously accepted answer). However class is an ...
Adam Nemitoff's user avatar
6 votes

how to show my account link in header after successfully login in magento 2.0

Use the following code to show your account link in header: <?php $objectManagerlogin = \Magento\Framework\App\ObjectManager::getInstance(); $customerSession = $objectManagerlogin->get('...
Abhinav Singh's user avatar
6 votes
Accepted

magento2: add static block to header menu

Firstly you need to create static cms block about us. and add your content in content part. Now to add that block in header follow the below steps : Create/Add new category from product/categories ...
Manthan Dave's user avatar
  • 9,856
6 votes
Accepted

Wrapping search and cart in element Magento 2

I think something like this would work, though I am often wrong :) <referenceContainer name="header-wrapper"> <container name="block-wrapper-to-hold-the-items" as="block-wrapper-to-hold-...
Eamonn's user avatar
  • 508
6 votes
Accepted

Magento 2: What is Offloader header?

There is no difference. The default offloader header in Magento 2 is X-Forwarded-Proto, which matches the de facto standard. SSL_OFFLOADED on the other hand, was the default offloader header in ...
Fabian Schmengler's user avatar
6 votes

Magento 2 how to make sticky header for frontend?

You can add this piece of javascript code to your custom.js file and you can call this custom.js file either in default_head_blocks.xml or requirejs-config.js require([ "jquery" ], function($){ $(...
Sejal Shah's user avatar
  • 2,153
6 votes
Accepted

How to remove class `page-header` of tag `header` in Magento2?

1) To change class of Header Tag , edit your extended/custom default.xml app/design/frontend/vendor-name/theme-name/Magento_Theme/layout/default.xml Now add this line of code to change the class , ...
Manoj Deswal's user avatar
  • 5,805
6 votes

How i can change header button (sign in to log in) in magento 2 ? and which file i can change?

The simple way is to add default text with your text into app/design/frontend/Custom/default/i18n/en_US.csv like "Sign In","Login" clear cache after that php bin/magento cache:clean && ...
Hitesh's user avatar
  • 1,579
6 votes

How to get Email address in my phtml file in magento 2

Use helper to get email address in phtml. You can do it by following way. In phtml: $helper = $this->helper('Vendorname\Modulename\Helper\Data'); $email = $helper->getEmails(); //pass storeId ...
Sameer Bhayani's user avatar
5 votes

Magento 2 page-header background color

The easiest way to add simple styling to a magento 2 store is to add your code here: ADMIN > CONTENT > Design > CONFIGURATION Click Edit for the appropriate view (global, website or store) and Theme ...
Joshua34's user avatar
  • 2,317
5 votes

how to show my account link in header after successfully login in magento 2.0

Take a look at the places where Magento does this already. If you take a look at the customer modules default.xml: vendor/magento/module-customer/view/frontend/layout/default.xml You will see a call ...
circlesix's user avatar
  • 4,323
5 votes
Accepted

Magento 2 theme header - Welcome message

With regards to the XML, that block is called header and is set in \vendor\magento\module-theme\view\frontend\layout\default.xml You can remove it via a theme override at \app\design\frontend\...
RichardB's user avatar
  • 325
5 votes
Accepted

How can I move compare product link in header | Magento 2

The name of the element is catalog.compare.link as defined in Magento/Catalog/view/frontend/layout/default.xml : <block class="Magento\Framework\View\Element\Template" name="catalog....
Raphael at Digital Pianism's user avatar
5 votes
Accepted

How to change /blog url to some other url in Magento 1.9.2

You can do url rewriting from magento admin panel by following below steps : Logged into magento admin then click on Catalog -> URL Rewrite Management To add new url rewrite rule Click on Add Url ...
Manthan Dave's user avatar
  • 9,856
5 votes
Accepted

How to access the magento 2 graphql api using react js

We also faced the same issue for my Headless project. Try below two possible solutions. Solution 1 : Add the below line at the top of the index.php file. You can find the index.php file in the root ...
Jitendra Patel's user avatar
4 votes

how to add minicart in custom header block in magento2

Yes. Adding <?php echo $this->getLayout() ->createBlock('Magento\Checkout\Block\Cart\Sidebar') ->setTemplate('Magento_Checkout::cart/minicart.phtml') ->...
Bhanu Gupta's user avatar
4 votes
Accepted

Magento 2: Fatal error: Call to a member function getUsername() on null in

It seems you extends \Magento\Framework\App\Action\Action class in admin controller. Instead extend from \Magento\Backend\App\Action class, so it will redirect you to login page instead of throwing ...
Jaimin Parikh's user avatar

Only top scored, non community-wiki answers of a minimum length are eligible