I have created a custom product attribute using a module.
$eavSetup->addAttribute(
\Magento\Catalog\Model\Product::ENTITY,
'special_feature',
[
'type' => 'text',
'label' => 'Special Feature',
'input' => 'textarea',
'required' => false,
'sort_order' => 12,
'global' => \Magento\Eav\Model\Entity\Attribute\ScopedAttributeInterface::SCOPE_STORE,
'group' => 'Special Feature',
'backend' => 'Magento\Eav\Model\Entity\Attribute\Backend\ArrayBackend',
]
);
The attribute is showing in the product edit page and getting saved. Now, when I try to get the value using $product->getSpecialFeature()
in the .phtml file, it is not showing anything. I am looping through the product collection generated from the code below in my Block class.
public function getProductCollectionByCategories($ids)
{
$collection = $this->_productCollectionFactory->create();
$collection->addAttributeToSelect('*');
$collection->addCategoriesFilter(['in' => $ids]);
return $collection;
}