You can see all the Attribute Set lists from the Admin Panel. Store -> Properties -> Attribute Set.
You can explore all the attribute-set lists programmatically by the Magento\Catalog\Api\AttributeSetRepositoryInterface.
Retrieve all the attribute lists of the system by first create an object of the Search Criteria builder, Pass the object to the getList() method of the above interface.
<?php
namespace Jesadiya\ListAttributeSet\Model;
use Exception;
use Magento\Eav\Api\Data\AttributeSetInterface;
use Magento\Framework\Api\SearchCriteriaBuilder;
use Magento\Catalog\Api\AttributeSetRepositoryInterface;
class AttributeSetList
{
/**
* @var AttributeSetRepositoryInterface
*/
private $attributeSetRepository;
/**
* @var SearchCriteriaBuilder
*/
private $searchCriteriaBuilder;
public function __construct(
AttributeSetRepositoryInterface $attributeSetRepository,
SearchCriteriaBuilder $searchCriteriaBuilder
) {
$this->attributeSetRepository = $attributeSetRepository;
$this->searchCriteriaBuilder = $searchCriteriaBuilder;
}
/**
* list attribute set
*
* @return AttributeSetInterface|null
*/
public function listAttributeSet()
{
$attributeSetList = null;
try {
$searchCriteria = $this->searchCriteriaBuilder->create();
$attributeSet = $this->attributeSetRepository->getList($searchCriteria);
} catch (Exception $exception) {
throw new Exception($exception->getMessage());
}
if ($attributeSet->getTotalCount()) {
$attributeSetList = $attributeSet;
}
return $attributeSetList;
}
}
You can retrieve all the list of attributes set using the for each loop.
$attributeSetList = $this->listAttributeSet();
if ($attributeSetList) {
foreach ($attributeSetList->getItems() as $list) {
var_dump($list);
}
}
Output:
List of all the attribute sets.
