public static function add($type, $args, $pkg = false) { $ak = parent::add('store_product', $type, $args, $pkg); extract($args); $v = array($ak->getAttributeKeyID()); $db = Database::get(); $db->Execute('REPLACE INTO VividStoreProductAttributeKeys (akID) VALUES (?)', $v); $nak = new StoreProductKey(); $nak->load($ak->getAttributeKeyID()); return $ak; }
public function getAttribute($ak, $displayMode = false) { if (!is_object($ak)) { $ak = StoreProductKey::getByHandle($ak); } if (is_object($ak)) { $av = $this->getAttributeValueObject($ak); if (is_object($av)) { return $av->getValue($displayMode); } } }
public function save() { $data = $this->post(); if ($data['pID']) { $this->edit($data['pID']); } else { $this->add(); } if ($this->isPost()) { $errors = $this->validate($data); $this->error = null; //clear errors $this->error = $errors; if (!$errors->has()) { $product = VividProduct::save($data); $aks = StoreProductKey::getList(); foreach ($aks as $uak) { $uak->saveAttributeForm($product); } if ($data['pID']) { $this->redirect('/dashboard/store/products/', 'updated'); } else { $this->redirect('/dashboard/store/products/', 'success'); } } //if no errors } //if post }
public function edit($akID = 0) { if ($this->post('akID')) { $akID = $this->post('akID'); } $key = StoreProductKey::getByID($akID); $type = $key->getAttributeType(); $this->set('key', $key); $this->set('type', $type); $this->set('category', AttributeKeyCategory::getByHandle('store_product')); if ($this->isPost()) { $cnt = $type->getController(); $cnt->setAttributeKey($key); $e = $cnt->validateKey($this->post()); if ($e->has()) { $this->set('error', $e); } else { $type = AttributeType::getByID($this->post('atID')); $args = array('akHandle' => $this->post('akHandle'), 'akName' => $this->post('akName'), 'akIsSearchable' => $this->post('akIsSearchable'), 'akIsSearchableIndexed' => $this->post('akIsSearchableIndexed'), 'akIsAutoCreated' => 0, 'akIsEditable' => 1); $key->update($this->post()); $this->redirect('/dashboard/store/products/attributes', 'updated'); } } }
public function save() { $data = $this->post(); if ($data['pID']) { $this->edit($data['pID']); } else { $this->add(); } if ($this->isPost()) { $errors = $this->validate($data); $this->error = null; //clear errors $this->error = $errors; if (!$errors->has()) { //save the product $product = StoreProduct::saveProduct($data); //save product attributes $aks = StoreProductKey::getList(); foreach ($aks as $uak) { $uak->saveAttributeForm($product); } //save images StoreProductImage::addImagesForProduct($data, $product); //save product groups StoreProductGroup::addGroupsForProduct($data, $product); //save product user groups StoreProductUserGroup::addUserGroupsForProduct($data, $product); //save product options StoreProductOption::addProductOptions($data, $product); //save files StoreProductFile::addFilesForProduct($data, $product); //save category locations StoreProductLocation::addLocationsForProduct($data, $product); if ($data['pID']) { $this->redirect('/dashboard/store/products/', 'updated'); } else { $this->redirect('/dashboard/store/products/', 'success'); } } //if no errors } //if post }
public function edit($akID = 0) { if ($this->post('akID')) { $akID = $this->post('akID'); } $key = StoreProductKey::getByID($akID); $type = $key->getAttributeType(); $this->set('key', $key); $this->set('type', $type); $this->set('category', AttributeKeyCategory::getByHandle('store_product')); if ($this->isPost()) { $cnt = $type->getController(); $cnt->setAttributeKey($key); $e = $cnt->validateKey($this->post()); if ($e->has()) { $this->set('error', $e); } else { $key->update($this->post()); $this->redirect('/dashboard/store/products/attributes', 'updated'); } } }