function main()
 {
     if (!$this->lastArgument()) {
         echo 'vfmagento importvehicles <filename>' . "\n";
         exit;
     }
     $file = $this->lastArgument();
     $importer = new VF_Import_ProductFitments_CSV_Import($file);
     $importer->setProductTable($this->opt->getOption('product-table'));
     $importer->import();
 }
Exemplo n.º 2
0
    protected function doSetUp()
    {
        $this->switchSchema('make,model,year');
        $this->csvData = 'sku, make, model, year, universal
sku123, honda, civic, 2001
sku456, honda, civic, 2000
sku456,acura,integra,2000
sku123,acura,integra,2004
sku123,acura,test,2002
';
        $this->csvFile = TEMP_PATH . '/mappings-single.csv';
        file_put_contents($this->csvFile, $this->csvData);
        $this->insertProduct('sku123');
        $this->insertProduct('sku456');
        $importer = new VF_Import_ProductFitments_CSV_Import($this->csvFile);
        $importer->setProductTable('test_catalog_product_entity');
        $importer->import();
    }
 function main()
 {
     $newCsv = '';
     $newCsv .= "sku,make,model,year\n";
     for ($this->i = 1; $this->i <= 300; $this->i++) {
         $line = "";
         $line .= 'YJSU-20';
         $line .= ",";
         $line .= 'make' . rand(1, 25);
         $line .= ",";
         $line .= 'model' . rand(1, 25);
         $line .= ",";
         $year = rand(1950, 2010);
         $line .= $year;
         $newCsv .= $line . "\n";
     }
     $file = getenv('PHP_TEMP_PATH') . '/sampleMappings.csv';
     file_put_contents($file, $newCsv);
     $importer = new VF_Import_ProductFitments_CSV_Import($file);
     $importer->import();
     echo "data imported\n";
 }
Exemplo n.º 4
0
 function indexAction()
 {
     $schema = $this->schema();
     if ($this->getRequest()->isPost()) {
         if ($this->attemptedFileUpload() && $this->fileUploadHasError()) {
             $this->flashFileUploadErrorMessage();
         } else {
             if ($_FILES['file']['tmp_name']) {
                 $tmpFile = $_FILES['file']['tmp_name'];
             } else {
                 $tmpFile = sys_get_temp_dir() . '/' . sha1(uniqid());
                 file_put_contents($tmpFile, $_POST['text']);
             }
             $shoppingCartEnvironment = $this->shoppingCartEnvironment();
             $dbInfo = $shoppingCartEnvironment->databaseDetails();
             $importer = new \VF_Import_ProductFitments_CSV_Import($tmpFile);
             $importer->setProductTable($dbInfo['product_table'])->setProductSkuField($dbInfo['product_sku_field'])->setProductIdField($dbInfo['product_id_field']);
             //$importer->setLog($log);
             $importer->import();
             $this->flashMessenger()->setNamespace('success')->addMessage('Imported Fitments');
         }
     }
     return array('schema' => $schema->getLevels());
 }