I'm programmatically importing simple products in Magento based on a .csv file. Everything works fine, but I have to add some values where I have created some custom attributes for. But I don't know how to add them.
I thought since I added the attribute set where the custom attributes are in, I could add them like
$product->setCustomAttribute(value)
but that doesn't work.
How can I add them?
Rest of the code for reference
if(($handle = fopen("werkbladvoorraad.csv", "r")) !== FALSE){
while(($data = fgetcsv($handle, 1000, ";")) !== FALSE){
$row++;
if($row == 1){
continue;
}
try{
$product ->setStoreId(1)
->setWebsiteIds(array(1))
->setAttributeSetId(4)
->setTypeId('simple')
//->setCreatedAt(strtotime('now'))
->setSku($data[0])
->setName($data[1])
//->setWeight()
->setStatus(1)
->setTaxClassId(2)
->setVisibility(Mage_Catalog_Model_Product_Visibility::VISIBILITY_BOTH)
->setManufacturer($data[14])
->setColor($data[10])
->setPrice($data[6])
->setMaat_heren($data[4]) // CUSTOM ATTRIBUTE
->setStockData(array(
'use_config_manage_stock' => 0,
'manage_stock'=>1,
'min_sale_qty'=>1,
'max_sale_qty'=>2,
'is_in_stock' =>1,
'qty' => 999
));
$product->save();
}catch(Exception $e){
echo ($e->getMessage());
}
}
}
Note
There are no error messages displayed