Hi,
I am facing a problem in storing values, at a time in a loop in magento front-end product upload.Values remain same for all stores.Can't figure out how it can be recovered.Please help.
Thanks
$xlsx = new SimpleXLSX($path . DS.$fileName );
list($cols,) = $xlsx->dimension();
foreach( $xlsx->rows() as $k => $r) {
if ($k == 0) continue;//Ingnoring first column of excel file
try{
//grabbing categories for en
$key=array_search($r[55],$cat_arr);
$key2=array_search($r[56],$cat_arr);
$key3=array_search($r[57],$cat_arr);
//grabbing categories for de
$keyde=array_search($r[52],$cat_arr);
$key2de=array_search($r[53],$cat_arr);
$key3de=array_search($r[54],$cat_arr);
//grabbing categories for nl
$keynl=array_search($r[49],$cat_arr);
$key2nl=array_search($r[50],$cat_arr);
$key3nl=array_search($r[51],$cat_arr);
//Set the path of image folder
$imgpath_total="D:\wamp\www\liquor\media\proimg/adidas.jpg";//.$r[59]
$newProduct = new Mage_Catalog_Model_Product();
$newProduct->setAttributeSetId(4)
->setTypeId('simple')
->setVisibility(Mage_Catalog_Model_Product_Visibility::VISIBILITY_BOTH)
->setTaxClassId(2)
->setCreatedAt(strtotime('now'))
->setSku($r[39])
->setWeight($r[40])
->setBrand($r[5])
->setTags($r[58])
->setAlc_percentage($r[42])
->setWeight('10')
->setEan($r[37])
->setStatus(1)
->setPrice($r[22])
->setWebsiteIds(array(1))
->setStockData(array('is_in_stock' => 1, 'qty' => 99999 ))
->setSetupFee(522)
->addImageToMediaGallery($imgpath_total,array('image','small_image','thumbnail'),false,false)
->setsetupCost(100)
########En DATA##########
->setName($r[17])
->setTitle_long($r[18])
->setGoogle($r[64])
->setDescription($r[20])
->setShort_description($r[19])
->setCategoryIds(array(2,$key,$key2,$key3))
->setStoreId(1)
########En DATA##########
########de DATA##########
->setName($r[12])
->setTitle_long($r[13])
->setGoogle($r[63])
->setDescription($r[15])
->setShort_description($r[14])
->setCategoryIds(array(2,$keyde,$key2de,$key3de))
->setStoreId(7)
########de DATA##########
########nl DATA##########
->setName($r[7])
->setTitle_long($r[8])
->setGoogle($r[62])
->setDescription($r[10])
->setShort_description($r[9])
->setCategoryIds(array(2,$keynl,$key2nl,$key3nl))
->setStoreId(8);
########nl DATA##########
$newProduct->save();
#####save your product###################
}catch(Exception $e){
$result['status'] = 3;
$result['message'] = 'There is an ERROR happened! NOT ALL products are created! Error:'.$e->getMessage();
echo json_encode($result);
return;
}
}
Code is here