function testFindsMatchingProduct() { $bolt = VF_Wheel_BoltPattern::create('4x114.3'); $product = $this->newWheelProduct(1); $product->addBoltPattern($bolt); $this->assertEquals(array(1), $this->wheelFinder()->getProductIds($bolt), 'should find products with this bolt pattern'); }
function wheelSize($row) { $lugCount = $this->getFieldValue('lug_count', $row); $boltDistance = $this->getFieldValue('bolt_distance', $row); $offset = $this->getFieldValue('offset', $row); return VF_Wheel_BoltPattern::create($lugCount . 'x' . $boltDistance, $offset); }
/** * @param Varien_Controller_Action * @param Mage_Catalog_Model_Product */ protected function doAddBoltPatterns($controller, Elite_Vaf_Model_Catalog_Product $product) { $VFproduct = new VF_Product(); $VFproduct->setId($product->getId()); $wheelProduct = new VF_Wheel_Catalog_Product($VFproduct); $wheelProduct->removeBoltPatterns(); /** @todo get under test */ if (isset($_FILES['boltpatterncsv']) && $_FILES['boltpatterncsv']['tmp_name'] && $_FILES['boltpatterncsv']['error'] == 0) { $importer = new VF_Wheel_Catalog_Product_Import($_FILES['boltpatterncsv']['tmp_name']); $importer->import(); } else { $patterns = $controller->getRequest()->getParam('wheel_side_pattern') ? $controller->getRequest()->getParam('wheel_side_pattern') : $controller->getRequest()->getParam('multipatterns'); $patterns = explode("\n", $patterns); foreach ($patterns as $k => $pattern) { $pattern = str_replace("\r", '', $pattern); if (!trim($pattern)) { return; } $boltPattern = VF_Wheel_BoltPattern::create($pattern); if (!is_array($boltPattern)) { $boltPattern = array($boltPattern); } foreach ($boltPattern as $each) { $wheelProduct->addBoltPattern($each); } } } }
/** * @param array $row * @param VF_Vehicle|boolean the vehicle, false if none (for example, when setting a product as universal) */ function doImportRow($row, $vehicle) { $boltPattern = $this->getFieldValue('bolt_pattern', $row); $offset = $this->getFieldValue('offset', $row); $boltPattern = VF_Wheel_BoltPattern::create($boltPattern, $offset); $wheelDefinition = new VF_Wheel_Vehicle($vehicle); $wheelDefinition->addBoltPattern($boltPattern); }
/** * @param Varien_Controller_Action * @param Mage_Catalog_Model_Product */ function doBindWheelSide($controller, Elite_Vaf_Model_Catalog_Product $product) { $VFproduct = new VF_Product(); $VFproduct->setId($product->getId()); $wheeladapterProduct = new VF_Wheeladapter_Catalog_Product($VFproduct); $pattern = $controller->getRequest()->getParam('wheel_side_pattern'); if (!$pattern) { return $wheeladapterProduct->unsetWheelSideBoltPattern(); } $boltPattern = VF_Wheel_BoltPattern::create($pattern); $wheeladapterProduct->setWheelSideBoltPattern($boltPattern); }
function getWheelSideBoltPattern() { if (!$this->getId()) { return false; } $select = $this->getReadAdapter()->select()->from('elite_product_wheeladapter')->where('entity_id=?', $this->getId())->limit(1); $result = $select->query(); $row = $result->fetchObject(); if (!$row) { return false; } return VF_Wheel_BoltPattern::create($row->lug_count . 'x' . $row->bolt_distance); }
function getBoltPatterns() { if (!$this->getId()) { return array(); } $select = $this->getReadAdapter()->select()->from('elite_product_wheel')->where('entity_id=?', $this->getId()); $result = $select->query(); $return = array(); while ($row = $result->fetchObject()) { $bolt = VF_Wheel_BoltPattern::create($row->lug_count . 'x' . $row->bolt_distance, $row->offset); array_push($return, $bolt); } $result->closeCursor(); return $return; }
function vehicleBolt() { $vehicleBoltString = $this->vehicleSideLugCount() . 'x' . $this->vehicleSideStudSpread(); return VF_Wheel_BoltPattern::create($vehicleBoltString); }
function boltPattern() { return VF_Wheel_BoltPattern::create($this->boltString()); }
function boltPattern($boltPatternString, $offset = null) { return VF_Wheel_BoltPattern::create($boltPatternString, $offset); }
function testOffsetThresholdMaximum() { $bolt = VF_Wheel_BoltPattern::create('4x114.3', 20); $this->assertEquals(25, $bolt->offsetMax()); }