How to remove SKU info on product page

Evening All,
I found this solution for removing the SKU details from the product page https://www.fmeextensions.com/blog/magento-2-how-to-remove-sku-from-product-page/ However, when I tried it and also tried playing around with it all that happened was my site wouldn’t show properly it just had lines of error code. Can someone advise the best solution for removing the SKU information? This is the code currently in the file that they suggested editing:
<?xml version=”1.0″?>
<!--
/**
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
-->
<page layout=”1column” xmlns:xsi=”http://www.w3.org/2001/XMLSchema-instance&#8221; xsi:noNamespaceSchemaLocation=”urn:magento:framework:View/Layout/etc/page_configuration.xsd”>
<body>
<move element=”page.main.title” destination=”product.info.main” before=”-” />
<!-- Move SKU to Bottom in Product Info Main -->
<move element=”product.info.stock.sku” destination=”product.info.main” after=”-” />
<block class=”Magento\Catalog\Block\Product\View” name=”ub_category_name” template=”Ubertheme_UbThemeHelper::product/view/get_category_name.phtml” />
<move element=”ub_category_name” destination=”product.info.main” before=”page.main.title”/>
</body>
</page>

3 answers

Profile photo of Ziven Staff 100280.00 $tone October 18, 2021
Public

Hi Jim,
I am sorry for replying to you this late as our team has just been back from our weekend. 

Can someone advise the best solution for removing the SKU information?

Please open the file: app\design\frontend\Ubertheme\atoms\Ubertheme_UbThemeHelper\layout\update_product_view__default.xml, add this code after line 5:

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

(Like this screenshot:
https://www.dropbox.com/s/oerh5bvvov26x6i/2021-10-18_09-04-57.png?dl=0
 
Then, flush the Magento cache.
 
Best Regards,
Ziven.

#1
Profile photo of James Weston 2860.00 $tone October 19, 2021
Public

Thanks Ziven, I followed your instructions and had the same code as the dropbox image. 
However, after saving and then flushing the cache the page crashed with error code pertaining to line 6 errors. I deleted it and the. page has come back. Is there something missing in the code?

1 exception(s):
Exception #0 (Magento\Framework\Config\Dom\ValidationException): Theme layout update file '/home/jdsoyqmy/public_html/app/design/frontend/Ubertheme/atoms/Ubertheme_UbThemeHelper/layout/update_product_view__default.xml' is not valid.
AttValue: " or ' expected
 Line: 6
attributes construct error
 Line: 6
Couldn't find end of Start Tag referenceBlock line 6
 Line: 6
AttValue: " or ' expected
 Line: 6
attributes construct error
 Line: 6
Couldn't find end of Start Tag referenceBlock line 6
 Line: 6

Exception #0 (Magento\Framework\Config\Dom\ValidationException): Theme layout update file '/home/jdsoyqmy/public_html/app/design/frontend/Ubertheme/atoms/Ubertheme_UbThemeHelper/layout/update_product_view__default.xml' is not valid.
AttValue: " or ' expected
 Line: 6
attributes construct error
 Line: 6
Couldn't find end of Start Tag referenceBlock line 6
 Line: 6
AttValue: " or ' expected
 Line: 6
attributes construct error
 Line: 6
Couldn't find end of Start Tag referenceBlock line 6
 Line: 6
<pre>#1 Magento\Framework\View\Model\Layout\Merge->getFileLayoutUpdatesXml() called at [generated/code/Magento/Framework/View/Model/Layout/Merge/Interceptor.php:185]
#2 Magento\Framework\View\Model\Layout\Merge\Interceptor->getFileLayoutUpdatesXml() called at [vendor/magento/framework/View/Model/Layout/Merge.php:598]
#3 Magento\Framework\View\Model\Layout\Merge->_fetchPackageLayoutUpdates() called at [vendor/magento/framework/View/Model/Layout/Merge.php:577]
#4 Magento\Framework\View\Model\Layout\Merge->_merge() called at [vendor/magento/framework/View/Model/Layout/Merge.php:496]
#5 Magento\Framework\View\Model\Layout\Merge->load() called at [generated/code/Magento/Framework/View/Model/Layout/Merge/Interceptor.php:149]
#6 Magento\Framework\View\Model\Layout\Merge\Interceptor->load() called at [vendor/magento/framework/View/Layout/Builder.php:86]
#7 Magento\Framework\View\Layout\Builder->loadLayoutUpdates() called at [vendor/magento/framework/View/Layout/Builder.php:63]
#8 Magento\Framework\View\Layout\Builder->build() called at [vendor/magento/framework/View/Layout.php:271]
#9 Magento\Framework\View\Layout->build() called at [vendor/magento/framework/View/Layout.php:896]
#10 Magento\Framework\View\Layout->getBlock() called at [generated/code/Magento/Framework/View/Layout/Interceptor.php:293]
#11 Magento\Framework\View\Layout\Interceptor->getBlock() called at [vendor/magento/module-cms/Helper/Page.php:218]
#12 Magento\Cms\Helper\Page->prepareResultPage() called at [vendor/magento/module-cms/Controller/Noroute/Index.php:47]
#13 Magento\Cms\Controller\Noroute\Index->execute() called at [vendor/magento/framework/Interception/Interceptor.php:58]
#14 Magento\Cms\Controller\Noroute\Index\Interceptor->___callParent() called at [vendor/magento/framework/Interception/Interceptor.php:138]
#15 Magento\Cms\Controller\Noroute\Index\Interceptor->Magento\Framework\Interception\{closure}() called at [vendor/magento/framework/Interception/Interceptor.php:153]
#16 Magento\Cms\Controller\Noroute\Index\Interceptor->___callPlugins() called at [generated/code/Magento/Cms/Controller/Noroute/Index/Interceptor.php:23]
#17 Magento\Cms\Controller\Noroute\Index\Interceptor->execute() called at [vendor/magento/framework/App/Action/Action.php:111]
#18 Magento\Framework\App\Action\Action->dispatch() called at [vendor/magento/framework/Interception/Interceptor.php:58]
#19 Magento\Cms\Controller\Noroute\Index\Interceptor->___callParent() called at [vendor/magento/framework/Interception/Interceptor.php:138]
#20 Magento\Cms\Controller\Noroute\Index\Interceptor->Magento\Framework\Interception\{closure}() called at [vendor/magento/framework/Interception/Interceptor.php:153]
#21 Magento\Cms\Controller\Noroute\Index\Interceptor->___callPlugins() called at [generated/code/Magento/Cms/Controller/Noroute/Index/Interceptor.php:32]
#22 Magento\Cms\Controller\Noroute\Index\Interceptor->dispatch() called at [vendor/magento/framework/App/FrontController.php:245]
#23 Magento\Framework\App\FrontController->getActionResponse() called at [vendor/magento/framework/App/FrontController.php:212]
#24 Magento\Framework\App\FrontController->processRequest() called at [vendor/magento/framework/App/FrontController.php:147]
#25 Magento\Framework\App\FrontController->dispatch() called at [vendor/magento/framework/Interception/Interceptor.php:58]
#26 Magento\Framework\App\FrontController\Interceptor->___callParent() called at [vendor/magento/framework/Interception/Interceptor.php:138]
#27 Magento\Framework\App\FrontController\Interceptor->Magento\Framework\Interception\{closure}() called at [vendor/magento/module-store/App/FrontController/Plugin/RequestPreprocessor.php:99]
#28 Magento\Store\App\FrontController\Plugin\RequestPreprocessor->aroundDispatch() called at [vendor/magento/framework/Interception/Interceptor.php:135]
#29 Magento\Framework\App\FrontController\Interceptor->Magento\Framework\Interception\{closure}() called at [vendor/magento/module-page-cache/Model/App/FrontController/BuiltinPlugin.php:75]
#30 Magento\PageCache\Model\App\FrontController\BuiltinPlugin->aroundDispatch() called at [vendor/magento/framework/Interception/Interceptor.php:135]
#31 Magento\Framework\App\FrontController\Interceptor->Magento\Framework\Interception\{closure}() called at [vendor/magento/framework/Interception/Interceptor.php:153]
#32 Magento\Framework\App\FrontController\Interceptor->___callPlugins() called at [generated/code/Magento/Framework/App/FrontController/Interceptor.php:23]
#33 Magento\Framework\App\FrontController\Interceptor->dispatch() called at [vendor/magento/framework/App/Http.php:116]
#34 Magento\Framework\App\Http->launch() called at [generated/code/Magento/Framework/App/Http/Interceptor.php:23]
#35 Magento\Framework\App\Http\Interceptor->launch() called at [vendor/magento/framework/App/Bootstrap.php:264]
#36 Magento\Framework\App\Bootstrap->run() called at [pub/index.php:29]
</pre>

Jim

#2

Please login or Register to Submit Answer

Written By

Comments