22 votes
Accepted

magento 2 - How to get attribute set name in product listing and product detail page

We can use \Magento\Eav\Api\AttributeSetRepositoryInterface to get attribute set name. Detail Page We need to override the \Magento\Catalog\Block\Product\View block. Inject this class on the ...
user avatar
19 votes
Accepted

Magento 2 Get a list of Attribute Set Names and IDs

The best way to get it is to use the following source model : \Magento\Catalog\Model\Product\AttributeSet\Options You can inject it in your constructor then call the toOptionArray() method to ...
user avatar
18 votes
Accepted

Add Custom attributes to Custom attribute set programmatically

Yes, this is possible. First, set these keys in your $data array to following values to avoid adding attribute to all attribute sets: 'user_defined' => true, 'group' => ...
user avatar
18 votes
Accepted

How to show the drop down attribute value using getData() method in magento 2?

Instead of getData() you need to use getAttributeText('attribute_code') for dropdown attributes. like $_product->getAttributeText('material'); For multi-select try this : $result = $_product-&...
user avatar
13 votes
Accepted

Create and add attribute group with attributes to all attribute sets

It's a lot easier to do it via setup script. Here is an example: // Add new Attribute group $groupName = 'My Attr Group'; $entityTypeId = $installer->getEntityTypeId('catalog_product'); $...
user avatar
12 votes
Accepted

Magento : Filter Collection by Attribute that Doesn't Exist or Null or another condition

After some tests, the code I wrote in the third edit of the question seems to work fine, so I think it is the correct answer: $_products = Mage::getModel('catalog/product') ->getCollection() -&...
user avatar
  • 791
10 votes
Accepted

Layered Navigation not showing Attributes

Besides the attribute settings, you also need to check each category. I.E. the category needs to be anchored. While editing the category, go to the Display Settings tab and check that Is Anchor is ...
user avatar
  • 2,107
10 votes
Accepted

How to retrieve custom attribute set ID by name

