- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-19-2017
01:57 AM
07-19-2017
01:57 AM
Insert attribute options (values) in bulk
Hi,
I created a custom drop down attribute in magento 2 and i hundreds of options to add in the attribute. What is the best way to add in bulk, maybe using a csv file or using direct query.
Thanks
Labels:
3 REPLIES 3
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-19-2017
02:06 AM
07-19-2017
02:06 AM
Re: Insert attribute options (values) in bulk
Your best way is using Direct sql query.
You cant do within csv file to import multiple option of attribute because there are not native code for that using csv.
You have to refer below link to using sql query,
Insert multiple option value of attribute.
If issue solved, Click Kudos/Accept As Solutions.
If Issue Solved, Click Kudos/Accept As solutions. Get Magento insight from
Magento 2 Blogs/Tutorial
Magento 2 Blogs/Tutorial
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-23-2019
01:39 AM
05-23-2019
01:39 AM
Re: Insert attribute options (values) in bulk
Follow this Link to do so "https://www.pearlbells.co.uk/import-attribute-options-magento-2-programmatically/"
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-23-2019
02:18 AM
05-23-2019
02:18 AM
Re: Insert attribute options (values) in bulk
Hi@abdulwahab1290 ,
You can add custom options programmatically using following code.
/** @var \Magento\Catalog\Api\Data\ProductCustomOptionInterface $customOption */ $customOption = $this->objectManager->create('Magento\Catalog\Api\Data\ProductCustomOptionInterface'); $customOption->setTitle('Text') ->setType('area') ->setIsRequire(true) ->setSortOrder(1) ->setPrice(1.00) ->setPriceType('fixed') ->setMaxCharacters(50) ->setProductSku($product->getSku()); $customOptions[] = $customOption; $product->setOptions($customOptions)->save();
I hope it will help you!