public static function cascadeCreate($names, $separator = " > ") { $array = explode($separator, $names); foreach ($array as $index => $name) { $array[$index] = trim($name); } $producttypearray = array(); //do first one (special treatment for root) $producttype = Fetcher::fetchOne("Producttype", array('name' => '"' . $array[0] . '"')); $parent_id = $producttype->getId(); $producttypearray[] = $producttype; foreach ($array as $index => $name) { //skip first one if ($index == 0) { continue; } //fetch next producttype based on previous $producttype = Doctrine_Query::create()->from('Producttype p')->where('p.name="' . $name . '"')->andWhere('p.parent_id="' . $parent_id . '"')->fetchOne(); //one of the nodes not found //if null, create if (!$producttype) { //create $producttype = ProducttypeTable::createOne(array('name' => $name, 'parent_id' => $parent_id, 'priority' => 2)); } //prepare for next round $parent_id = $producttype->getId(); //add to array, whether fetched object or null $producttypearray[] = $producttype; } return $producttypearray; }
private function processline($line) { //save data from parsed inputstring to array $productname = $line[1]; $object = Fetcher::fetchOne("Product", array('name' => '"' . $productname . '"')); $producttype = $this->main->producttypedata->items[$line[3]]["object"]; $this->hydrate($productname, $line, $object, $producttype); }
private function processLine($index, $line) { //save data from parsed inputstring to array $name = $line[1]; //if this producttype is already in the array if (array_key_exists($name, $this->items)) { continue; } //search database for producttype by name //$array=ProducttypeTable::followBreadCrumbsByNames($name," > "); //$object=count($array)?$array[count($array)-1]:null; $object = Fetcher::fetchOne("Producttype", array('path' => '"' . $name . '"')); $this->items[$name] = array('name' => $name, 'description' => $line[2] ? $line[2] : ($object ? $object->getDescription() : ""), 'category1' => $line[3] ? $line[3] : ($object ? $object->getCategory1() : ""), 'category2' => $line[4] ? $line[4] : ($object ? $object->getCategory2() : ""), 'category3' => $line[5] ? $line[5] : ($object ? $object->getCategory3() : ""), 'category4' => $line[6] ? $line[6] : ($object ? $object->getCategory4() : ""), 'category5' => $line[7] ? $line[7] : ($object ? $object->getCategory5() : ""), 'category6' => $line[8] ? $line[8] : ($object ? $object->getCategory6() : ""), 'category7' => $line[9] ? $line[9] : ($object ? $object->getCategory7() : ""), 'category8' => $line[10] ? $line[10] : ($object ? $object->getCategory8() : ""), 'category9' => $line[11] ? $line[11] : ($object ? $object->getCategory9() : ""), 'category10' => $line[12] ? $line[12] : ($object ? $object->getCategory10() : ""), 'object' => $object, 'from' => "producttypesection"); }
private function processAddProduct($index, $line) { //save data from parsed inputstring to array $name = $line[1]; //search database for producttype by name $producttype = Fetcher::fetchOne("Producttype", array('path' => '"' . $name . '"')); //if not found if (!$producttype) { return; } $this->main->producttypedata->addProducttype($producttype); //ask the product data group to add each product in this producttype foreach ($producttype->getProducts() as $product) { $this->main->productdata->addProduct($product, $producttype); } }
public function processById($id) { $this->pricelist = Fetcher::fetchOne("Pricelist", array('id' => $id)); $this->hydrate(); //this needs to happen after the pricelist is loaded $this->main->inputstring = $this->pricelist->getQuickInputString(); }
public function getSimilarQuote() { return Fetcher::fetchOne("Quote", array('total' => $this->getUnittotal(), 'vendor_id' => SettingsTable::fetch("me_vendor_id"), 'product_id' => $this->getProductId())); }