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(); }
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 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()); }