In Magento 2, How do I get all the attributes and it's description ?
Please provide me a solution. Anyone have any script ?
Magento Stack Exchange is a question and answer site for users of the Magento e-Commerce platform. It only takes a minute to sign up.
Sign up to join this communityTry below code for getting all custom attributes of Product.
protected $_attributeFactory;
public function __construct(
....
\Magento\Catalog\Model\ResourceModel\Eav\Attribute $attributeFactory,
....
) {
....
$this->_attributeFactory = $attributeFactory;
....
}
public function getCustomAttributes()
{
$attributeList = $this->_attributeFactory->getCollection();
$attributeList->addFieldToFilter('is_user_defined',['eq' => 1]);
foreach($attributeList as $attribute)
{
echo '<pre>';print_r($attribute->getData());
}
}
die;
It's working fine for me.