0

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?

  • U have to create from Admin first then u can import – Ankit Shah Feb 1 '17 at 9:35
1

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.

See: Attribute Set REST API

1

$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);


0

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.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.