I'm using Magento 2.1.3.
Is it possible to import product attributes and attribute sets or do I have to create them manually before importing products with specific attributes?
In Magento 2 product can't be imported if attribute set is absent in system.
You will receive next error after Data Validation:
Invalid value for Attribute Set column (set doesn't exist?) in row(s): x
You have to create attribute set manually in Admin Panel or via API request.
$eavSetupFactory = $objectManager->get('\Magento\Eav\Setup\EavSetupFactory'); $storeManager = $objectManager->get('Magento\Store\Model\StoreManagerInterface')->getStore(); $attributeFactory = $objectManager->get('\Magento\Catalog\Model\ResourceModel\Eav\Attribute'); $attribute_arr = ['Franciscan Slate','Union Square','Timber Glen','Terrace','Sandalo']; $attributeInfo= $attributeFactory->getCollection() ->addFieldToFilter('attribute_code',['eq'=>"styles_name"]) ->getFirstItem(); $attribute_id = $attributeInfo->getAttributeId(); $option=array(); $option['attribute_id'] = $attributeInfo->getAttributeId(); foreach($attribute_arr as $key=>$value){ $option['value'][$value][0]=$value; } $eavSetup = $eavSetupFactory->create(); $eavSetup->addAttributeOption($option);
you can create product attributes and attribute sets through admin panel or programatically with M2 module. I don't know way to create product attributes/sets through import.