Suppose package:Learning and module: Custom
Module.xml looks like
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../../../../../lib/internal/Magento/Framework/Module/etc/module.xsd">
<module name="Learning_Custom" setup_version="2.0.0">
<sequence>
<module name="Magento_Catalog"/>
</sequence>
</module>
</config>
And then create a layout xml following path -> app/code/Learning/Custom/view/frontend/layout/catalog_product_prices.xml
<layout xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../../../../../../../lib/internal/Magento/Framework/View/Layout/etc/layout_generic.xsd">
<referenceBlock name="render.product.prices">
<arguments>
<argument name="default" xsi:type="array">
<item name="prices" xsi:type="array">
<item name="tier_price" xsi:type="array">
<item name="render_template" xsi:type="string">Learning_Custom::product/price/tier_prices.phtml
</item>
</item>
</argument>
</arguments>
</referenceBlock>
</layout>
Create template inside your module or copy base template file inside your module path should be ->
app/code/Learning/Custom/view/frontend/templates/product/price/tier_prices.phtml
(1) first create a new module with a custom eav for your product content (this is just the InstallData.php
content):
<?php namespace <vendor>\<module_name>\Setup;
use Magento\Eav\Setup\EavSetup;
use Magento\Eav\Setup\EavSetupFactory;
use Magento\Framework\Setup\InstallDataInterface;
use Magento\Framework\Setup\ModuleContextInterface;
use Magento\Framework\Setup\ModuleDataSetupInterface;
/**
* @codeCoverageIgnore
*/
class InstallData implements InstallDataInterface
{
/**
* EAV setup factory
*
* @var EavSetupFactory
*/
private $eavSetupFactory;
/**
* Init
*
* @param EavSetupFactory $eavSetupFactory
*/
public function __construct(EavSetupFactory $eavSetupFactory)
{
$this->eavSetupFactory = $eavSetupFactory;
/* assign object to class global variable for use in other class methods */
}
/**
* {@inheritdoc}
* @SuppressWarnings(PHPMD.ExcessiveMethodLength)
*/
public function install(ModuleDataSetupInterface $setup, ModuleContextInterface $context)
{
$setup->startSetup();
/** @var EavSetup $eavSetup */
$eavSetup = $this->eavSetupFactory->create(['setup' => $setup]);
/**
* Add attributes to the eav/attribute
*/
$eavSetup->addAttribute(
\Magento\Catalog\Model\Product::ENTITY,
'my_attribute',
[
'type' => 'text',
'backend' => '',
'frontend' => '',
'label' => 'my custom content',
'input' => 'textarea',
'class' => '',
'source' => '',
'global' => 1,
'visible' => true,
'required' => false,
'user_defined' => true,
'default' => 0,
'searchable' => false,
'filterable' => false,
'comparable' => false,
'visible_on_front' => false,
'used_in_product_listing' => true,
'wysiwyg_enabled' => true, // if you want a wysiwyg editor
'unique' => false,
'apply_to' => 'simple,configurable,virtual,bundle,downloadable,grouped',
'group' => 'General'
]
);
$setup->endSetup();
}
}
(2) in the module extend catalog_product_view.xml
to insert your attribute:
[I added mine as a new product tab]
<referenceBlock name="product.info.details">
<block class="Magento\Catalog\Block\Product\View\Description" name="{SOME_NAME}" template="product/view/attribute.phtml" group="detailed_info">
<arguments>
<argument name="at_call" xsi:type="string">getMyAttribute</argument>
<argument name="at_code" xsi:type="string">my_attribute</argument>
<argument name="css_class" xsi:type="string">{some class if you like}</argument>
<argument name="at_label" xsi:type="string">none</argument>
<argument name="title" translate="true" xsi:type="string">My tab label</argument>
</arguments>
</block>
</referenceBlock>
(3) now you can go to your magento admin and insert custom content (even html) into the attribute content like for every other attribute
Best Answer
You can add class like this
Check this http://devdocs.magento.com/guides/v2.0/frontend-dev-guide/layouts/layout-types.html