- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-26-2016
06:39 AM
02-26-2016
06:39 AM
Get eav attribute value of a product programmatically
Hi all. How can I get the value of an eav attribute of a product programmatically?
I added attribute programmatically in this way:
$eavSetup->addAttribute( \Magento\Catalog\Model\Product::ENTITY, 'rewrite_url_with_parent', [ 'group' => 'Search Engine Optimization', 'type' => 'int', 'label' => 'rewrite_url_with_parent', 'input' => 'select', 'source' => 'ModuleVendor\ModuleName\Model\Product\Attribute\Source\Product', 'required' => false, 'user_defined' => true, 'searchable' => true, 'filterable' => true, 'comparable' => true, 'visible_in_advanced_search' => true, 'apply_to' => Type::TYPE_VIRTUAL, 'is_used_in_grid' => true, 'is_visible_in_grid' => false, 'is_filterable_in_grid' => true, ] ); $setup->endSetup();
Labels:
1 REPLY 1
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-26-2016
08:32 AM
02-26-2016
08:32 AM
Re: Get eav attribute value of a product programmatically
The most appropriate method depends on a situation, but you can simply load the product, and all the EAV attributes will be loaded automatically:
How to load a Magento 2 product by its ID programmatically? https://mage2.pro/t/828
How to load a Magento 2 product by its SKU programmatically? https://mage2.pro/t/829