public static function ConvertSEO() { $arrFamilies = Family::model()->findAll(); foreach ($arrFamilies as $objFamily) { $objFamily->request_url = _xls_seo_url($objFamily->family); $objFamily->save(); } }
public static function ConvertSEO() { $arr = Classes::model()->findAll(); foreach ($arr as $obj) { $obj->request_url = _xls_seo_url($obj->class_name); $obj->save(); } }
/** * Return link for current sro * @return string */ public function GenerateLink() { if (empty($this->linkid)) { $this->linkid = _xls_seo_url(_xls_truncate(_xls_encrypt(md5(date("YmdHis"))), 31, '')); $this->save(); return $this->linkid; } else { return $this->linkid; } }
public function actionEdit() { // Retrieve the pageid we're looking to edit $id = Yii::app()->getRequest()->getQuery('id'); $model = CustomPage::model()->findByPk($id); if (!$model instanceof CustomPage) { Yii::app()->user->setFlash('error', "Invalid Custom Page"); $this->redirect($this->createUrl("custompage/index")); } Yii::log('POST: ' . print_r($_POST, true), 'info', 'application.' . __CLASS__ . "." . __FUNCTION__); if (_xls_get_conf('LANG_MENU')) { $langs = _xls_comma_to_array(_xls_get_conf('LANG_OPTIONS')); } else { $langs = array("en:English"); } if (isset($_POST['CustomPage'])) { $model->setPageData($_POST); $_POST['CustomPage']['page_data'] = $model->page_data; $model->attributes = $_POST['CustomPage']; if ($model->validate()) { if ($model->deleteMe) { $model->delete(); Yii::app()->user->setFlash('info', "Custom page has been deleted"); $this->redirect($this->createUrl("custompage/index")); } else { $model->request_url = _xls_seo_url($model->title); if (!$model->save()) { Yii::app()->user->setFlash('error', print_r($model->getErrors(), true)); } else { Yii::app()->user->setFlash('success', Yii::t('admin', 'Custom page updated on {time}.', array('{time}' => date("d F, Y h:i:sa")))); $this->beforeAction('edit'); //In case we renamed one and we want to update menu } } } } $this->render('edit', array('model' => $model)); }
public function readFromSession($page) { switch ($page) { case 2: if (file_exists(Yii::app()->basepath . "/config/wskeys.php")) { $existingKeys = (require Yii::app()->basepath . "/config/wskeys.php"); $this->encryptionKey = $existingKeys['key']; $this->encryptionSalt = $existingKeys['salt']; } else { $this->encryptionKey = _xls_seo_url(_xls_truncate(md5(date("YmdHis")), 50, '')); $this->encryptionSalt = _xls_seo_url(_xls_truncate(md5(date("siHdMY")), 50, '')); } return array('TIMEZONE' => _xls_get_conf('TIMEZONE'), 'LSKEY' => null, 'encryptionKey' => $this->encryptionKey, 'encryptionSalt' => $this->encryptionSalt); case 3: return array('STORE_NAME' => _xls_get_conf('STORE_NAME'), 'EMAIL_FROM' => _xls_get_conf('EMAIL_FROM'), 'STORE_ADDRESS1' => _xls_get_conf('STORE_ADDRESS1'), 'STORE_ADDRESS2' => _xls_get_conf('STORE_ADDRESS2'), 'STORE_CITY' => _xls_get_conf('STORE_CITY'), 'STORE_STATE' => _xls_get_conf('STORE_STATE'), 'STORE_COUNTRY' => _xls_get_conf('STORE_COUNTRY'), 'STORE_ZIP' => _xls_get_conf('STORE_ZIP'), 'STORE_HOURS' => _xls_get_conf('STORE_HOURS'), 'STORE_PHONE' => _xls_get_conf('STORE_PHONE')); case 4: return array('EMAIL_SMTP_SERVER' => _xls_get_conf('EMAIL_SMTP_SERVER'), 'EMAIL_SMTP_PORT' => _xls_get_conf('EMAIL_SMTP_PORT'), 'EMAIL_SMTP_USERNAME' => _xls_get_conf('EMAIL_SMTP_USERNAME'), 'EMAIL_SMTP_PASSWORD' => null, 'EMAIL_SMTP_SECURITY_MODE' => _xls_get_conf('EMAIL_SMTP_SECURITY_MODE')); } }
/** * Builds the SEO friendly request_url for a single product. * @param integer $id The Product Id * @param string $title The Product Title * @param integer $code The Product Code * @return string The SEO formatted reqeuest_url. */ public static function buildRequestUrl($id, $title, $code) { $strRequest = _xls_parse_language($title); if (Yii::app()->params['SEO_URL_CODES']) { $strRequest .= "-" . $code; } if (Yii::app()->params['SEO_URL_CATEGORIES']) { $objProduct = Product::model()->findByPk($id); if ($objProduct instanceof Product === false) { return false; } $objCategory = $objProduct->xlswsCategories; if ($objCategory) { $strBread = $objCategory[0]->getBreadcrumbs("requestUrl"); } if (empty($strBread) === false) { $strRequest = array_pop($strBread) . "-" . $strRequest; } } return _xls_seo_url($strRequest); }
/** * Add a family * * @param string $passkey * @param string $strFamily * @return string */ public function add_family($passkey, $strFamily) { if (!$this->check_passkey($passkey)) { return self::FAIL_AUTH; } if (trim($strFamily) == '') { //ignore blank families return self::OK; } $family = Family::LoadByFamily($strFamily); if (!$family) { $family = new Family(); } $family->family = $strFamily; $family->request_url = _xls_seo_url($strFamily); if (!$family->save()) { Yii::log("SOAP ERROR : Error saving family {$strFamily} " . print_r($family->getErrors()), 'error', 'application.' . __CLASS__ . "." . __FUNCTION__); return self::UNKNOWN_ERROR . " Error saving family {$strFamily} " . print_r($family->getErrors(), true); } return self::OK; }
public function GetSEOPath() { $arrPath = $this->GetTrail('names'); $strPath = implode("-", $arrPath); return _xls_seo_url($strPath); }
/** * Since Validate tests to make sure certain fields have values, populate requirements here such as the modified timestamp * @return boolean from parent */ protected function beforeValidate() { if ($this->isNewRecord) { $this->created = new CDbExpression('NOW()'); } $this->modified = new CDbExpression('NOW()'); $this->request_url = _xls_seo_url($this->title); return parent::beforeValidate(); }
/** * Save a product in the database (Create if need be) * * @param string $passkey * @param int $intRowid * @param string $strCode * @param string $strName * @param string $blbImage * @param string $strClassName * @param int $blnCurrent * @param string $strDescription * @param string $strDescriptionShort * @param string $strFamily * @param int $blnGiftCard * @param int $blnInventoried * @param double $fltInventory * @param double $fltInventoryTotal * @param int $blnMasterModel * @param int $intMasterId * @param string $strProductColor * @param string $strProductSize * @param double $fltProductHeight * @param double $fltProductLength * @param double $fltProductWidth * @param double $fltProductWeight * @param int $intTaxStatusId * @param double $fltSell * @param double $fltSellTaxInclusive * @param double $fltSellWeb * @param string $strUpc * @param int $blnOnWeb * @param string $strWebKeyword1 * @param string $strWebKeyword2 * @param string $strWebKeyword3 * @param int $blnFeatured * @param int $intCategoryId * @return string * @throws SoapFault * * @soap */ public function save_product($passkey, $intRowid, $strCode, $strName, $blbImage, $strClassName, $blnCurrent, $strDescription, $strDescriptionShort, $strFamily, $blnGiftCard, $blnInventoried, $fltInventory, $fltInventoryTotal, $blnMasterModel, $intMasterId, $strProductColor, $strProductSize, $fltProductHeight, $fltProductLength, $fltProductWidth, $fltProductWeight, $intTaxStatusId, $fltSell, $fltSellTaxInclusive, $fltSellWeb, $strUpc, $blnOnWeb, $strWebKeyword1, $strWebKeyword2, $strWebKeyword3, $blnFeatured, $intCategoryId) { self::check_passkey($passkey); // We must preservice the Rowid of Products within the Web Store // database and must therefore see if it already exists $objProduct = Product::model()->findByPk($intRowid); if (!$objProduct) { $objProduct = new Product(); $objProduct->id = $intRowid; } $strName = trim($strName); $strName = trim($strName, '-'); $strName = substr($strName, 0, 255); $strCode = trim($strCode); $strCode = str_replace('"', '', $strCode); $strCode = str_replace("'", '', $strCode); if (empty($strName)) { $strName = 'missing-name'; } if (empty($strDescription)) { $strDescription = ''; } $objProduct->code = $strCode; $objProduct->title = $strName; //$objProduct->class_name = $strClassName; $objProduct->current = $blnCurrent; $objProduct->description_long = $strDescription; $objProduct->description_short = $strDescriptionShort; //$objProduct->family = $strFamily; $objProduct->gift_card = $blnGiftCard; $objProduct->inventoried = $blnInventoried; $objProduct->inventory = $fltInventory; $objProduct->inventory_total = $fltInventoryTotal; $objProduct->master_model = $blnMasterModel; if ($intMasterId > 0) { $objProduct->parent = $intMasterId; } else { $objProduct->parent = null; } $objProduct->product_color = $strProductColor; $objProduct->product_size = $strProductSize; $objProduct->product_height = $fltProductHeight; $objProduct->product_length = $fltProductLength; $objProduct->product_width = $fltProductWidth; $objProduct->product_weight = $fltProductWeight; $objProduct->tax_status_id = $intTaxStatusId; $objProduct->sell = $fltSell; $objProduct->sell_tax_inclusive = $fltSellTaxInclusive; //If we're in TaxIn Mode, then SellWeb has tax and we reverse it. if (_xls_get_conf('TAX_INCLUSIVE_PRICING', 0) == 1) { if ($fltSellWeb != 0) { //Tax in with a sell on web price $objProduct->sell_web_tax_inclusive = $fltSellWeb; //LS sends tax in web already $objProduct->sell_web = Tax::StripTaxesFromPrice($fltSellWeb, $intTaxStatusId); } else { //We use our regular prices and copy them price $objProduct->sell_web_tax_inclusive = $fltSellTaxInclusive; $objProduct->sell_web = $fltSell; } } else { if ($fltSellWeb != 0) { $objProduct->sell_web = $fltSellWeb; } else { $objProduct->sell_web = $fltSell; } } $objProduct->upc = $strUpc; $objProduct->web = $blnOnWeb; $objProduct->featured = $blnFeatured; $fltReserved = $objProduct->CalculateReservedInventory(); $objProduct->inventory_reserved = $fltReserved; if (_xls_get_conf('INVENTORY_FIELD_TOTAL', 0) == 1) { $objProduct->inventory_avail = $fltInventoryTotal - $fltReserved; } else { $objProduct->inventory_avail = $fltInventory - $fltReserved; } //Because Lightspeed may send us products out of sequence (child before parent), we have to turn this off Yii::app()->db->createCommand('SET FOREIGN_KEY_CHECKS=0;')->execute(); if (!$objProduct->save()) { $strMsg = "Error saving product {$intRowid} {$strCode}"; Yii::log("SOAP ERROR : {$strMsg} " . print_r($objProduct->getErrors(), true), CLogger::LEVEL_ERROR, 'application.' . __CLASS__ . "." . __FUNCTION__); Yii::log("Product attributes: " . CVarDumper::dumpAsString($objProduct), CLogger::LEVEL_INFO, 'application.' . __CLASS__ . "." . __FUNCTION__); throw new SoapFault($strMsg, WsSoapException::ERROR_UNKNOWN); } $strFeatured = _xls_get_conf('FEATURED_KEYWORD', 'XnotsetX'); if (empty($strFeatured)) { $strFeatured = 'XnotsetX'; } //Save keywords $strTags = trim($strWebKeyword1) . "," . trim($strWebKeyword2) . "," . trim($strWebKeyword3); $strTags = str_replace(",,", ",", $strTags); $arrTags = explode(",", $strTags); ProductTags::DeleteProductTags($objProduct->id); foreach ($arrTags as $indivTag) { if (!empty($indivTag)) { $tag = Tags::model()->findByAttributes(array('tag' => $indivTag)); if (!$tag instanceof Tags) { $tag = new Tags(); $tag->tag = $indivTag; $tag->save(); } $objProductTag = new ProductTags(); $objProductTag->product_id = $objProduct->id; $objProductTag->tag_id = $tag->id; $objProductTag->save(); if ($strFeatured != 'XnotsetX' && $objProduct->web && $indivTag == $strFeatured) { $objProduct->featured = 1; $objProduct->save(); } } } if (!empty($strFamily)) { $objFamily = Family::model()->findByAttributes(array('family' => $strFamily)); if ($objFamily instanceof Family) { $objProduct->family_id = $objFamily->id; $objProduct->save(); } else { $objFamily = new Family(); $objFamily->family = $strFamily; $objFamily->child_count = 0; $objFamily->request_url = _xls_seo_url($strFamily); $objFamily->save(); $objProduct->family_id = $objFamily->id; $objProduct->save(); } $objFamily->UpdateChildCount(); } else { if ($objProduct->family_id) { $objFamily = Family::model()->findByAttributes(array('id' => $objProduct->family_id)); $objProduct->family_id = null; $objProduct->save(); $objFamily->UpdateChildCount(); } } if (!empty($strClassName)) { $objClass = Classes::model()->findByAttributes(array('class_name' => $strClassName)); if ($objClass instanceof Classes) { $objProduct->class_id = $objClass->id; $objProduct->save(); } else { $objClass = new Classes(); $objClass->class_name = $strClassName; $objClass->child_count = 0; $objClass->request_url = _xls_seo_url($strClassName); $objClass->save(); $objProduct->class_id = $objClass->id; $objProduct->save(); } $objClass->UpdateChildCount(); } // Assign the product category. // Delete any prior category from the product. ProductCategoryAssn::model()->deleteAllByAttributes(array('product_id' => $objProduct->id)); // A categoryId of 0 indicates that the Item is not assigned to a category. if ($intCategoryId !== 0) { $objCategory = Category::model()->findByPk($intCategoryId); if ($objCategory === null) { Yii::log('Unable to find matching category.', 'error', 'application.' . __CLASS__ . "." . __FUNCTION__); } else { $objAssn = new ProductCategoryAssn(); $objAssn->product_id = $objProduct->id; $objAssn->category_id = $intCategoryId; $objAssn->save(); $objCategory->UpdateChildCount(); } } Product::convertSEO($intRowid); //Build request_url Yii::app()->db->createCommand('SET FOREIGN_KEY_CHECKS=1;')->execute(); $objEvent = new CEventProduct('LegacysoapController', 'onSaveProduct', $objProduct); _xls_raise_events('CEventProduct', $objEvent); return self::OK; }