You can retrieve attribute set ID by using following code: protected $_attributeSetCollection; public function __construct( ... ,\Magento\Eav\Model\ResourceModel\Entity\Attribute\Set\...
user avatar
9 votes

How to retrieve custom attribute set ID by name

Based on Rizwan Dhuka answer, you can: reduce response size with select 'attribute_set_id' instead of '*' avoid a loop on the object with combine getFirstItem and toArray methods namespace ...
user avatar
  • 503
9 votes
Accepted

How to get the attribute id by attribute code in magento 2

Get Attribute Id By Attribute Code In Magento2. Just you have to follow some steps. Create constructor /** * @var \Magento\Eav\Model\ResourceModel\Entity\Attribute */ protected $_eavAttribute; /...
user avatar
8 votes

Please re-run Magento compile command?

Depending on your configuration it may also be unecessary. If you are in default or dev mode you do not need it. You just need it on production mode From command line and from your Magento root path:...
user avatar
8 votes

How to show the drop down attribute value using getData() method in magento 2?

You can get product attribute option values by below code $_product->getAttributeText('material'); You can get multi select option values by $_attributeValue = $block->getProduct()->...
user avatar
8 votes

How to show the drop down attribute value using getData() method in magento 2?

To fetch value of attribute Use: $this->getProduct()->getAttributeText('material'); Or $this->getProduct()->getResource()->getAttributeRawValue($this->getProduct()->getId(),'...
user avatar
7 votes
Accepted

magento2 create customer attribute

Please make below change in module.xml, <?xml version="1.0" encoding="UTF-8"?> <config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../../../../../...
user avatar
  • 2,817
6 votes

Magento 2: How to Change Default Attribute Set & Set Our Own

1.Find id of "Attribute Set" in database column eav_attribute_set.attribute_set_id 2.UPDATE `eav_entity_type` SET `default_attribute_set_id` = '%YOUR_Attribute_Set_ID%' WHERE `eav_entity_type`.`...
user avatar
6 votes
Accepted

How do you remove the short product description from the product page Magento 2

You remove it in layout xml. Make the file {theme_dir}/Magento_Catalog/layout/catalog_product_view.xml with this contents: <?xml version="1.0"?> <page xmlns:xsi="http://www.w3.org/2001/...
user avatar
  • 8,819
6 votes
Accepted

Magento 2 : How to get attribute group id using attribute set id ?

Block function public function getAttributeGroupId($attributeSetId) { $obj = \Magento\Framework\App\ObjectManager::getInstance(); /** @var \Magento\Catalog\Model\Config $config *...
user avatar
  • 1,486
6 votes
Accepted

Programmatically add Custom Product Attribute to attribute set

Try this <?php $installer = new Mage_Eav_Model_Entity_Setup('core_setup'); $installer->startSetup(); $installer->addAttribute('catalog_product', 'pim_id', array( 'group' ...
user avatar
  • 9,552
5 votes

Create Products with nested attributes

Use attribute-sets and attribute-groups. Product: iPhone Attribute-Set: Smartphone (or mobile phone, as you like to call it). The attribute-set "Smartphone" contains multiple attribute-groups, such ...
user avatar
  • 17.2k
5 votes

Saving Attribute Sets - Very SLOW

I took a default installation and ran a Blackfire.io test on the save action of the attribute set page. This is the main method I found that takes the bulk of the time ...
user avatar
5 votes
Accepted

Get all Attribute Sets in Static Block

You can get all attribute set list using below code. $entityType = Mage::getModel('catalog/product')->getResource()->getTypeId(); $attributeSetCollection = Mage::getResourceModel('eav/...
user avatar
5 votes

Magento2 How can get the Attributes based on the Attribute Set Id or Attribute Set Name

you can make use of the Magento\Catalog\Api\ProductAttributeManagementInterface $attributeSetId = 20;//your_attributeSetId $productAttributesManagement = $this->objectManager->create('Magento\...
user avatar
4 votes

How to change product attribute set?

If you want to change the attribute set id directly using sql (which may be faster for a one off issue) #attribute_set_id = new attribute set id #entity_id = product id UPDATE `...
user avatar
4 votes

Best Practices for Planning Attributes and Attribute Sets

Obviously reuse attributes between attribute sets where it makes sense. The key with attributes is to strike a balance between the number of attributes and attribute options. Its no good having a ...
user avatar
  • 954
4 votes
Accepted

migrating entire set of attributes and attribute sets to a fresh installation

I also had to deal with this kind of issue once. Possible ways of migrating the attributes and attribute-sets to a fresh (!!) installation: Copying tables to the new database As the OP already ...
user avatar
  • 17.2k
4 votes

Detect default attribute set id

A better answer would be this: Mage::getModel('my_module/my_entity')->getResource()->getEntityType()->getDefaultAttributeSetId(); Marius's answer is also good, but only works for products ...
user avatar
  • 380
4 votes
Accepted

How to echo/print attribute set name on frontend catalog page

add the following code in your catalog/product/list.phtml <?php $attributeSetModel = Mage::getModel("eav/entity_attribute_set"); $attributeSetModel->load($_product->getAttributeSetId()); // $...
user avatar
4 votes

How to Clone an Attribute Set

$entityTypeId = Mage::getModel('catalog/product')->getResource()->getTypeId(); $baseAttributeSet = 4; // "default" attribute set $model = Mage::getModel('eav/entity_attribute_set') ...
user avatar
  • 661
4 votes

Magento as a product information management (PIM) tool for multiple marketplaces (ebay, amazon, Rakuten, etc)

Welcome 李程腾 to MageOverflow! Why do you want to misuse an ecommerce system like magento as a PIM? What about using something like: http://www.akeneo.com/ https://www.pimcore.org Is there a ...
user avatar
4 votes
Accepted

Programatically created atrributes on layered navigation

Problem here is that you want to use a text type attribute for magento layered navigation. Magento only supports the int type as valid layered navigation attribute. The types select and multi select ...
user avatar

Only top scored, non community-wiki answers of a minimum length are eligible