Thursday, 27 October 2016

Magento2: How remove a element from the template?

Hello Guys
Welcome to Magento2.. keep learning magento2

Today i found one thing
We can easily remove the element from the frontend templates with out touching phml files

go to layout file of page(module) then add this tag
<referenceBlock name="blockname" remove="true"/>

Example:
i would like remove sku, price from the product details page
I have done this
go to app\design\frontend\yournamespace\yourtheme\Magento_Catalog\layout\catalog_product_view.xml

i have added
<referenceBlock name="product.info.stock.sku" remove="true"/>
<referenceBlock name="product.info.price" remove="true"/>
under body tag.
sku and price are removed from the page.

if you dont have xml file in ur theme just copy from the base, place it in your theme.
you can get base file from vendor\magento\module-catalog\view\frontend\layout\catalog_product_view.xml

Please let me know if you need any help.

Thanks

1 Comments:

At 30 June 2020 at 15:25 , Blogger Spruce London maintained by Acquablue said...


Thank you so much that was so easy most people writing about this ask to create but it is already there.
I inserted around line 40 and it worked

 

Post a Comment

Subscribe to Post Comments [Atom]

<< Home