/**
  * @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);
             }
         }
     }
 }
    function testShouldThrowExceptionForInvalidProductTable()
    {
        $this->setExpectedException('Zend_Db_Statement_Exception');
        $this->query(sprintf("INSERT INTO `ps_product` ( `reference` ) values ( '%s' )", 'foobar123'));
        $productID = $this->getReadAdapter()->lastInsertId();
        $this->mappingsImporterFromData('sku, make, model, year
foobar123, honda, civic, 2000')->setProductTable('invalid')->setProductSkuField('reference')->setProductIdField('id_product')->import();
        $product = new VF_Product();
        $product->setId($productID);
        $fitments = $product->getFitModels();
        $this->assertEquals('honda civic 2000', $fitments[0]->__toString(), 'should add fitment to product');
    }
 /**
  * @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 testShouldMakeSafeOperations()
 {
     $this->createVehicle(array('year' => 2000, 'make' => 'Ford', 'model' => 'F-150', 'engine' => '1.6L'));
     $this->createVehicle(array('year' => 2000, 'make' => 'Ford', 'model' => 'F-150', 'engine' => '1.8L'));
     $this->createVehicle(array('year' => 2001, 'make' => 'Ford', 'model' => 'F-150', 'engine' => '1.6L'));
     // there is no 2001/Ford/F-150 with a 1.8L in this example
     $this->mappingsImport('sku, make, model, year, engine' . "\n" . 'sku,Ford,F-150,"2000,2001,2002",{{all}}');
     $product = new VF_Product();
     $product->setId($this->product_id);
     $fits = $product->getFits();
     $this->assertEquals(3, count($fits), 'should not a non-existant vehicle even it is implied');
 }
 function testShouldImportFitments()
 {
     $this->query("INSERT INTO test_catalog_product_entity ( `sku` ) values ( 'sku123' )");
     $productID = $this->getReadAdapter()->lastInsertId();
     $file = sys_get_temp_dir() . '/' . uniqid();
     $data = "sku,make,model,year\n";
     $data .= "sku123,Honda,Civic,2000";
     file_put_contents($file, $data);
     $command = __DIR__ . '/vfmagento importfitments --product-table=test_catalog_product_entity ' . $file;
     `{$command}`;
     $product = new VF_Product();
     $product->setId($productID);
     $fitments = $product->getFitModels();
     $this->assertEquals('Honda Civic 2000', $fitments[0]->__toString(), 'should import fitment');
 }
Esempio n. 6
0
    function testBlowoutMultipleColumn()
    {
        $this->importVehiclesList($this->vehiclesList);
        $this->mappingsImport('sku, make, model, year
sku, honda, {{all}}, {{all}}');
        $product = new VF_Product();
        $product->setId($this->product_id);
        $fits = $product->getFits();
        $this->assertEquals(3, count($fits), 'should blow out options');
        $this->assertEquals('civic', $fits[0]->model);
        $this->assertEquals('accord', $fits[1]->model);
        $this->assertEquals('2000', $fits[1]->year);
        $this->assertEquals('accord', $fits[2]->model);
        $this->assertEquals('2001', $fits[2]->year);
    }
Esempio n. 7
0
 function productmanageAction()
 {
     $schema = new \VF_Schema();
     $product = new \VF_Product();
     $product->setId($this->params()->fromRoute('id'));
     if ($this->getRequest()->isPost()) {
         $this->removeFitments($product);
         $this->updateUniversal($product);
         //$this->updateRelated($product);
         $this->addNewFitments($product);
         $this->flashMessenger()->addSuccessMessage('Produt\'s fitments saved');
     }
     $view = new ViewModel(array('fitments' => $product->getFits(), 'product' => $product, 'schema' => $schema->getLevels()));
     $view->setTemplate('fitments/index/multitree.phtml');
     return $view;
 }
    function testShouldImportPrestaShop()
    {
        $this->query(sprintf("INSERT INTO `ps_product` ( `reference` ) values ( '%s' )", 'foobar123'));
        $productID1 = $this->getReadAdapter()->lastInsertId();
        $this->query(sprintf("INSERT INTO `ps_product` ( `reference` ) values ( '%s' )", 'foobar456'));
        $productID2 = $this->getReadAdapter()->lastInsertId();
        $this->mappingsImporterFromData('sku, make, model, year
foo*, honda, civic, 2000')->setProductTable('ps_product')->setProductSkuField('reference')->setProductIdField('id_product')->import();
        $product1 = new VF_Product();
        $product1->setId($productID1);
        $product2 = new VF_Product();
        $product2->setId($productID2);
        $fitments = $product1->getFitModels();
        $this->assertEquals('honda civic 2000', $fitments[0]->__toString(), 'should add fitment to product');
        $fitments = $product2->getFitModels();
        $this->assertEquals('honda civic 2000', $fitments[0]->__toString(), 'should add fitment to product');
    }
Esempio n. 9
0
 function export($stream)
 {
     fwrite($stream, '"sku","section_width","aspect_ratio","diameter"');
     fwrite($stream, "\n");
     foreach ($this->getProductRows() as $productRow) {
         $product = new VF_Product();
         $product->setId($productRow['entity_id']);
         $product = new VF_Tire_Catalog_TireProduct($product);
         if ($product->getTireSize()) {
             $tireSize = $product->getTireSize();
             fwrite($stream, '"' . $productRow['sku'] . '",');
             fwrite($stream, '"' . $tireSize->sectionWidth() . '",');
             fwrite($stream, '"' . $tireSize->aspectRatio() . '",');
             fwrite($stream, '"' . $tireSize->diameter() . '"');
             fwrite($stream, "\n");
         }
     }
 }
 function testUnbindBoltFromProduct()
 {
     $this->setRequestParams(array('wheel_side_pattern' => '4x114.3'));
     $binder = new Elite_Vafwheeladapter_Observer_WheelSideBinder();
     $product = new Elite_Vaf_Model_Catalog_Product();
     $product->setId(1);
     $event = $this->event($product);
     $binder->bindWheelSide($event);
     $this->setRequestParams(array('wheel_side_pattern' => ''));
     $binder = new Elite_Vafwheeladapter_Observer_WheelSideBinder();
     $product = new Elite_Vaf_Model_Catalog_Product();
     $product->setId(1);
     $event = $this->event($product);
     $binder->bindWheelSide($event);
     $VFproduct = new VF_Product();
     $VFproduct->setId($product->getId());
     $wheeladapterProduct = new VF_Wheeladapter_Catalog_Product($VFproduct);
     $this->assertFalse($wheeladapterProduct->getWheelSideBoltPattern(), 'should unbind bolt pattern from product');
 }
 function testAddsAndRemovesBoltPattern()
 {
     $this->setRequestParams(array('multipatterns' => "4x114.3\n5x114.3"));
     $binder = new Elite_Vafwheel_Observer_ProductBoltBinder();
     $product = new Elite_Vaf_Model_Catalog_Product();
     $product->setId(1);
     $event = $this->event($product);
     $binder->addBoltPatterns($event);
     $VFproduct = new VF_Product();
     $VFproduct->setId($product->getId());
     $wheelProduct = new VF_Wheel_Catalog_Product($VFproduct);
     $this->assertEquals(2, count($wheelProduct->getBoltPatterns()));
     $this->setRequestParams(array('wheel_side_pattern' => "4x114.3"));
     $binder = new Elite_Vafwheel_Observer_ProductBoltBinder();
     $product = new Elite_Vaf_Model_Catalog_Product();
     $product->setId(1);
     $event = $this->event($product);
     $binder->addBoltPatterns($event);
     $VFproduct = new VF_Product();
     $VFproduct->setId($product->getId());
     $wheelProduct = new VF_Wheel_Catalog_Product($VFproduct);
     $this->assertEquals(1, count($wheelProduct->getBoltPatterns()), 'removes previously added bolt patterns');
 }
Esempio n. 12
0
 function getVFProductForSku($sku)
 {
     $sql = sprintf("SELECT `entity_id` from `test_catalog_product_entity` WHERE `sku` = %s", $this->getReadAdapter()->quote($sku));
     $r = $this->query($sql);
     $product_id = $r->fetchColumn();
     $r->closeCursor();
     $product = new VF_Product();
     $product->setId($product_id);
     return $product;
 }
Esempio n. 13
0
 public static function getJoins()
 {
     return VF_Product::getJoins();
 }