function insertMapping(Elite_Vaf_Model_Vehicle $vehicle) { $mapping = new Elite_Vaf_Model_Mapping($this->getId(), $vehicle); return $mapping->save(); }
<?php require_once 'F:\\dev\\vaf\\app\\code\\local\\Elite\\Vaf\\bootstrap-tests.php'; $schemaGenerator = new Elite_Vaf_Model_Schema_Generator(); $schemaGenerator->dropExistingTables(); $schemaGenerator->execute(array('make', 'model', 'year')); $schema = new Elite_Vaf_Model_Schema(); $vehicle = Elite_Vaf_Model_Vehicle::create($schema, array('make' => 'Honda_Unique' . uniqid(), 'model' => 'Civic', 'year' => '2002')); $vehicle->save(); $values = $vehicle->toValueArray(); $mapping = new Elite_Vaf_Model_Mapping(1, $vehicle); $mapping->save(); ?> <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> <html> <head> <link rel="stylesheet" href="../qunit/qunit.css" type="text/css"/> <script src="/skin/adminhtml/default/default/jquery-1.4.2.min.js"> </script> <script src="/skin/adminhtml/default/default/jquery.metadata.pack.js"> </script> <script type="text/javascript" src="../qunit/qunit.js"></script> <script type="text/javascript" src="/vaf/ajax/js?front=1"></script> <script type="text/javascript" src="../common.js"></script> <script type="text/javascript"> jQuery(document).ready(function($){ QUnit.done = function (failures, total) { top.testPageComplete( 'ajaxTestJs/MMYLoadNextLevelAuto.php', failures, total ); };
/** * @var integer product id * @var mixed boolean false for universal, or Elite_Vaf_Model_Vehicle to create a mapping for */ function insertMapping($row, $vehicle) { $sku = $this->sku($row); $productId = $this->productId($sku); if (!$productId) { $this->skipped_mappings++; return; } if ($this->isUniversal($row)) { $product = new Elite_Vaf_Model_Catalog_Product(); $product->setId($productId); $product->setUniversal(1); return; } if (false === $vehicle) { $this->invalid_vehicle_count++; $this->skipped_mappings++; return; } $mapping = new Elite_Vaf_Model_Mapping($productId, $vehicle); if ($this->hasMapping($productId, $vehicle)) { $this->already_existing_mappings++; $this->skipped_mappings++; return $mapping->save(); } $mapping_id = $mapping->save(); if (!$mapping_id) { $this->skipped_mappings++; } else { $this->added_mappings++; } return $mapping_id; }