{"id":145371,"date":"2018-09-28T10:37:20","date_gmt":"2018-09-28T10:37:20","guid":{"rendered":"https:\/\/webkul.com\/blog\/?p=145371"},"modified":"2026-01-29T13:44:33","modified_gmt":"2026-01-29T13:44:33","slug":"create-drop-down-product-attribute-in-magento-2","status":"publish","type":"post","link":"https:\/\/webkul.com\/blog\/create-drop-down-product-attribute-in-magento-2\/","title":{"rendered":"Create dropdown product attribute in Magento 2"},"content":{"rendered":"\n<p>Creating a dropdown product attribute in Magento 2 allows you to manage product data more efficiently and maintain consistent values across your catalog. <\/p>\n\n\n\n<p>There are two ways to create the dropdown attribute in Magento.<br>1 -> Manually: Go to the admin panel,\u00a0 Store -> Attributes -> Product.<br>2 ->\u00a0Programmatically.<\/p>\n\n\n\n<p>In this guide, we\u2019ll walk through the steps to create and assign a dropdown product attribute programmatically.<\/p>\n\n\n\n<p>So let&#8217;s start :<br><strong>Step 1:<\/strong> Create the AddProductAttribute.php file in the location Vendor\\Module\\Setup\\Patch\\Data<\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\">&lt;?php\n\nnamespace Vendor\\Module\\Setup\\Patch\\Data;\n\nuse Magento\\Framework\\Setup\\ModuleDataSetupInterface;\nuse Magento\\Framework\\Setup\\Patch\\DataPatchInterface;\nuse Magento\\Eav\\Setup\\EavSetupFactory;\nuse Magento\\Eav\\Model\\Entity\\Attribute\\ScopedAttributeInterface;\nuse Magento\\Eav\\Model\\Entity\\Attribute\\SetFactory;\nuse Magento\\Catalog\\Model\\Product;\n\nclass AddProductAttribute implements DataPatchInterface\n{\n    public const ATTRIBUTE_GROUP = &quot;Test Group&quot;;\n    public const ATTRIBUTE_CODE = &quot;custom_dropdown&quot;;\n    \n    \/**\n     * @var ModuleDataSetupInterface\n     *\/\n    private $moduleDataSetup;\n\n    \/**\n     * @var EavSetupFactory\n     *\/\n    private $eavSetupFactory;\n\n    \/**\n     * @var SetFactory\n     *\/\n    private $attributeSetFactory;\n\n\n    \/**\n     * @param ModuleDataSetupInterface $moduleDataSetup\n     * @param EavSetupFactory $eavSetupFactory\n     * @param SetFactory $attributeSetFactory\n     *\/\n    public function __construct(\n        ModuleDataSetupInterface $moduleDataSetup,\n        EavSetupFactory $eavSetupFactory,\n        SetFactory $attributeSetFactory\n    ) {\n        $this-&gt;moduleDataSetup = $moduleDataSetup;\n        $this-&gt;eavSetupFactory = $eavSetupFactory;\n        $this-&gt;attributeSetFactory = $attributeSetFactory;\n    }\n\n    \/**\n     * @inheritdoc\n     *\/\n    public function apply()\n    {\n        $eavSetup = $this-&gt;eavSetupFactory-&gt;create(&#091;&#039;setup&#039; =&gt; $this-&gt;moduleDataSetup]);\n        if ($eavSetup-&gt;getAttributeId(Product::ENTITY, self::ATTRIBUTE_CODE)) {\n            return $this;\n        }\n        $eavSetup-&gt;addAttribute(\n            Product::ENTITY,\n            self::ATTRIBUTE_CODE,\n            &#091;\n                &#039;type&#039; =&gt; &#039;int&#039;,\n                &#039;backend&#039; =&gt; &#039;&#039;,\n                &#039;frontend&#039; =&gt; &#039;&#039;,\n                &#039;label&#039; =&gt; &#039;Attribute Label&#039;,\n                &#039;input&#039; =&gt; &#039;select&#039;,\n                &#039;class&#039; =&gt; &#039;&#039;,\n                &#039;source&#039; =&gt; \\Vendor\\Module\\Model\\Config\\Source\\Options::class,\n                &#039;global&#039; =&gt; \\Magento\\Eav\\Model\\Entity\\Attribute\\ScopedAttributeInterface::SCOPE_STORE,\n                &#039;visible&#039; =&gt; true,\n                &#039;required&#039; =&gt; false,\n                &#039;user_defined&#039; =&gt; true,\n                &#039;searchable&#039; =&gt; false,\n                &#039;filterable&#039; =&gt; false,\n                &#039;comparable&#039; =&gt; false,\n                &#039;visible_on_front&#039; =&gt; false,\n                &#039;used_in_product_listing&#039; =&gt; true,\n                &#039;unique&#039; =&gt; false,\n                &#039;apply_to&#039; =&gt; &#039;simple,grouped,configurable,downloadable,virtual,bundle&#039;,\n                &#039;group&#039; =&gt; self::ATTRIBUTE_GROUP,\n            ]\n        );\n\n\n        \/\/ Assign attribute to ALL attribute sets under &quot;Test Group&quot; group\n        $entityTypeId = $eavSetup-&gt;getEntityTypeId(Product::ENTITY);\n        $attributeId  = $eavSetup-&gt;getAttributeId(Product::ENTITY, self::ATTRIBUTE_CODE);\n        $attributeSets = $eavSetup-&gt;getAllAttributeSetIds($entityTypeId);\n\n        foreach ($attributeSets as $attributeSetId) {\n            $groupId = $eavSetup-&gt;getAttributeGroupId(\n                $entityTypeId,\n                $attributeSetId,\n                self::ATTRIBUTE_GROUP\n            );\n\n            if (!$groupId) {\n                $eavSetup-&gt;addAttributeGroup(\n                    $entityTypeId,\n                    $attributeSetId,\n                    self::ATTRIBUTE_GROUP,\n                    100\n                );\n                $groupId = $eavSetup-&gt;getAttributeGroupId(\n                    $entityTypeId,\n                    $attributeSetId,\n                    self::ATTRIBUTE_GROUP\n                );\n            }\n\n            $eavSetup-&gt;addAttributeToGroup(\n                $entityTypeId,\n                $attributeSetId,\n                $groupId,\n                $attributeId,\n                100\n            );\n        }\n\n\n        return $this;\n    }\n\n    \/**\n     * @inheritdoc\n     *\/\n    public static function getDependencies()\n    {\n        return &#091;];\n    }\n\n    \/**\n     * @inheritdoc\n     *\/\n    public function getAliases()\n    {\n        return &#091;];\n    }\n}<\/pre>\n\n\n\n<p><strong>Step 2:<\/strong> Create the Options.php file in the location Vendor\\Module\\Model\\Config\\Source<\/p>\n\n\n\n<p>Note:\u00a0 Options for the dropdown attribute can be added directly as an array. Here, we are using &#8216;source&#8217; to add the options\u00a0 as follows :<\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\">&lt;?php\n\nnamespace Vendor\\Module\\Model\\Config\\Source;\n\nclass Options extends \\Magento\\Eav\\Model\\Entity\\Attribute\\Source\\AbstractSource\n{\n    \/**\n    * Get all options\n    *\n    * @return array\n    *\/\n    public function getAllOptions()\n    {\n        $this-&gt;_options = &#091;\n                &#091;&#039;label&#039; =&gt; __(&#039;No&#039;), &#039;value&#039;=&gt;&#039;0&#039;],\n                &#091;&#039;label&#039; =&gt; __(&#039;Yes&#039;), &#039;value&#039;=&gt;&#039;1&#039;],\n                &#091;&#039;label&#039; =&gt; __(&#039;Other&#039;), &#039;value&#039;=&gt;&#039;2&#039;]\n            ];\n\n    return $this-&gt;_options;\n\n    }\n\n}<\/pre>\n\n\n\n<p><strong>Step 3:<\/strong> Run the following command on your magento root directory.<\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\">php bin\/magento setup:upgrade<\/pre>\n\n\n\n<p><strong>Once the command executes successfully<\/strong>, you can check the results in the following locations:<br><br>Product Add\/Edit page-<\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><img decoding=\"async\" width=\"1200\" height=\"502\" src=\"https:\/\/cdnblog.webkul.com\/blog\/wp-content\/uploads\/2018\/09\/product-view-1200x502.webp\" alt=\"product-view\" class=\"wp-image-524242\" srcset=\"https:\/\/cdnblog.webkul.com\/blog\/wp-content\/uploads\/2018\/09\/product-view-1200x502.webp 1200w, https:\/\/cdnblog.webkul.com\/blog\/wp-content\/uploads\/2018\/09\/product-view-300x125.webp 300w, https:\/\/cdnblog.webkul.com\/blog\/wp-content\/uploads\/2018\/09\/product-view-250x105.webp 250w, https:\/\/cdnblog.webkul.com\/blog\/wp-content\/uploads\/2018\/09\/product-view-768x321.webp 768w, https:\/\/cdnblog.webkul.com\/blog\/wp-content\/uploads\/2018\/09\/product-view.webp 1423w\" sizes=\"(max-width: 1200px) 100vw, 1200px\" loading=\"lazy\" \/><\/figure>\n\n\n\n<p>Attribute Set Page-<\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><img decoding=\"async\" width=\"1200\" height=\"644\" src=\"https:\/\/cdnblog.webkul.com\/blog\/wp-content\/uploads\/2018\/09\/attributeset-view-1200x644.webp\" alt=\"attributeset-view\" class=\"wp-image-524244\" srcset=\"https:\/\/cdnblog.webkul.com\/blog\/wp-content\/uploads\/2018\/09\/attributeset-view-1200x644.webp 1200w, https:\/\/cdnblog.webkul.com\/blog\/wp-content\/uploads\/2018\/09\/attributeset-view-300x161.webp 300w, https:\/\/cdnblog.webkul.com\/blog\/wp-content\/uploads\/2018\/09\/attributeset-view-250x134.webp 250w, https:\/\/cdnblog.webkul.com\/blog\/wp-content\/uploads\/2018\/09\/attributeset-view-768x412.webp 768w, https:\/\/cdnblog.webkul.com\/blog\/wp-content\/uploads\/2018\/09\/attributeset-view.webp 1385w\" sizes=\"(max-width: 1200px) 100vw, 1200px\" loading=\"lazy\" \/><\/figure>\n\n\n\n<p>Attributes listing Grid-<\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><img decoding=\"async\" width=\"1200\" height=\"397\" src=\"https:\/\/cdnblog.webkul.com\/blog\/wp-content\/uploads\/2018\/09\/attributelist-view-1200x397.webp\" alt=\"attributelist-view\" class=\"wp-image-524245\" srcset=\"https:\/\/cdnblog.webkul.com\/blog\/wp-content\/uploads\/2018\/09\/attributelist-view-1200x397.webp 1200w, https:\/\/cdnblog.webkul.com\/blog\/wp-content\/uploads\/2018\/09\/attributelist-view-300x99.webp 300w, https:\/\/cdnblog.webkul.com\/blog\/wp-content\/uploads\/2018\/09\/attributelist-view-250x83.webp 250w, https:\/\/cdnblog.webkul.com\/blog\/wp-content\/uploads\/2018\/09\/attributelist-view-768x254.webp 768w, https:\/\/cdnblog.webkul.com\/blog\/wp-content\/uploads\/2018\/09\/attributelist-view.webp 1409w\" sizes=\"(max-width: 1200px) 100vw, 1200px\" loading=\"lazy\" \/><\/figure>\n\n\n\n<p>Now, you have successfully created the dropdown product attribute.<\/p>\n\n\n\n<p><strong>With this approach<\/strong>, you can easily add fixed values to your products and keep your catalog data clean and consistent. <\/p>\n\n\n\n<p><strong>Moving forward<\/strong>, you can use this method to create other custom attributes and manage them more confidently in Magento 2.<\/p>\n\n\n\n<p>In case you have any queries, feel free to ask in the comment section below.<\/p>\n\n\n\n<p>For technical assistance, please get in touch with us via email at\u00a0<a href=\"mailto:support@webkul.com\" target=\"_blank\" rel=\"noreferrer noopener\">support@webkul.com<\/a>.<\/p>\n\n\n\n<p>Discover powerful solutions to enhance your Magento 2 store by exploring our\u00a0<a href=\"https:\/\/store.webkul.com\/Magento-2.html\">Magento 2 plugins<\/a>\u00a0page.<\/p>\n\n\n\n<p>Bring your vision to life with custom-built solutions\u2014hire skilled\u00a0<a href=\"https:\/\/webkul.com\/hire-magento-developers\/\">Magento 2 developers<\/a>\u00a0today.<\/p>\n\n\n\n<p><\/p>\n","protected":false},"excerpt":{"rendered":"<p>Creating a dropdown product attribute in Magento 2 allows you to manage product data more efficiently and maintain consistent values across your catalog. There are two ways to create the dropdown attribute in Magento.1 -> Manually: Go to the admin panel,\u00a0 Store -> Attributes -> Product.2 ->\u00a0Programmatically. In this guide, we\u2019ll walk through the steps <a href=\"https:\/\/webkul.com\/blog\/create-drop-down-product-attribute-in-magento-2\/\">[&#8230;]<\/a><\/p>\n","protected":false},"author":170,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[302],"tags":[354,7576,1908,2056,2460,7577,2070,580,4301,1909],"class_list":["post-145371","post","type-post","status-publish","format-standard","hentry","category-magento2","tag-attribute","tag-drop-down","tag-dropdown","tag-magento","tag-magento-2","tag-magento-2-create-product-attribute-programmatically","tag-magento2","tag-product","tag-programmatically","tag-select"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v24.5 - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>Create dropdown product attribute in Magento 2 - Webkul Blog<\/title>\n<meta name=\"description\" content=\"Learn How to Create a Dropdown Product Attribute in Magento 2 Programmatically Using Data Patch and Source Model\" \/>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/webkul.com\/blog\/create-drop-down-product-attribute-in-magento-2\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Create dropdown product attribute in Magento 2 - Webkul Blog\" \/>\n<meta property=\"og:description\" content=\"Learn How to Create a Dropdown Product Attribute in Magento 2 Programmatically Using Data Patch and Source Model\" \/>\n<meta property=\"og:url\" content=\"https:\/\/webkul.com\/blog\/create-drop-down-product-attribute-in-magento-2\/\" \/>\n<meta property=\"og:site_name\" content=\"Webkul Blog\" \/>\n<meta property=\"article:publisher\" content=\"https:\/\/www.facebook.com\/webkul\/\" \/>\n<meta property=\"article:published_time\" content=\"2018-09-28T10:37:20+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2026-01-29T13:44:33+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/webkul.com\/blog\/wp-content\/uploads\/2018\/09\/product-view-1200x502.webp\" \/>\n<meta name=\"author\" content=\"Prabhat Rawat\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:creator\" content=\"@webkul\" \/>\n<meta name=\"twitter:site\" content=\"@webkul\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"Prabhat Rawat\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"2 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\/\/webkul.com\/blog\/create-drop-down-product-attribute-in-magento-2\/#article\",\"isPartOf\":{\"@id\":\"https:\/\/webkul.com\/blog\/create-drop-down-product-attribute-in-magento-2\/\"},\"author\":{\"name\":\"Prabhat Rawat\",\"@id\":\"https:\/\/webkul.com\/blog\/#\/schema\/person\/3d52d6c1ad8a809d2f7548e6a9c3358f\"},\"headline\":\"Create dropdown product attribute in Magento 2\",\"datePublished\":\"2018-09-28T10:37:20+00:00\",\"dateModified\":\"2026-01-29T13:44:33+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\/\/webkul.com\/blog\/create-drop-down-product-attribute-in-magento-2\/\"},\"wordCount\":265,\"commentCount\":2,\"publisher\":{\"@id\":\"https:\/\/webkul.com\/blog\/#organization\"},\"image\":{\"@id\":\"https:\/\/webkul.com\/blog\/create-drop-down-product-attribute-in-magento-2\/#primaryimage\"},\"thumbnailUrl\":\"https:\/\/webkul.com\/blog\/wp-content\/uploads\/2018\/09\/product-view-1200x502.webp\",\"keywords\":[\"Attribute\",\"drop down\",\"dropdown\",\"magento\",\"Magento 2\",\"Magento 2 create product attribute programmatically\",\"Magento2\",\"product\",\"Programmatically\",\"select\"],\"articleSection\":[\"Magento2\"],\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"CommentAction\",\"name\":\"Comment\",\"target\":[\"https:\/\/webkul.com\/blog\/create-drop-down-product-attribute-in-magento-2\/#respond\"]}]},{\"@type\":\"WebPage\",\"@id\":\"https:\/\/webkul.com\/blog\/create-drop-down-product-attribute-in-magento-2\/\",\"url\":\"https:\/\/webkul.com\/blog\/create-drop-down-product-attribute-in-magento-2\/\",\"name\":\"Create dropdown product attribute in Magento 2 - Webkul Blog\",\"isPartOf\":{\"@id\":\"https:\/\/webkul.com\/blog\/#website\"},\"primaryImageOfPage\":{\"@id\":\"https:\/\/webkul.com\/blog\/create-drop-down-product-attribute-in-magento-2\/#primaryimage\"},\"image\":{\"@id\":\"https:\/\/webkul.com\/blog\/create-drop-down-product-attribute-in-magento-2\/#primaryimage\"},\"thumbnailUrl\":\"https:\/\/webkul.com\/blog\/wp-content\/uploads\/2018\/09\/product-view-1200x502.webp\",\"datePublished\":\"2018-09-28T10:37:20+00:00\",\"dateModified\":\"2026-01-29T13:44:33+00:00\",\"description\":\"Learn How to Create a Dropdown Product Attribute in Magento 2 Programmatically Using Data Patch and Source Model\",\"breadcrumb\":{\"@id\":\"https:\/\/webkul.com\/blog\/create-drop-down-product-attribute-in-magento-2\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/webkul.com\/blog\/create-drop-down-product-attribute-in-magento-2\/\"]}]},{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/webkul.com\/blog\/create-drop-down-product-attribute-in-magento-2\/#primaryimage\",\"url\":\"https:\/\/cdnblog.webkul.com\/blog\/wp-content\/uploads\/2018\/09\/product-view.webp\",\"contentUrl\":\"https:\/\/cdnblog.webkul.com\/blog\/wp-content\/uploads\/2018\/09\/product-view.webp\",\"width\":1423,\"height\":595},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/webkul.com\/blog\/create-drop-down-product-attribute-in-magento-2\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\/\/webkul.com\/blog\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Create dropdown product attribute in Magento 2\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/webkul.com\/blog\/#website\",\"url\":\"https:\/\/webkul.com\/blog\/\",\"name\":\"Webkul Blog\",\"description\":\"\",\"publisher\":{\"@id\":\"https:\/\/webkul.com\/blog\/#organization\"},\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\/\/webkul.com\/blog\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-US\"},{\"@type\":\"Organization\",\"@id\":\"https:\/\/webkul.com\/blog\/#organization\",\"name\":\"WebKul Software Private Limited\",\"url\":\"https:\/\/webkul.com\/blog\/\",\"logo\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/webkul.com\/blog\/#\/schema\/logo\/image\/\",\"url\":\"https:\/\/cdnblog.webkul.com\/blog\/wp-content\/uploads\/2021\/08\/webkul-logo-accent-sq.png\",\"contentUrl\":\"https:\/\/cdnblog.webkul.com\/blog\/wp-content\/uploads\/2021\/08\/webkul-logo-accent-sq.png\",\"width\":380,\"height\":380,\"caption\":\"WebKul Software Private Limited\"},\"image\":{\"@id\":\"https:\/\/webkul.com\/blog\/#\/schema\/logo\/image\/\"},\"sameAs\":[\"https:\/\/www.facebook.com\/webkul\/\",\"https:\/\/x.com\/webkul\",\"https:\/\/www.instagram.com\/webkul\/\",\"https:\/\/www.linkedin.com\/company\/webkul\",\"https:\/\/www.youtube.com\/user\/webkul\/\"]},{\"@type\":\"Person\",\"@id\":\"https:\/\/webkul.com\/blog\/#\/schema\/person\/3d52d6c1ad8a809d2f7548e6a9c3358f\",\"name\":\"Prabhat Rawat\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/webkul.com\/blog\/#\/schema\/person\/image\/\",\"url\":\"https:\/\/secure.gravatar.com\/avatar\/616ec5deaf63b72b3003cf99e608ae354f4d373cee8d25b2d0bfa65cab270ad8?s=96&d=https%3A%2F%2Fcdnblog.webkul.com%2Fblog%2Fwp-content%2Fuploads%2F2019%2F10%2Fmike.png&r=g\",\"contentUrl\":\"https:\/\/secure.gravatar.com\/avatar\/616ec5deaf63b72b3003cf99e608ae354f4d373cee8d25b2d0bfa65cab270ad8?s=96&d=https%3A%2F%2Fcdnblog.webkul.com%2Fblog%2Fwp-content%2Fuploads%2F2019%2F10%2Fmike.png&r=g\",\"caption\":\"Prabhat Rawat\"},\"url\":\"https:\/\/webkul.com\/blog\/author\/prabhat-rawat763\/\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"Create dropdown product attribute in Magento 2 - Webkul Blog","description":"Learn How to Create a Dropdown Product Attribute in Magento 2 Programmatically Using Data Patch and Source Model","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/webkul.com\/blog\/create-drop-down-product-attribute-in-magento-2\/","og_locale":"en_US","og_type":"article","og_title":"Create dropdown product attribute in Magento 2 - Webkul Blog","og_description":"Learn How to Create a Dropdown Product Attribute in Magento 2 Programmatically Using Data Patch and Source Model","og_url":"https:\/\/webkul.com\/blog\/create-drop-down-product-attribute-in-magento-2\/","og_site_name":"Webkul Blog","article_publisher":"https:\/\/www.facebook.com\/webkul\/","article_published_time":"2018-09-28T10:37:20+00:00","article_modified_time":"2026-01-29T13:44:33+00:00","og_image":[{"url":"https:\/\/webkul.com\/blog\/wp-content\/uploads\/2018\/09\/product-view-1200x502.webp","type":"","width":"","height":""}],"author":"Prabhat Rawat","twitter_card":"summary_large_image","twitter_creator":"@webkul","twitter_site":"@webkul","twitter_misc":{"Written by":"Prabhat Rawat","Est. reading time":"2 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/webkul.com\/blog\/create-drop-down-product-attribute-in-magento-2\/#article","isPartOf":{"@id":"https:\/\/webkul.com\/blog\/create-drop-down-product-attribute-in-magento-2\/"},"author":{"name":"Prabhat Rawat","@id":"https:\/\/webkul.com\/blog\/#\/schema\/person\/3d52d6c1ad8a809d2f7548e6a9c3358f"},"headline":"Create dropdown product attribute in Magento 2","datePublished":"2018-09-28T10:37:20+00:00","dateModified":"2026-01-29T13:44:33+00:00","mainEntityOfPage":{"@id":"https:\/\/webkul.com\/blog\/create-drop-down-product-attribute-in-magento-2\/"},"wordCount":265,"commentCount":2,"publisher":{"@id":"https:\/\/webkul.com\/blog\/#organization"},"image":{"@id":"https:\/\/webkul.com\/blog\/create-drop-down-product-attribute-in-magento-2\/#primaryimage"},"thumbnailUrl":"https:\/\/webkul.com\/blog\/wp-content\/uploads\/2018\/09\/product-view-1200x502.webp","keywords":["Attribute","drop down","dropdown","magento","Magento 2","Magento 2 create product attribute programmatically","Magento2","product","Programmatically","select"],"articleSection":["Magento2"],"inLanguage":"en-US","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/webkul.com\/blog\/create-drop-down-product-attribute-in-magento-2\/#respond"]}]},{"@type":"WebPage","@id":"https:\/\/webkul.com\/blog\/create-drop-down-product-attribute-in-magento-2\/","url":"https:\/\/webkul.com\/blog\/create-drop-down-product-attribute-in-magento-2\/","name":"Create dropdown product attribute in Magento 2 - Webkul Blog","isPartOf":{"@id":"https:\/\/webkul.com\/blog\/#website"},"primaryImageOfPage":{"@id":"https:\/\/webkul.com\/blog\/create-drop-down-product-attribute-in-magento-2\/#primaryimage"},"image":{"@id":"https:\/\/webkul.com\/blog\/create-drop-down-product-attribute-in-magento-2\/#primaryimage"},"thumbnailUrl":"https:\/\/webkul.com\/blog\/wp-content\/uploads\/2018\/09\/product-view-1200x502.webp","datePublished":"2018-09-28T10:37:20+00:00","dateModified":"2026-01-29T13:44:33+00:00","description":"Learn How to Create a Dropdown Product Attribute in Magento 2 Programmatically Using Data Patch and Source Model","breadcrumb":{"@id":"https:\/\/webkul.com\/blog\/create-drop-down-product-attribute-in-magento-2\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/webkul.com\/blog\/create-drop-down-product-attribute-in-magento-2\/"]}]},{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/webkul.com\/blog\/create-drop-down-product-attribute-in-magento-2\/#primaryimage","url":"https:\/\/cdnblog.webkul.com\/blog\/wp-content\/uploads\/2018\/09\/product-view.webp","contentUrl":"https:\/\/cdnblog.webkul.com\/blog\/wp-content\/uploads\/2018\/09\/product-view.webp","width":1423,"height":595},{"@type":"BreadcrumbList","@id":"https:\/\/webkul.com\/blog\/create-drop-down-product-attribute-in-magento-2\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/webkul.com\/blog\/"},{"@type":"ListItem","position":2,"name":"Create dropdown product attribute in Magento 2"}]},{"@type":"WebSite","@id":"https:\/\/webkul.com\/blog\/#website","url":"https:\/\/webkul.com\/blog\/","name":"Webkul Blog","description":"","publisher":{"@id":"https:\/\/webkul.com\/blog\/#organization"},"potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/webkul.com\/blog\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":"Organization","@id":"https:\/\/webkul.com\/blog\/#organization","name":"WebKul Software Private Limited","url":"https:\/\/webkul.com\/blog\/","logo":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/webkul.com\/blog\/#\/schema\/logo\/image\/","url":"https:\/\/cdnblog.webkul.com\/blog\/wp-content\/uploads\/2021\/08\/webkul-logo-accent-sq.png","contentUrl":"https:\/\/cdnblog.webkul.com\/blog\/wp-content\/uploads\/2021\/08\/webkul-logo-accent-sq.png","width":380,"height":380,"caption":"WebKul Software Private Limited"},"image":{"@id":"https:\/\/webkul.com\/blog\/#\/schema\/logo\/image\/"},"sameAs":["https:\/\/www.facebook.com\/webkul\/","https:\/\/x.com\/webkul","https:\/\/www.instagram.com\/webkul\/","https:\/\/www.linkedin.com\/company\/webkul","https:\/\/www.youtube.com\/user\/webkul\/"]},{"@type":"Person","@id":"https:\/\/webkul.com\/blog\/#\/schema\/person\/3d52d6c1ad8a809d2f7548e6a9c3358f","name":"Prabhat Rawat","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/webkul.com\/blog\/#\/schema\/person\/image\/","url":"https:\/\/secure.gravatar.com\/avatar\/616ec5deaf63b72b3003cf99e608ae354f4d373cee8d25b2d0bfa65cab270ad8?s=96&d=https%3A%2F%2Fcdnblog.webkul.com%2Fblog%2Fwp-content%2Fuploads%2F2019%2F10%2Fmike.png&r=g","contentUrl":"https:\/\/secure.gravatar.com\/avatar\/616ec5deaf63b72b3003cf99e608ae354f4d373cee8d25b2d0bfa65cab270ad8?s=96&d=https%3A%2F%2Fcdnblog.webkul.com%2Fblog%2Fwp-content%2Fuploads%2F2019%2F10%2Fmike.png&r=g","caption":"Prabhat Rawat"},"url":"https:\/\/webkul.com\/blog\/author\/prabhat-rawat763\/"}]}},"amp_enabled":true,"_links":{"self":[{"href":"https:\/\/webkul.com\/blog\/wp-json\/wp\/v2\/posts\/145371","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/webkul.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/webkul.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/webkul.com\/blog\/wp-json\/wp\/v2\/users\/170"}],"replies":[{"embeddable":true,"href":"https:\/\/webkul.com\/blog\/wp-json\/wp\/v2\/comments?post=145371"}],"version-history":[{"count":11,"href":"https:\/\/webkul.com\/blog\/wp-json\/wp\/v2\/posts\/145371\/revisions"}],"predecessor-version":[{"id":524269,"href":"https:\/\/webkul.com\/blog\/wp-json\/wp\/v2\/posts\/145371\/revisions\/524269"}],"wp:attachment":[{"href":"https:\/\/webkul.com\/blog\/wp-json\/wp\/v2\/media?parent=145371"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/webkul.com\/blog\/wp-json\/wp\/v2\/categories?post=145371"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/webkul.com\/blog\/wp-json\/wp\/v2\/tags?post=145371"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}