I'm confused a bit. You state you created a custom attribute. You then speak of using an extension in app/code/local. Why do you need an extension for placing an attribute?
Have you considered adding to /app/design/frontend/yourtheme/default/template/catalog/product/view.phtml
something like this?
<p>YOU WILL EARN <?php echo $_product->getAttributeText('customer_product_points') ?> POINTS FOR PURCHASING THIS PRODUCT.</p>
After searched lot over the internet i decided to show product additional information using the product attributes. Get all the attributes of product using getAttributes()
method. Then filter the attribute using the group id for group product details. After that avoid the attributes which are not necessary like sku, price, image etc. Following is code may be it is helpful for some one.
Block code:
<?php
namespace Vendor\Module\Block\Product;
use Magento\Catalog\Model\Product;
use Magento\Catalog\Model\Category;
use Magento\Framework\ObjectManagerInterface;
class Create extends \Magento\Framework\View\Element\Template
{
/**
* @var \Magento\Catalog\Model\Product
*/
protected $_product;
/**
* @var \Magento\Catalog\Model\Category
*/
protected $_category;
/**
* @var \Magento\Cms\Model\Wysiwyg\Config
*/
protected $_wysiwygConfig;
protected $customerSession;
public $_objectManager;
/**
* @param \Magento\Catalog\Block\Product\Context $context
* @param \Magento\Cms\Model\Wysiwyg\Config $wysiwygConfig
* @param Product $product
* @param Category $category
* @param array $data
*/
public function __construct(
\Magento\Catalog\Block\Product\Context $context,
\Magento\Cms\Model\Wysiwyg\Config $wysiwygConfig,
\Magento\Customer\Model\Session $customerSession,
Product $product,
Category $category,
ObjectManagerInterface $objectManager,
array $data = []
)
{
$this->_wysiwygConfig = $wysiwygConfig;
$this->_product = $product;
$this->_objectManager = $objectManager;
$this->customerSession = $customerSession;
$this->_category = $category;
parent::__construct($context, $data);
}
public function getWysiwygConfig()
{
$config = $this->_wysiwygConfig->getConfig();
$config = json_encode($config->getData());
}
public function getProduct($id)
{
return $this->_product->load($id);
}
public function getSellerId()
{
return $this->customerSession->getCustomer()->getId();
}
public function getSellerProduct($mageProductId, $sellerId)
{
$sellerProductColls = $this->_objectManager->create(
'Vendor\Module\Model\Product'
)
->getCollection()
->addFieldToFilter(
'mageproduct_id',
$mageProductId
)->addFieldToFilter(
'seller_id',
$sellerId
);
$count = $sellerProductColls->getData();
return $count;
}
public function getAttributeGroupId($attributeSetId)
{
$obj = \Magento\Framework\App\ObjectManager::getInstance();
/** @var \Magento\Catalog\Model\Config $config */
$config= $obj->get('Magento\Catalog\Model\Config');
return $attributeGroupId = $config->getAttributeGroupId($attributeSetId, 'Product Details');
}
public function getProductAttrValue($pid, $code)
{
$product = $this->_product->load($pid);
return $product->getResource()->getAttribute($code)->getFrontend()->getValue($product);
}
public function getCategory()
{
return $this->_category;
}
public function _prepareLayout()
{
return parent::_prepareLayout();
}
}
Phml Template:
<?php
$product_id=$this->getRequest()->getParam('pid');
$product_coll = $block->getProduct($product_id);
$pname = $product_coll->getname();
$pattr = $product_coll->getAttributeSetId();
$extraAttr = array('swatch_image', 'old_id', 'name', 'url_path', 'required_options', 'has_options', 'image_label', 'swatch_image', 'small_image_label', 'thumbnail_label', 'created_at', 'updated_at', 'sku', 'price', 'tax_class_id', 'image', 'quantity_and_stock_status', 'weight', 'updated_at', 'category_ids', 'description', 'status', 'price_type', 'sku_type', 'sw_featured', 'weight_type', 'shipment_type', 'links_purchased_separately', 'samples_title', 'links_title', 'links_exist', 'new', 'sale');
$group_id = $block->getAttributeGroupId($pattr);
$productAttributes = $product_coll->getAttributes();
foreach ($productAttributes as $attribute):
$code = $attribute->getAttributeCode();
if ($attribute->isInGroup($pattr, $group_id) && !in_array($code, $extraAttr)):
echo '<strong>'.$attribute->getDefaultFrontendLabel().': </strong> '.$block->getProductAttrValue($product_id, $code).'<br>';
endif;
endforeach;
?>
Best Answer
Create or replace with the below content and put it in app\design\frontend\Your-Package\Your-theme\template\catalog\product\view\attributes.phtml
Also make logo named as CE.png,CLASSE II.png, ENEC.png, F.png, IP20.png and place it in skin\frontend\Your-Package\Your-theme\images
It is working for me. Let me know once you tried it.