We have a scenario where schools.csv
file will be uploaded under schoolsearch
folder under the Magento root directory. This should update the schools
table under Magento database. But since migration its not working. We are using a module for this task. But its not working. The following is the content of observer.php
class Attigo_Schoolsearch_Model_Observer { protected function getfilepath() { Mage::getBaseDir(). DS .'csv'. DS . 'schoolsearch/schools.csv'; } public function schoolDetail() { $row=array(); //$filePath = $this->getfilepath(); $filePath = "/var/www/html/main/schoolsearch/schools.csv"; if (($handle = fopen($filePath, 'r')) !== FALSE) { $i=0; while (($data = fgetcsv($handle, 1000, '\t')) !== FALSE) { if($i==0) { $i++; continue; } if($data != "") { foreach ($data as $school) { // echo $school.''; $row=explode("\t",$school); } $school = Mage::getModel('schoolsearch/schools'); $school->setKundnr($row[0]); $school->setSkola($row[1]); $school->setBadress($row[2]); $school->setBadress1($row[3]); $school->setBpostnummer($row[4]); $school->setBpostort($row[5]); $school->setFakturamottagare($row[6]); $school->setFakturaadress1($row[7]); $school->setFakturaadress2($row[8]); $school->setFpostnr($row[9]); $school->setFpostort($row[10]); $school->setBadressid($row[11]); $school->setFakturaadressid($row[12]); $school->setBcountrycode($row[13]); $school->setFakturacountrycode($row[14]); $school->save(); // print_r($school); // echo $row[13].'->'.$row[14].''; } $i++; } } else { echo "permission denide"; } } public function AddCustomerGroup(Varien_Event_Observer $observer) { $_post = Mage::app()->getFrontController()->getRequest()->getParams(); try { $customer = $observer->getEvent()->getCustomer(); $customer->setData('group_id', $_post['group_id']); // or whatever the group id should be $customer->save(); } catch ( Exception $e ) { echo $e->getMessage; } } }
Can any one help me where it goes wrong?