コード例 #1
0
 protected function importTaxRules()
 {
     $this->truncateTables(array('tax_rule'));
     $handle = $this->openCsvFile('tax_rules.csv');
     for ($current_line = 0; $line = fgetcsv($handle, MAX_LINE_SIZE, ';'); $current_line++) {
         $res = false;
         $fields = $this->filterFields('TaxRule', $this->tax_rule_fields, $line);
         if (!isset($fields['id'])) {
             $tax_rule = new TaxRule($line[0]);
             $tax_rule->id = $line[0];
         } else {
             $tax_rule = new TaxRule($fields['id']);
         }
         foreach ($fields as $key => $field) {
             $tax_rule->{$key} = $field;
         }
         $tax_rule->force_id = true;
         if (!$res) {
             $res = $tax_rule->add();
         }
     }
     $this->closeCsvFile($handle);
     return true;
 }