array_push($pa, $c); } } // $pa = explode("\r\n\r\n", $ps); foreach ($pa as $key => $pc) { $pct = explode("":"", $pc); $fa[$key]['ASIN'] = str_replace("","MYIService.Quantity", "", $pct[1]); $fa[$key]['Qty'] = str_replace("","MYIService.Points", "", $pct[2]); $fa[$key]['Price'] = str_replace("","MYIService.Sku", "", $pct[12]); $fa[$key]['Sku'] = str_replace("","MYIService.Title", "", $pct[13]); $fa[$key]['Name'] = str_replace("","MYIService.CurrencyCode", "", $pct[14]); } $fn = $_POST['filename']; $file = new File("{$fn}.csv", "var/code-to-csv"); $headings = '"ASIN","Price","Sku","Name"'; $file->write_to_file($headings . "\n"); foreach ($fa as $key => $fp) { if ($fp['Qty'] != 0) { $text = '"' . $fp['ASIN'] . '",'; $text .= '"' . $fp['Price'] . '",'; $text .= '"' . $fp['Sku'] . '",'; $text .= '"' . $fp['Name'] . '"'; $file->write_to_file($text . "\n"); } } } $form = new Forms(); $form->start("filter.php"); $form->input("filename", "filename"); $form->input("code", "code", "textarea"); $form->button("submit");
public function create_flux() { $report = new Report(); $report->start("flux files"); $report->entry("info", "Flux Settings", "On"); $report->entry("info", "Flux Settings", "Creating flux files"); $file_content = str_replace(",{$this->qty},0,1,", ',0,0,0,', $this->file_content); $file = new File("Flux - {$this->collection_name}.csv", "../var/magmi-import/flux-up/"); $file->write_to_file($this->file_content); if (is_file("../var/magmi-import/flux-up/Flux - {$this->collection_name}.csv")) { $report->entry("success", "Flux Up File", "Flux - {$this->collection_name}.csv created successfully"); } else { $report->entry("danger", "Flux Up File", "Flux - {$this->collection_name}.csv failed to create"); } $file = new File("Flux - {$this->collection_name}.csv", "../var/magmi-import/flux-down/"); $file->write_to_file($file_content); if (is_file("../var/magmi-import/flux-down/Flux - {$this->collection_name}.csv")) { $report->entry("success", "Flux Down File", "Flux - {$this->collection_name}.csv created successfully"); } else { $report->entry("danger", "Flux Down File", "Flux - {$this->collection_name}.csv failed to create"); } $report->end(); }