how to get attribute_set_id in magento 2 custom collection
-
14-04-2021 - |
Pergunta
I have created custom table and display the values as grid in admin by UI component.In my custom table already I have SKU column .now I need attribute set id Name of the product in custom grid .how to get attribute setid by joining in collection.what are the tables needs to be joined to get attribute set_id name ?
Solução
In your Collection.php which you are using for the Grid add below function code
protected function _initSelect()
{
parent::_initSelect();
$this->getSelect()
->columns('eas.attribute_set_name')
->join(
['cpe' => $this->getTable('catalog_product_entity')],
'main_table.sku = cpe.sku',
[]
)->join(
['eas' => $this->getTable('eav_attribute_set')],
'cpe.attribute_set_id = eas.attribute_set_id',
[]
);
}
Outras dicas
Not sure to really understand your issue. To give you a strict answer the attribute set is stored in the table eav_attribute_set
where you can find the columns attribute_set_id
and attribute_set_name
Now if what you try to do is add that value into a grid, we need more information and code about what you've done.