Ejemplo n.º 1
0
 function removeFitments($request, $product)
 {
     $schema = new Elite_Vaf_Model_Schema();
     if (is_array($request->getParam('vaf-delete')) && count($request->getParam('vaf-delete')) >= 1) {
         foreach ($request->getParam('vaf-delete', array()) as $fit) {
             $fit = explode('-', $fit);
             $level = $fit[0];
             $fit = $fit[1];
             if ($level == $schema->getLeafLevel()) {
                 $product->deleteVafFit($fit);
             }
         }
     }
 }
 protected function saveLeafLevels()
 {
     $schema = new Elite_Vaf_Model_Schema();
     $select = $this->getReadAdapter()->select()->from('elite_' . $schema->getLeafLevel());
     $result = $select->query();
     $vehicleFinder = new Elite_Vaf_Model_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) {
         }
     }
 }
function vafDoLevel($level, $parent_id = 0)
{
    $schema = new Elite_Vaf_Model_Schema();
    $finder = new Elite_Vaf_Model_Level($level);
    $parentLevel = $schema->getPrevLevel($level);
    if ($parentLevel) {
        $entities = $finder->listInUse(array($parentLevel => $parent_id));
    } else {
        $entities = $finder->listInUse();
    }
    echo $level . '["' . $parent_id . '"] = new Array();';
    foreach ($entities as $entity) {
        ?>
        var obj = new Array();
        obj["title"] = "<?php 
        echo $entity->getTitle();
        ?>
";
        obj["id"] = "<?php 
        echo $entity->getId();
        ?>
";
        <?php 
        echo $level;
        ?>
["<?php 
        echo $parent_id;
        ?>
"].push( obj );
        <?php 
        if ($level != $schema->getLeafLevel()) {
            vafDoLevel($schema->getNextLevel($level), $entity->getId());
        }
        echo "\n";
    }
}
Ejemplo n.º 4
0
 function getLeafValue()
 {
     $leaf = $this->schema->getLeafLevel();
     return $this->getValue($leaf);
 }
Ejemplo n.º 5
0
 /**
  * Create duplicate
  *
  * @return Mage_Catalog_Model_Product
  */
 function duplicate()
 {
     $schema = new Elite_Vaf_Model_Schema();
     $vehicleFinder = new Elite_Vaf_Model_Vehicle_Finder($schema);
     $leaf = $schema->getLeafLevel() . '_id';
     $newProduct = parent::duplicate();
     foreach ($this->getFits() as $fit) {
         $vehicle = $vehicleFinder->findByLeaf($fit->{$leaf});
         $newProduct->insertMapping($vehicle);
     }
     if ($this->isUniversal()) {
         $newProduct->setUniversal(true);
     }
     return $newProduct;
 }
Ejemplo n.º 6
0
 function getLeafLevel()
 {
     $schema = new Elite_Vaf_Model_Schema();
     return $schema->getLeafLevel();
 }