2

Information: I'm using Magento 2.1 on CentOS Linux, my theme is a child of the built-in Luma theme.

When the theme I made is active, I want some blocks to be removed. Let's say I want to remove the SKU number from the product page.

What I do is:

  • In my theme folder, I add a file called Magento_Catalog/layout/catalog_product_view.xml, with the following content

    <?xml version="1.0"?>
    <page layout="1column" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:View/Layout/etc/page_configuration.xsd">
        <body>
            <referenceBlock name="product.info.sku" remove="true" />
        </body>
    </page>
    
  • I change the version in composer.json from 100.x.0 to 100.(x+1).0 (so for example if the current version is 100.2.0 I change it to 100.3.0). To be honest, don't really know if this is necessary.

  • I delete the <theme-name> folders from pub/static/frontend/<theme-vendor> and var/view_preprocessed/css/frontend/<theme-vendor>.

  • I run the following commands from the Magento root:

    sudo php bin/magento cache:clean
    sudo chown -R <user-of-Magento>:<group-of-that-user> *
    sudo php bin/magento setup:static-content:deploy nl_NL en_US
    sudo chown -R <user-of-Magento>:<group-of-that-user> *
    

But the block is still there! Unchanged. I tried other blocks, like the add to cart button, but also without success.

What should I do? Thanks in advance.

0

Try following code

<referenceContainer name="content">
    <referenceBlock name="product.info.sku" display="false" />
</referenceContainer>
  • Thanks, but still nothing. :( – Kevin Sep 14 '16 at 13:05
0

Delete the var directory and then run bin/magento setup:di:compile

0

Your name of that block is wrong :)

You should use this correct name:

<referenceBlock name="product.info.stock.sku" remove="true"/>

Then run:

php bin/magento setup:upgrade && php bin/magento cache:flush
0

Your code is correct:

<referenceBlock name="product.info.sku" remove="true" />

You don't need to change your composer.json or delete the static folders or change permissions or run the static content deployment.

You just have to clear the cache bin/magento cache:clean and see the changes. If it doesn't work you can try:

  • Check the browser cache (it's often just that)
  • Clear the cache manually. Delete the content of the var/cache folder
  • Make sure you are working on the right theme. Write something in a .phtml file as a test.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.