My Custom product tab not displaying in Magento 2Add new tab on product detail page Magento 2Magento 2.2.2...
How to deal with an incendiary email that was recalled
Is there any risk in sharing info about technologies and products we use with a supplier?
Can we harness gravitational potential energy?
What's a good word to describe a public place that looks like it wouldn't be rough?
Why is working on the same position for more than 15 years not a red flag?
Consequences of lack of rigour
Odd 74HCT1G125 behaviour
How can I get my players to come to the game session after agreeing to a date?
In Linux what happens if 1000 files in a directory are moved to another location while another 300 files were added to the source directory?
Why don't hotels mount air conditioning units outside the rooms?
What would the chemical name be for C13H8Cl3NO
A starship is travelling at 0.9c and collides with a small rock. Will it leave a clean hole through, or will more happen?
Using only 1s, make 29 with the minimum number of digits
How old is the day of 24 equal hours?
Why am I able to open Wireshark in macOS without root privileges?
Eww, those bytes are gross
Is there a Linux system call to create a “view” of a range of a file?
What is the use of 'de' preposition in 'Yo voy *de* compras todos los sábados'
Do theoretical physics suggest that gravity is the exchange of gravitons or deformation/bending of spacetime?
Does Skippy chunky peanut butter contain trans fat?
Play Zip, Zap, Zop
How would an AI self awareness kill switch work?
Quickly creating a sparse array
What are "industrial chops"?
My Custom product tab not displaying in Magento 2
Add new tab on product detail page Magento 2Magento 2.2.2 Add a custom tab on product pageMagento 2 - How to add new tab in Product detail pageAdd tab in magento2?Magento2 : Change order of Tabs on Product PageHow to show/hide custom tab in Product page from Magento 2Magento 2 how to create custom tabs in custom moduleHow do I add a custom TAB to magento2 product detailTemplate is not displaying in tab of my custom moduleAdd Custom Product Tab in MAGENTO 1.9 CELayouts and modulesHow to show/hide custom tab in Product page from Magento 2Why Getting categories and names on product view page Magento 2 fails?Magento 2 Fatal error: Uncaught Error: Cannot instantiate interface on catalog/product pages and widgetsProducts and categories not displaying in adminGENERATE THIS REPORT: main.INFO: Cache file with merged layout: LAYOUT_adminhtml_STORE1_Form is not displayed on panel admin Magento 2Magento 2.2.2 Prodcut quanity, color and sku not displaying under custom tab
I am trying to inject my custom product tab in storefront on product view page, but it's not displaying. For this I am written below code.
registration.php
<?php
MagentoFrameworkComponentComponentRegistrar::register(
MagentoFrameworkComponentComponentRegistrar::MODULE,
'Test_ProductTabs',
__DIR__
);
Test/ProductTabs/Block/CustomTab.php
<?php
namespace TestProductTabsBlock;
use MagentoCatalogModelProduct;
class CustomTab extends MagentoFrameworkViewElementTemplate{
/**
* @var Product
*/
protected $_product = null;
/**
* Core registry
*
* @var MagentoFrameworkRegistry
*/
protected $_coreRegistry = null;
/**
* @param MagentoFrameworkViewElementTemplateContext $context
* @param MagentoFrameworkRegistry $registry
* @param array $data
*/
public function __construct(
MagentoFrameworkViewElementTemplateContext $context,
MagentoFrameworkRegistry $registry,
array $data = []
) {
$this->_coreRegistry = $registry;
parent::__construct($context, $data);
}
/**
* @return Product
*/
public function getProduct()
{
if (!$this->_product) {
$this->_product = $this->_coreRegistry->registry('product');
}
return $this->_product;
}
}
Test/ProductTabs/etc/module.xml
<?xml version="1.0"?>
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:Module/etc/module.xsd">
<module name="Test_ProductTabs" setup_version="1.0.0">
<sequence>
<module name="Magento_Catalog"/>
</sequence>
</module>
</config>
Test/ProductTabs/view/layout/catalog_product_view.xml
<?xml version="1.0"?>
<page 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.details">
<block class="TestProductTabsBlockCustomTab" name="mycustom.tab" as="mycustom" template="Test_ProductTabs::kit.phtml" group="detailed_info">
<arguments>
<argument name="title" translate="true" xsi:type="string">Kit Components</argument>
</arguments>
</block>
</referenceBlock>
</body>
</page>
Test/ProductTabs/view/templates/kit.phtml
<h1>Kit Components</h1>
above code is not working for me. Any help on this?
product magento-2.1 tabs
|
show 2 more comments
I am trying to inject my custom product tab in storefront on product view page, but it's not displaying. For this I am written below code.
registration.php
<?php
MagentoFrameworkComponentComponentRegistrar::register(
MagentoFrameworkComponentComponentRegistrar::MODULE,
'Test_ProductTabs',
__DIR__
);
Test/ProductTabs/Block/CustomTab.php
<?php
namespace TestProductTabsBlock;
use MagentoCatalogModelProduct;
class CustomTab extends MagentoFrameworkViewElementTemplate{
/**
* @var Product
*/
protected $_product = null;
/**
* Core registry
*
* @var MagentoFrameworkRegistry
*/
protected $_coreRegistry = null;
/**
* @param MagentoFrameworkViewElementTemplateContext $context
* @param MagentoFrameworkRegistry $registry
* @param array $data
*/
public function __construct(
MagentoFrameworkViewElementTemplateContext $context,
MagentoFrameworkRegistry $registry,
array $data = []
) {
$this->_coreRegistry = $registry;
parent::__construct($context, $data);
}
/**
* @return Product
*/
public function getProduct()
{
if (!$this->_product) {
$this->_product = $this->_coreRegistry->registry('product');
}
return $this->_product;
}
}
Test/ProductTabs/etc/module.xml
<?xml version="1.0"?>
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:Module/etc/module.xsd">
<module name="Test_ProductTabs" setup_version="1.0.0">
<sequence>
<module name="Magento_Catalog"/>
</sequence>
</module>
</config>
Test/ProductTabs/view/layout/catalog_product_view.xml
<?xml version="1.0"?>
<page 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.details">
<block class="TestProductTabsBlockCustomTab" name="mycustom.tab" as="mycustom" template="Test_ProductTabs::kit.phtml" group="detailed_info">
<arguments>
<argument name="title" translate="true" xsi:type="string">Kit Components</argument>
</arguments>
</block>
</referenceBlock>
</body>
</page>
Test/ProductTabs/view/templates/kit.phtml
<h1>Kit Components</h1>
above code is not working for me. Any help on this?
product magento-2.1 tabs
Your controller file?
– Nitin Pawar
Nov 17 '16 at 10:39
@NitinPawar is it required?
– Bojjaiah
Nov 17 '16 at 10:40
Yes whenever i create the page i write controller for that page
– Nitin Pawar
Nov 17 '16 at 10:42
@NitinPawar I think not required. I am creating storefront. any way how can i link up with tab to controller? can you share the code if it possible?
– Bojjaiah
Nov 17 '16 at 10:44
@NitinPawar any help on this?
– Bojjaiah
Nov 17 '16 at 10:50
|
show 2 more comments
I am trying to inject my custom product tab in storefront on product view page, but it's not displaying. For this I am written below code.
registration.php
<?php
MagentoFrameworkComponentComponentRegistrar::register(
MagentoFrameworkComponentComponentRegistrar::MODULE,
'Test_ProductTabs',
__DIR__
);
Test/ProductTabs/Block/CustomTab.php
<?php
namespace TestProductTabsBlock;
use MagentoCatalogModelProduct;
class CustomTab extends MagentoFrameworkViewElementTemplate{
/**
* @var Product
*/
protected $_product = null;
/**
* Core registry
*
* @var MagentoFrameworkRegistry
*/
protected $_coreRegistry = null;
/**
* @param MagentoFrameworkViewElementTemplateContext $context
* @param MagentoFrameworkRegistry $registry
* @param array $data
*/
public function __construct(
MagentoFrameworkViewElementTemplateContext $context,
MagentoFrameworkRegistry $registry,
array $data = []
) {
$this->_coreRegistry = $registry;
parent::__construct($context, $data);
}
/**
* @return Product
*/
public function getProduct()
{
if (!$this->_product) {
$this->_product = $this->_coreRegistry->registry('product');
}
return $this->_product;
}
}
Test/ProductTabs/etc/module.xml
<?xml version="1.0"?>
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:Module/etc/module.xsd">
<module name="Test_ProductTabs" setup_version="1.0.0">
<sequence>
<module name="Magento_Catalog"/>
</sequence>
</module>
</config>
Test/ProductTabs/view/layout/catalog_product_view.xml
<?xml version="1.0"?>
<page 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.details">
<block class="TestProductTabsBlockCustomTab" name="mycustom.tab" as="mycustom" template="Test_ProductTabs::kit.phtml" group="detailed_info">
<arguments>
<argument name="title" translate="true" xsi:type="string">Kit Components</argument>
</arguments>
</block>
</referenceBlock>
</body>
</page>
Test/ProductTabs/view/templates/kit.phtml
<h1>Kit Components</h1>
above code is not working for me. Any help on this?
product magento-2.1 tabs
I am trying to inject my custom product tab in storefront on product view page, but it's not displaying. For this I am written below code.
registration.php
<?php
MagentoFrameworkComponentComponentRegistrar::register(
MagentoFrameworkComponentComponentRegistrar::MODULE,
'Test_ProductTabs',
__DIR__
);
Test/ProductTabs/Block/CustomTab.php
<?php
namespace TestProductTabsBlock;
use MagentoCatalogModelProduct;
class CustomTab extends MagentoFrameworkViewElementTemplate{
/**
* @var Product
*/
protected $_product = null;
/**
* Core registry
*
* @var MagentoFrameworkRegistry
*/
protected $_coreRegistry = null;
/**
* @param MagentoFrameworkViewElementTemplateContext $context
* @param MagentoFrameworkRegistry $registry
* @param array $data
*/
public function __construct(
MagentoFrameworkViewElementTemplateContext $context,
MagentoFrameworkRegistry $registry,
array $data = []
) {
$this->_coreRegistry = $registry;
parent::__construct($context, $data);
}
/**
* @return Product
*/
public function getProduct()
{
if (!$this->_product) {
$this->_product = $this->_coreRegistry->registry('product');
}
return $this->_product;
}
}
Test/ProductTabs/etc/module.xml
<?xml version="1.0"?>
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:Module/etc/module.xsd">
<module name="Test_ProductTabs" setup_version="1.0.0">
<sequence>
<module name="Magento_Catalog"/>
</sequence>
</module>
</config>
Test/ProductTabs/view/layout/catalog_product_view.xml
<?xml version="1.0"?>
<page 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.details">
<block class="TestProductTabsBlockCustomTab" name="mycustom.tab" as="mycustom" template="Test_ProductTabs::kit.phtml" group="detailed_info">
<arguments>
<argument name="title" translate="true" xsi:type="string">Kit Components</argument>
</arguments>
</block>
</referenceBlock>
</body>
</page>
Test/ProductTabs/view/templates/kit.phtml
<h1>Kit Components</h1>
above code is not working for me. Any help on this?
product magento-2.1 tabs
product magento-2.1 tabs
edited Nov 17 '16 at 11:35
Bojjaiah
asked Nov 17 '16 at 10:38
BojjaiahBojjaiah
2,4802571
2,4802571
Your controller file?
– Nitin Pawar
Nov 17 '16 at 10:39
@NitinPawar is it required?
– Bojjaiah
Nov 17 '16 at 10:40
Yes whenever i create the page i write controller for that page
– Nitin Pawar
Nov 17 '16 at 10:42
@NitinPawar I think not required. I am creating storefront. any way how can i link up with tab to controller? can you share the code if it possible?
– Bojjaiah
Nov 17 '16 at 10:44
@NitinPawar any help on this?
– Bojjaiah
Nov 17 '16 at 10:50
|
show 2 more comments
Your controller file?
– Nitin Pawar
Nov 17 '16 at 10:39
@NitinPawar is it required?
– Bojjaiah
Nov 17 '16 at 10:40
Yes whenever i create the page i write controller for that page
– Nitin Pawar
Nov 17 '16 at 10:42
@NitinPawar I think not required. I am creating storefront. any way how can i link up with tab to controller? can you share the code if it possible?
– Bojjaiah
Nov 17 '16 at 10:44
@NitinPawar any help on this?
– Bojjaiah
Nov 17 '16 at 10:50
Your controller file?
– Nitin Pawar
Nov 17 '16 at 10:39
Your controller file?
– Nitin Pawar
Nov 17 '16 at 10:39
@NitinPawar is it required?
– Bojjaiah
Nov 17 '16 at 10:40
@NitinPawar is it required?
– Bojjaiah
Nov 17 '16 at 10:40
Yes whenever i create the page i write controller for that page
– Nitin Pawar
Nov 17 '16 at 10:42
Yes whenever i create the page i write controller for that page
– Nitin Pawar
Nov 17 '16 at 10:42
@NitinPawar I think not required. I am creating storefront. any way how can i link up with tab to controller? can you share the code if it possible?
– Bojjaiah
Nov 17 '16 at 10:44
@NitinPawar I think not required. I am creating storefront. any way how can i link up with tab to controller? can you share the code if it possible?
– Bojjaiah
Nov 17 '16 at 10:44
@NitinPawar any help on this?
– Bojjaiah
Nov 17 '16 at 10:50
@NitinPawar any help on this?
– Bojjaiah
Nov 17 '16 at 10:50
|
show 2 more comments
5 Answers
5
active
oldest
votes
Try this in your layout file
<referenceBlock name="product.info.details">
<block class="MagentoCatalogBlockProductView" name="mycustom.tab" as="mycustom" template="Test_ProductTabs::kit.phtml" group="detailed_info">
<arguments>
<argument translate="true" name="title" xsi:type="string">Kit Components</argument>
</arguments>
</block>
</referenceBlock>
product related details all are available in MagentoCatalogBlockProductView
so no need to create custom block for get product details.
update
wrong layout file location! it should be
Test/ProductTabs/view/frontend/layout/catalog_product_view.xml
not working....
– Bojjaiah
Nov 17 '16 at 11:17
wrong layout location see my updated answer
– Bilal Usean
Nov 17 '16 at 11:22
1
Yes I have wrongly created folder structure. I forgot it. Thanks you. Is there any way to display @ 1 tab as my custom tab?
– Bojjaiah
Nov 17 '16 at 11:37
add a comment |
You code is fine just simple mistake you have done two mistake
please change file name
catalog_product_view_.xml
to
catalog_product_view.xml
change frontend layout and tempplate file location
Test/ProductTabs/view/layout/catalog_product_view_.xml
to
Test/ProductTabs/view/frontend/layout/catalog_product_view.xml
change template file location
Test/ProductTabs/view/templates/kit.phtml
to
Test/ProductTabs/view/frontend/templates/kit.phtml
that is typing mistake any way thanks bro...
– Bojjaiah
Nov 17 '16 at 11:38
Is there any way to display @ 1 tab as my custom tab?
– Bojjaiah
Nov 17 '16 at 11:39
@magentotwo refer link magento.stackexchange.com/questions/110796/…
– Prashant Valanda
Nov 17 '16 at 11:54
add a comment |
Try this code of layout:
<referenceContainer name="content">
<referenceBlock name="product.info.details">
<block class="TestProductTabsBlockCustomTab" name="customtab_display" template="template="Test_ProductTabs::kit.phtml" group="detailed_info">
<arguments>
<argument translate="true" name="title" xsi:type="string">Kit Components</argument>
</arguments>
</block>
</referenceBlock>
</referenceContainer>
not working....
– Bojjaiah
Nov 17 '16 at 10:58
remove /var and apply reindex and cache:flush
– Ronak Chauhan
Nov 17 '16 at 11:00
yes I executed above commandscache:flush, cache:clean
andindexer:reindex
but no luck.
– Bojjaiah
Nov 17 '16 at 11:06
may be you have issue in block so please removegetProduct()
then try again
– Ronak Chauhan
Nov 17 '16 at 11:10
1
for that you need to rewrite catalog view but here we are override that page
– Ronak Chauhan
Nov 17 '16 at 11:40
|
show 1 more comment
First go to the admin panel of your Magento store and then navigate to
Stores -> Product. Click on Add New Attribute and create new Attribute. (Set Attribute label DEMO and Attribute code demo)Now go to Stores -> Attribute Set and Add Attribute Set.
Now click on your Attribute Set and dragged unassigned Attribute (which you have created in first step) to Product Details and click Save.
Now go to your product edit page in admin panel and change the attribute name and template name which you have created in first and second step.
In app/code/Test/ProductTabs/etc/module.xml paste this code.
<?xml version="1.0"?>
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:Module/etc/module.xsd">
<module name="Test_ProductTabs" setup_version="1.0.0"></module>
</config>
In app/code/Test/ProductTabs/registration.php, paste this code.
<?php
MagentoFrameworkComponentComponentRegistrar::register(
MagentoFrameworkComponentComponentRegistrar::MODULE,
'Test_ProductTabs',
__DIR__
);
In app/code/Test/ProductTabs/view/frontend/layout/catalog_product_view.xml, paste this code.
<?xml version="1.0"?>
<page 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.details">
<block class="MagentoCatalogBlockProductView" name="demo.tab" template="Test_ProductTabs::custom_tab.phtml" group="detailed_info" >
<arguments>
<argument translate="true" name="title" xsi:type="string">Custom Tab</argument>
</arguments>
</block>
</referenceBlock>
</body>
</page>Now in app/code/Test/ProductTabs/view/frontend/templates/custom_tab.phtml, paste this code.
<?php
$product = $block->getProduct();
?>
<h1 style="color: #00aeed"><?php echo $product->getData('demo'); ?></h1>Now lauch your product page.
Create a whole module just to callecho $product->getData('demo');
in a custom template file? It seems easier to extendcatalog_product_view.xml
in the Theme - either by re-using theMagentoCatalogBlockProductViewDescription
block as described by @Holly, or even by adding your customcustom_tab.phtml
to the theme.
– thaddeusmt
Oct 9 '17 at 4:07
Nicely explain and helpful
– Nitesh
Nov 26 '17 at 12:34
add a comment |
I think the better way to do this is to follow the same approach Magento uses to add the description
attribute as one of the tabs on the product details page.
First create your attribute, lets say it's tech_spec
and add it to whichever attribute sets you want it to so I can be updated from the Manage Manage Products page.
Then create/update your appcode[NameSpace][ModuleName]viewfrontendlayoutcatalog_product_view.xml file with:
<referenceBlock name="product.info.details">
<block class="MagentoCatalogBlockProductViewDescription" name="product.info.tech.spec" template="product/view/attribute.phtml" group="detailed_info">
<arguments>
<argument name="at_call" xsi:type="string">getTechSpec</argument>
<argument name="at_code" xsi:type="string">tech_spec</argument>
<argument name="css_class" xsi:type="string">tech-spec</argument>
<argument name="at_label" xsi:type="string">none</argument>
<argument name="title" translate="true" xsi:type="string">Technical Specification</argument>
</arguments>
</block>
</referenceBlock>
Alternatively if you don't want to add an attribute you can add a template instead.
<referenceBlock name="product.info.details">
<block class="MagentoCatalogBlockProductView" name="product.info.tech.spec" template="Magento_Catalog::product/view/tech-spec.phtml" group="detailed_info" >
<arguments>
<argument translate="true" name="title" xsi:type="string">Technical Specification</argument>
</arguments>
</block>
</referenceBlock>
add a comment |
Your Answer
StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "479"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});
function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: false,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: null,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});
}
});
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fmagento.stackexchange.com%2fquestions%2f146229%2fmy-custom-product-tab-not-displaying-in-magento-2%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
5 Answers
5
active
oldest
votes
5 Answers
5
active
oldest
votes
active
oldest
votes
active
oldest
votes
Try this in your layout file
<referenceBlock name="product.info.details">
<block class="MagentoCatalogBlockProductView" name="mycustom.tab" as="mycustom" template="Test_ProductTabs::kit.phtml" group="detailed_info">
<arguments>
<argument translate="true" name="title" xsi:type="string">Kit Components</argument>
</arguments>
</block>
</referenceBlock>
product related details all are available in MagentoCatalogBlockProductView
so no need to create custom block for get product details.
update
wrong layout file location! it should be
Test/ProductTabs/view/frontend/layout/catalog_product_view.xml
not working....
– Bojjaiah
Nov 17 '16 at 11:17
wrong layout location see my updated answer
– Bilal Usean
Nov 17 '16 at 11:22
1
Yes I have wrongly created folder structure. I forgot it. Thanks you. Is there any way to display @ 1 tab as my custom tab?
– Bojjaiah
Nov 17 '16 at 11:37
add a comment |
Try this in your layout file
<referenceBlock name="product.info.details">
<block class="MagentoCatalogBlockProductView" name="mycustom.tab" as="mycustom" template="Test_ProductTabs::kit.phtml" group="detailed_info">
<arguments>
<argument translate="true" name="title" xsi:type="string">Kit Components</argument>
</arguments>
</block>
</referenceBlock>
product related details all are available in MagentoCatalogBlockProductView
so no need to create custom block for get product details.
update
wrong layout file location! it should be
Test/ProductTabs/view/frontend/layout/catalog_product_view.xml
not working....
– Bojjaiah
Nov 17 '16 at 11:17
wrong layout location see my updated answer
– Bilal Usean
Nov 17 '16 at 11:22
1
Yes I have wrongly created folder structure. I forgot it. Thanks you. Is there any way to display @ 1 tab as my custom tab?
– Bojjaiah
Nov 17 '16 at 11:37
add a comment |
Try this in your layout file
<referenceBlock name="product.info.details">
<block class="MagentoCatalogBlockProductView" name="mycustom.tab" as="mycustom" template="Test_ProductTabs::kit.phtml" group="detailed_info">
<arguments>
<argument translate="true" name="title" xsi:type="string">Kit Components</argument>
</arguments>
</block>
</referenceBlock>
product related details all are available in MagentoCatalogBlockProductView
so no need to create custom block for get product details.
update
wrong layout file location! it should be
Test/ProductTabs/view/frontend/layout/catalog_product_view.xml
Try this in your layout file
<referenceBlock name="product.info.details">
<block class="MagentoCatalogBlockProductView" name="mycustom.tab" as="mycustom" template="Test_ProductTabs::kit.phtml" group="detailed_info">
<arguments>
<argument translate="true" name="title" xsi:type="string">Kit Components</argument>
</arguments>
</block>
</referenceBlock>
product related details all are available in MagentoCatalogBlockProductView
so no need to create custom block for get product details.
update
wrong layout file location! it should be
Test/ProductTabs/view/frontend/layout/catalog_product_view.xml
edited Nov 17 '16 at 11:42
answered Nov 17 '16 at 11:07
Bilal UseanBilal Usean
4,90923689
4,90923689
not working....
– Bojjaiah
Nov 17 '16 at 11:17
wrong layout location see my updated answer
– Bilal Usean
Nov 17 '16 at 11:22
1
Yes I have wrongly created folder structure. I forgot it. Thanks you. Is there any way to display @ 1 tab as my custom tab?
– Bojjaiah
Nov 17 '16 at 11:37
add a comment |
not working....
– Bojjaiah
Nov 17 '16 at 11:17
wrong layout location see my updated answer
– Bilal Usean
Nov 17 '16 at 11:22
1
Yes I have wrongly created folder structure. I forgot it. Thanks you. Is there any way to display @ 1 tab as my custom tab?
– Bojjaiah
Nov 17 '16 at 11:37
not working....
– Bojjaiah
Nov 17 '16 at 11:17
not working....
– Bojjaiah
Nov 17 '16 at 11:17
wrong layout location see my updated answer
– Bilal Usean
Nov 17 '16 at 11:22
wrong layout location see my updated answer
– Bilal Usean
Nov 17 '16 at 11:22
1
1
Yes I have wrongly created folder structure. I forgot it. Thanks you. Is there any way to display @ 1 tab as my custom tab?
– Bojjaiah
Nov 17 '16 at 11:37
Yes I have wrongly created folder structure. I forgot it. Thanks you. Is there any way to display @ 1 tab as my custom tab?
– Bojjaiah
Nov 17 '16 at 11:37
add a comment |
You code is fine just simple mistake you have done two mistake
please change file name
catalog_product_view_.xml
to
catalog_product_view.xml
change frontend layout and tempplate file location
Test/ProductTabs/view/layout/catalog_product_view_.xml
to
Test/ProductTabs/view/frontend/layout/catalog_product_view.xml
change template file location
Test/ProductTabs/view/templates/kit.phtml
to
Test/ProductTabs/view/frontend/templates/kit.phtml
that is typing mistake any way thanks bro...
– Bojjaiah
Nov 17 '16 at 11:38
Is there any way to display @ 1 tab as my custom tab?
– Bojjaiah
Nov 17 '16 at 11:39
@magentotwo refer link magento.stackexchange.com/questions/110796/…
– Prashant Valanda
Nov 17 '16 at 11:54
add a comment |
You code is fine just simple mistake you have done two mistake
please change file name
catalog_product_view_.xml
to
catalog_product_view.xml
change frontend layout and tempplate file location
Test/ProductTabs/view/layout/catalog_product_view_.xml
to
Test/ProductTabs/view/frontend/layout/catalog_product_view.xml
change template file location
Test/ProductTabs/view/templates/kit.phtml
to
Test/ProductTabs/view/frontend/templates/kit.phtml
that is typing mistake any way thanks bro...
– Bojjaiah
Nov 17 '16 at 11:38
Is there any way to display @ 1 tab as my custom tab?
– Bojjaiah
Nov 17 '16 at 11:39
@magentotwo refer link magento.stackexchange.com/questions/110796/…
– Prashant Valanda
Nov 17 '16 at 11:54
add a comment |
You code is fine just simple mistake you have done two mistake
please change file name
catalog_product_view_.xml
to
catalog_product_view.xml
change frontend layout and tempplate file location
Test/ProductTabs/view/layout/catalog_product_view_.xml
to
Test/ProductTabs/view/frontend/layout/catalog_product_view.xml
change template file location
Test/ProductTabs/view/templates/kit.phtml
to
Test/ProductTabs/view/frontend/templates/kit.phtml
You code is fine just simple mistake you have done two mistake
please change file name
catalog_product_view_.xml
to
catalog_product_view.xml
change frontend layout and tempplate file location
Test/ProductTabs/view/layout/catalog_product_view_.xml
to
Test/ProductTabs/view/frontend/layout/catalog_product_view.xml
change template file location
Test/ProductTabs/view/templates/kit.phtml
to
Test/ProductTabs/view/frontend/templates/kit.phtml
answered Nov 17 '16 at 11:32
Prashant ValandaPrashant Valanda
9,76912354
9,76912354
that is typing mistake any way thanks bro...
– Bojjaiah
Nov 17 '16 at 11:38
Is there any way to display @ 1 tab as my custom tab?
– Bojjaiah
Nov 17 '16 at 11:39
@magentotwo refer link magento.stackexchange.com/questions/110796/…
– Prashant Valanda
Nov 17 '16 at 11:54
add a comment |
that is typing mistake any way thanks bro...
– Bojjaiah
Nov 17 '16 at 11:38
Is there any way to display @ 1 tab as my custom tab?
– Bojjaiah
Nov 17 '16 at 11:39
@magentotwo refer link magento.stackexchange.com/questions/110796/…
– Prashant Valanda
Nov 17 '16 at 11:54
that is typing mistake any way thanks bro...
– Bojjaiah
Nov 17 '16 at 11:38
that is typing mistake any way thanks bro...
– Bojjaiah
Nov 17 '16 at 11:38
Is there any way to display @ 1 tab as my custom tab?
– Bojjaiah
Nov 17 '16 at 11:39
Is there any way to display @ 1 tab as my custom tab?
– Bojjaiah
Nov 17 '16 at 11:39
@magentotwo refer link magento.stackexchange.com/questions/110796/…
– Prashant Valanda
Nov 17 '16 at 11:54
@magentotwo refer link magento.stackexchange.com/questions/110796/…
– Prashant Valanda
Nov 17 '16 at 11:54
add a comment |
Try this code of layout:
<referenceContainer name="content">
<referenceBlock name="product.info.details">
<block class="TestProductTabsBlockCustomTab" name="customtab_display" template="template="Test_ProductTabs::kit.phtml" group="detailed_info">
<arguments>
<argument translate="true" name="title" xsi:type="string">Kit Components</argument>
</arguments>
</block>
</referenceBlock>
</referenceContainer>
not working....
– Bojjaiah
Nov 17 '16 at 10:58
remove /var and apply reindex and cache:flush
– Ronak Chauhan
Nov 17 '16 at 11:00
yes I executed above commandscache:flush, cache:clean
andindexer:reindex
but no luck.
– Bojjaiah
Nov 17 '16 at 11:06
may be you have issue in block so please removegetProduct()
then try again
– Ronak Chauhan
Nov 17 '16 at 11:10
1
for that you need to rewrite catalog view but here we are override that page
– Ronak Chauhan
Nov 17 '16 at 11:40
|
show 1 more comment
Try this code of layout:
<referenceContainer name="content">
<referenceBlock name="product.info.details">
<block class="TestProductTabsBlockCustomTab" name="customtab_display" template="template="Test_ProductTabs::kit.phtml" group="detailed_info">
<arguments>
<argument translate="true" name="title" xsi:type="string">Kit Components</argument>
</arguments>
</block>
</referenceBlock>
</referenceContainer>
not working....
– Bojjaiah
Nov 17 '16 at 10:58
remove /var and apply reindex and cache:flush
– Ronak Chauhan
Nov 17 '16 at 11:00
yes I executed above commandscache:flush, cache:clean
andindexer:reindex
but no luck.
– Bojjaiah
Nov 17 '16 at 11:06
may be you have issue in block so please removegetProduct()
then try again
– Ronak Chauhan
Nov 17 '16 at 11:10
1
for that you need to rewrite catalog view but here we are override that page
– Ronak Chauhan
Nov 17 '16 at 11:40
|
show 1 more comment
Try this code of layout:
<referenceContainer name="content">
<referenceBlock name="product.info.details">
<block class="TestProductTabsBlockCustomTab" name="customtab_display" template="template="Test_ProductTabs::kit.phtml" group="detailed_info">
<arguments>
<argument translate="true" name="title" xsi:type="string">Kit Components</argument>
</arguments>
</block>
</referenceBlock>
</referenceContainer>
Try this code of layout:
<referenceContainer name="content">
<referenceBlock name="product.info.details">
<block class="TestProductTabsBlockCustomTab" name="customtab_display" template="template="Test_ProductTabs::kit.phtml" group="detailed_info">
<arguments>
<argument translate="true" name="title" xsi:type="string">Kit Components</argument>
</arguments>
</block>
</referenceBlock>
</referenceContainer>
edited Nov 13 '17 at 9:01
Murtuza Zabuawala
12.5k73362
12.5k73362
answered Nov 17 '16 at 10:40
Ronak ChauhanRonak Chauhan
4,23011449
4,23011449
not working....
– Bojjaiah
Nov 17 '16 at 10:58
remove /var and apply reindex and cache:flush
– Ronak Chauhan
Nov 17 '16 at 11:00
yes I executed above commandscache:flush, cache:clean
andindexer:reindex
but no luck.
– Bojjaiah
Nov 17 '16 at 11:06
may be you have issue in block so please removegetProduct()
then try again
– Ronak Chauhan
Nov 17 '16 at 11:10
1
for that you need to rewrite catalog view but here we are override that page
– Ronak Chauhan
Nov 17 '16 at 11:40
|
show 1 more comment
not working....
– Bojjaiah
Nov 17 '16 at 10:58
remove /var and apply reindex and cache:flush
– Ronak Chauhan
Nov 17 '16 at 11:00
yes I executed above commandscache:flush, cache:clean
andindexer:reindex
but no luck.
– Bojjaiah
Nov 17 '16 at 11:06
may be you have issue in block so please removegetProduct()
then try again
– Ronak Chauhan
Nov 17 '16 at 11:10
1
for that you need to rewrite catalog view but here we are override that page
– Ronak Chauhan
Nov 17 '16 at 11:40
not working....
– Bojjaiah
Nov 17 '16 at 10:58
not working....
– Bojjaiah
Nov 17 '16 at 10:58
remove /var and apply reindex and cache:flush
– Ronak Chauhan
Nov 17 '16 at 11:00
remove /var and apply reindex and cache:flush
– Ronak Chauhan
Nov 17 '16 at 11:00
yes I executed above commands
cache:flush, cache:clean
and indexer:reindex
but no luck.– Bojjaiah
Nov 17 '16 at 11:06
yes I executed above commands
cache:flush, cache:clean
and indexer:reindex
but no luck.– Bojjaiah
Nov 17 '16 at 11:06
may be you have issue in block so please remove
getProduct()
then try again– Ronak Chauhan
Nov 17 '16 at 11:10
may be you have issue in block so please remove
getProduct()
then try again– Ronak Chauhan
Nov 17 '16 at 11:10
1
1
for that you need to rewrite catalog view but here we are override that page
– Ronak Chauhan
Nov 17 '16 at 11:40
for that you need to rewrite catalog view but here we are override that page
– Ronak Chauhan
Nov 17 '16 at 11:40
|
show 1 more comment
First go to the admin panel of your Magento store and then navigate to
Stores -> Product. Click on Add New Attribute and create new Attribute. (Set Attribute label DEMO and Attribute code demo)Now go to Stores -> Attribute Set and Add Attribute Set.
Now click on your Attribute Set and dragged unassigned Attribute (which you have created in first step) to Product Details and click Save.
Now go to your product edit page in admin panel and change the attribute name and template name which you have created in first and second step.
In app/code/Test/ProductTabs/etc/module.xml paste this code.
<?xml version="1.0"?>
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:Module/etc/module.xsd">
<module name="Test_ProductTabs" setup_version="1.0.0"></module>
</config>
In app/code/Test/ProductTabs/registration.php, paste this code.
<?php
MagentoFrameworkComponentComponentRegistrar::register(
MagentoFrameworkComponentComponentRegistrar::MODULE,
'Test_ProductTabs',
__DIR__
);
In app/code/Test/ProductTabs/view/frontend/layout/catalog_product_view.xml, paste this code.
<?xml version="1.0"?>
<page 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.details">
<block class="MagentoCatalogBlockProductView" name="demo.tab" template="Test_ProductTabs::custom_tab.phtml" group="detailed_info" >
<arguments>
<argument translate="true" name="title" xsi:type="string">Custom Tab</argument>
</arguments>
</block>
</referenceBlock>
</body>
</page>Now in app/code/Test/ProductTabs/view/frontend/templates/custom_tab.phtml, paste this code.
<?php
$product = $block->getProduct();
?>
<h1 style="color: #00aeed"><?php echo $product->getData('demo'); ?></h1>Now lauch your product page.
Create a whole module just to callecho $product->getData('demo');
in a custom template file? It seems easier to extendcatalog_product_view.xml
in the Theme - either by re-using theMagentoCatalogBlockProductViewDescription
block as described by @Holly, or even by adding your customcustom_tab.phtml
to the theme.
– thaddeusmt
Oct 9 '17 at 4:07
Nicely explain and helpful
– Nitesh
Nov 26 '17 at 12:34
add a comment |
First go to the admin panel of your Magento store and then navigate to
Stores -> Product. Click on Add New Attribute and create new Attribute. (Set Attribute label DEMO and Attribute code demo)Now go to Stores -> Attribute Set and Add Attribute Set.
Now click on your Attribute Set and dragged unassigned Attribute (which you have created in first step) to Product Details and click Save.
Now go to your product edit page in admin panel and change the attribute name and template name which you have created in first and second step.
In app/code/Test/ProductTabs/etc/module.xml paste this code.
<?xml version="1.0"?>
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:Module/etc/module.xsd">
<module name="Test_ProductTabs" setup_version="1.0.0"></module>
</config>
In app/code/Test/ProductTabs/registration.php, paste this code.
<?php
MagentoFrameworkComponentComponentRegistrar::register(
MagentoFrameworkComponentComponentRegistrar::MODULE,
'Test_ProductTabs',
__DIR__
);
In app/code/Test/ProductTabs/view/frontend/layout/catalog_product_view.xml, paste this code.
<?xml version="1.0"?>
<page 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.details">
<block class="MagentoCatalogBlockProductView" name="demo.tab" template="Test_ProductTabs::custom_tab.phtml" group="detailed_info" >
<arguments>
<argument translate="true" name="title" xsi:type="string">Custom Tab</argument>
</arguments>
</block>
</referenceBlock>
</body>
</page>Now in app/code/Test/ProductTabs/view/frontend/templates/custom_tab.phtml, paste this code.
<?php
$product = $block->getProduct();
?>
<h1 style="color: #00aeed"><?php echo $product->getData('demo'); ?></h1>Now lauch your product page.
Create a whole module just to callecho $product->getData('demo');
in a custom template file? It seems easier to extendcatalog_product_view.xml
in the Theme - either by re-using theMagentoCatalogBlockProductViewDescription
block as described by @Holly, or even by adding your customcustom_tab.phtml
to the theme.
– thaddeusmt
Oct 9 '17 at 4:07
Nicely explain and helpful
– Nitesh
Nov 26 '17 at 12:34
add a comment |
First go to the admin panel of your Magento store and then navigate to
Stores -> Product. Click on Add New Attribute and create new Attribute. (Set Attribute label DEMO and Attribute code demo)Now go to Stores -> Attribute Set and Add Attribute Set.
Now click on your Attribute Set and dragged unassigned Attribute (which you have created in first step) to Product Details and click Save.
Now go to your product edit page in admin panel and change the attribute name and template name which you have created in first and second step.
In app/code/Test/ProductTabs/etc/module.xml paste this code.
<?xml version="1.0"?>
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:Module/etc/module.xsd">
<module name="Test_ProductTabs" setup_version="1.0.0"></module>
</config>
In app/code/Test/ProductTabs/registration.php, paste this code.
<?php
MagentoFrameworkComponentComponentRegistrar::register(
MagentoFrameworkComponentComponentRegistrar::MODULE,
'Test_ProductTabs',
__DIR__
);
In app/code/Test/ProductTabs/view/frontend/layout/catalog_product_view.xml, paste this code.
<?xml version="1.0"?>
<page 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.details">
<block class="MagentoCatalogBlockProductView" name="demo.tab" template="Test_ProductTabs::custom_tab.phtml" group="detailed_info" >
<arguments>
<argument translate="true" name="title" xsi:type="string">Custom Tab</argument>
</arguments>
</block>
</referenceBlock>
</body>
</page>Now in app/code/Test/ProductTabs/view/frontend/templates/custom_tab.phtml, paste this code.
<?php
$product = $block->getProduct();
?>
<h1 style="color: #00aeed"><?php echo $product->getData('demo'); ?></h1>Now lauch your product page.
First go to the admin panel of your Magento store and then navigate to
Stores -> Product. Click on Add New Attribute and create new Attribute. (Set Attribute label DEMO and Attribute code demo)Now go to Stores -> Attribute Set and Add Attribute Set.
Now click on your Attribute Set and dragged unassigned Attribute (which you have created in first step) to Product Details and click Save.
Now go to your product edit page in admin panel and change the attribute name and template name which you have created in first and second step.
In app/code/Test/ProductTabs/etc/module.xml paste this code.
<?xml version="1.0"?>
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:Module/etc/module.xsd">
<module name="Test_ProductTabs" setup_version="1.0.0"></module>
</config>
In app/code/Test/ProductTabs/registration.php, paste this code.
<?php
MagentoFrameworkComponentComponentRegistrar::register(
MagentoFrameworkComponentComponentRegistrar::MODULE,
'Test_ProductTabs',
__DIR__
);
In app/code/Test/ProductTabs/view/frontend/layout/catalog_product_view.xml, paste this code.
<?xml version="1.0"?>
<page 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.details">
<block class="MagentoCatalogBlockProductView" name="demo.tab" template="Test_ProductTabs::custom_tab.phtml" group="detailed_info" >
<arguments>
<argument translate="true" name="title" xsi:type="string">Custom Tab</argument>
</arguments>
</block>
</referenceBlock>
</body>
</page>Now in app/code/Test/ProductTabs/view/frontend/templates/custom_tab.phtml, paste this code.
<?php
$product = $block->getProduct();
?>
<h1 style="color: #00aeed"><?php echo $product->getData('demo'); ?></h1>Now lauch your product page.
edited Nov 18 '16 at 16:13
answered Nov 18 '16 at 16:06
Muneeb SyedMuneeb Syed
627316
627316
Create a whole module just to callecho $product->getData('demo');
in a custom template file? It seems easier to extendcatalog_product_view.xml
in the Theme - either by re-using theMagentoCatalogBlockProductViewDescription
block as described by @Holly, or even by adding your customcustom_tab.phtml
to the theme.
– thaddeusmt
Oct 9 '17 at 4:07
Nicely explain and helpful
– Nitesh
Nov 26 '17 at 12:34
add a comment |
Create a whole module just to callecho $product->getData('demo');
in a custom template file? It seems easier to extendcatalog_product_view.xml
in the Theme - either by re-using theMagentoCatalogBlockProductViewDescription
block as described by @Holly, or even by adding your customcustom_tab.phtml
to the theme.
– thaddeusmt
Oct 9 '17 at 4:07
Nicely explain and helpful
– Nitesh
Nov 26 '17 at 12:34
Create a whole module just to call
echo $product->getData('demo');
in a custom template file? It seems easier to extend catalog_product_view.xml
in the Theme - either by re-using the MagentoCatalogBlockProductViewDescription
block as described by @Holly, or even by adding your custom custom_tab.phtml
to the theme.– thaddeusmt
Oct 9 '17 at 4:07
Create a whole module just to call
echo $product->getData('demo');
in a custom template file? It seems easier to extend catalog_product_view.xml
in the Theme - either by re-using the MagentoCatalogBlockProductViewDescription
block as described by @Holly, or even by adding your custom custom_tab.phtml
to the theme.– thaddeusmt
Oct 9 '17 at 4:07
Nicely explain and helpful
– Nitesh
Nov 26 '17 at 12:34
Nicely explain and helpful
– Nitesh
Nov 26 '17 at 12:34
add a comment |
I think the better way to do this is to follow the same approach Magento uses to add the description
attribute as one of the tabs on the product details page.
First create your attribute, lets say it's tech_spec
and add it to whichever attribute sets you want it to so I can be updated from the Manage Manage Products page.
Then create/update your appcode[NameSpace][ModuleName]viewfrontendlayoutcatalog_product_view.xml file with:
<referenceBlock name="product.info.details">
<block class="MagentoCatalogBlockProductViewDescription" name="product.info.tech.spec" template="product/view/attribute.phtml" group="detailed_info">
<arguments>
<argument name="at_call" xsi:type="string">getTechSpec</argument>
<argument name="at_code" xsi:type="string">tech_spec</argument>
<argument name="css_class" xsi:type="string">tech-spec</argument>
<argument name="at_label" xsi:type="string">none</argument>
<argument name="title" translate="true" xsi:type="string">Technical Specification</argument>
</arguments>
</block>
</referenceBlock>
Alternatively if you don't want to add an attribute you can add a template instead.
<referenceBlock name="product.info.details">
<block class="MagentoCatalogBlockProductView" name="product.info.tech.spec" template="Magento_Catalog::product/view/tech-spec.phtml" group="detailed_info" >
<arguments>
<argument translate="true" name="title" xsi:type="string">Technical Specification</argument>
</arguments>
</block>
</referenceBlock>
add a comment |
I think the better way to do this is to follow the same approach Magento uses to add the description
attribute as one of the tabs on the product details page.
First create your attribute, lets say it's tech_spec
and add it to whichever attribute sets you want it to so I can be updated from the Manage Manage Products page.
Then create/update your appcode[NameSpace][ModuleName]viewfrontendlayoutcatalog_product_view.xml file with:
<referenceBlock name="product.info.details">
<block class="MagentoCatalogBlockProductViewDescription" name="product.info.tech.spec" template="product/view/attribute.phtml" group="detailed_info">
<arguments>
<argument name="at_call" xsi:type="string">getTechSpec</argument>
<argument name="at_code" xsi:type="string">tech_spec</argument>
<argument name="css_class" xsi:type="string">tech-spec</argument>
<argument name="at_label" xsi:type="string">none</argument>
<argument name="title" translate="true" xsi:type="string">Technical Specification</argument>
</arguments>
</block>
</referenceBlock>
Alternatively if you don't want to add an attribute you can add a template instead.
<referenceBlock name="product.info.details">
<block class="MagentoCatalogBlockProductView" name="product.info.tech.spec" template="Magento_Catalog::product/view/tech-spec.phtml" group="detailed_info" >
<arguments>
<argument translate="true" name="title" xsi:type="string">Technical Specification</argument>
</arguments>
</block>
</referenceBlock>
add a comment |
I think the better way to do this is to follow the same approach Magento uses to add the description
attribute as one of the tabs on the product details page.
First create your attribute, lets say it's tech_spec
and add it to whichever attribute sets you want it to so I can be updated from the Manage Manage Products page.
Then create/update your appcode[NameSpace][ModuleName]viewfrontendlayoutcatalog_product_view.xml file with:
<referenceBlock name="product.info.details">
<block class="MagentoCatalogBlockProductViewDescription" name="product.info.tech.spec" template="product/view/attribute.phtml" group="detailed_info">
<arguments>
<argument name="at_call" xsi:type="string">getTechSpec</argument>
<argument name="at_code" xsi:type="string">tech_spec</argument>
<argument name="css_class" xsi:type="string">tech-spec</argument>
<argument name="at_label" xsi:type="string">none</argument>
<argument name="title" translate="true" xsi:type="string">Technical Specification</argument>
</arguments>
</block>
</referenceBlock>
Alternatively if you don't want to add an attribute you can add a template instead.
<referenceBlock name="product.info.details">
<block class="MagentoCatalogBlockProductView" name="product.info.tech.spec" template="Magento_Catalog::product/view/tech-spec.phtml" group="detailed_info" >
<arguments>
<argument translate="true" name="title" xsi:type="string">Technical Specification</argument>
</arguments>
</block>
</referenceBlock>
I think the better way to do this is to follow the same approach Magento uses to add the description
attribute as one of the tabs on the product details page.
First create your attribute, lets say it's tech_spec
and add it to whichever attribute sets you want it to so I can be updated from the Manage Manage Products page.
Then create/update your appcode[NameSpace][ModuleName]viewfrontendlayoutcatalog_product_view.xml file with:
<referenceBlock name="product.info.details">
<block class="MagentoCatalogBlockProductViewDescription" name="product.info.tech.spec" template="product/view/attribute.phtml" group="detailed_info">
<arguments>
<argument name="at_call" xsi:type="string">getTechSpec</argument>
<argument name="at_code" xsi:type="string">tech_spec</argument>
<argument name="css_class" xsi:type="string">tech-spec</argument>
<argument name="at_label" xsi:type="string">none</argument>
<argument name="title" translate="true" xsi:type="string">Technical Specification</argument>
</arguments>
</block>
</referenceBlock>
Alternatively if you don't want to add an attribute you can add a template instead.
<referenceBlock name="product.info.details">
<block class="MagentoCatalogBlockProductView" name="product.info.tech.spec" template="Magento_Catalog::product/view/tech-spec.phtml" group="detailed_info" >
<arguments>
<argument translate="true" name="title" xsi:type="string">Technical Specification</argument>
</arguments>
</block>
</referenceBlock>
edited 9 mins ago
answered Apr 7 '17 at 8:52
HollyHolly
2,29733377
2,29733377
add a comment |
add a comment |
Thanks for contributing an answer to Magento Stack Exchange!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fmagento.stackexchange.com%2fquestions%2f146229%2fmy-custom-product-tab-not-displaying-in-magento-2%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Your controller file?
– Nitin Pawar
Nov 17 '16 at 10:39
@NitinPawar is it required?
– Bojjaiah
Nov 17 '16 at 10:40
Yes whenever i create the page i write controller for that page
– Nitin Pawar
Nov 17 '16 at 10:42
@NitinPawar I think not required. I am creating storefront. any way how can i link up with tab to controller? can you share the code if it possible?
– Bojjaiah
Nov 17 '16 at 10:44
@NitinPawar any help on this?
– Bojjaiah
Nov 17 '16 at 10:50