Exemplo n.º 1
0
 function testFindByLeaf()
 {
     $vehicle = $this->createMMY();
     $yearId = $vehicle->getValue('year');
     $finder = new VF_Vehicle_Finder(new VF_Schema());
     $this->getReadAdapter()->getProfiler()->clear();
     $this->getReadAdapter()->getProfiler()->setEnabled(true);
     $finder->findByLeaf($yearId);
     $finder->findByLeaf($yearId);
     $finder->findByLeaf($yearId);
     $finder->findByLeaf($yearId);
     $queries = $this->getReadAdapter()->getProfiler()->getQueryProfiles();
     $this->assertTrue(count($queries) <= 2);
 }
    /**
     * @deprecated
     */
    function getFitForSku($sku, $schema = null)
    {
        if (is_null($schema)) {
            $schema = new VF_Schema;
        }

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

        $sql = sprintf(
            "SELECT `%s_id` from `elite_1_mapping` WHERE `entity_id` = %d AND `universal` = 0",
            $schema->getLeafLevel(),
            $product_id
        );
        $r = $this->query($sql);
        $leaf_id = $r->fetchColumn();
        $r->closeCursor();

        if (!$leaf_id) {
            return false;
        }
        $finder = new VF_Vehicle_Finder($schema);
        return $finder->findByLeaf($leaf_id);
    }
 protected function saveLeafLevels()
 {
     $schema = new VF_Schema();
     
     $select = $this->getReadAdapter()->select()
         ->from( 'elite_' . $schema->getLeafLevel() );
     $result = $select->query();
     
     $vehicleFinder = new VF_Vehicle_Finder( $schema );
     while( $row = $result->fetchObject() )
     {
         $vehicle = $vehicleFinder->findByLeaf( $row->id );
         $bind = array();
         foreach( $schema->getLevels() as $level )
         {
             $bind[ $level . '_id' ] = $vehicle->getLevel( $level )->getId();
         }
         try
         {
             $this->getReadAdapter()->insert( 'elite_definition', $bind );
         }
         catch( Exception $e )
         {
         }
     }
 }
Exemplo n.º 4
0
 protected function saveLeafLevels()
 {
     $schema = VF_Singleton::getInstance()->schema();
     $select = $this->getReadAdapter()->select()->from('elite_' . $schema->getLeafLevel());
     $result = $select->query();
     $vehicleFinder = new VF_Vehicle_Finder($schema);
     foreach ($result->fetchAll(Zend_Db::FETCH_OBJ) as $row) {
         $vehicle = $vehicleFinder->findByLeaf($row->id);
         $bind = array();
         foreach ($schema->getLevels() as $level) {
             $bind[$level . '_id'] = $vehicle->getLevel($level)->getId();
         }
         try {
             $this->getReadAdapter()->insert('elite_definition', $bind);
         } catch (Exception $e) {
         }
     }
 }
Exemplo n.º 5
0
 /**
  * Create duplicate
  *
  * @return Mage_Catalog_Model_Product
  */
 function duplicate()
 {
     $schema = VF_Singleton::getInstance()->schema();
     $vehicleFinder = new VF_Vehicle_Finder($schema);
     $leaf = $schema->getLeafLevel() . '_id';
     $newProduct = parent::duplicate();
     foreach ($this->getFits() as $fit) {
         print_r($fit);
         exit;
         $vehicle = $vehicleFinder->findByLeaf($fit->{$leaf});
         $newProduct->insertMapping($vehicle);
     }
     if ($this->isUniversal()) {
         $newProduct->setUniversal(true);
     }
     return $newProduct;
 }