Exemple #1
0
 public function getIntegration()
 {
     $objCategoryInte = CategoryIntegration::model()->findByAttributes(array('category_id' => $this->id, 'module' => 'amazon'));
     if ($objCategoryInte instanceof CategoryIntegration) {
         $this->integrated['amazon']['original'] = CategoryAmazon::model()->findByPk($objCategoryInte->foreign_id);
         $this->integrated['amazon']['int'] = $objCategoryInte;
     }
     $objCategoryInte = CategoryIntegration::model()->findByAttributes(array('category_id' => $this->id, 'module' => 'google'));
     if ($objCategoryInte instanceof CategoryIntegration) {
         $this->integrated['google']['original'] = CategoryGoogle::model()->findByPk($objCategoryInte->foreign_id);
         $this->integrated['google']['int'] = $objCategoryInte;
     }
     return $this;
 }
 /**
  * 9-13 load amazon, Convert our web keywords into new tags table
  */
 protected function actionConvertGoogle()
 {
     $ct = 0;
     //Load google categories
     _dbx('SET FOREIGN_KEY_CHECKS=0');
     if ($this->online == 9) {
         Yii::app()->db->createCommand()->truncateTable(CategoryGoogle::model()->tableName());
     }
     $file = fopen(YiiBase::getPathOfAlias('ext.wsgoogle.assets') . "/googlecategories.txt", "r");
     if ($file) {
         while (!feof($file)) {
             $strLine = fgets($file);
             $ct++;
             if ($ct >= 1 && $ct <= 1000 && $this->online == 9 || $ct >= 1001 && $ct <= 2000 && $this->online == 10 || $ct >= 2001 && $ct <= 3000 && $this->online == 11 || $ct >= 3001 && $ct <= 4000 && $this->online == 12 || $ct >= 4001 && $ct <= 5000 && $this->online == 13) {
                 $objGC = new CategoryGoogle();
                 $objGC->name0 = trim($strLine);
                 $arrItems = array_filter(explode(" > ", $strLine));
                 if (isset($arrItems[0])) {
                     $objGC->name1 = trim($arrItems[0]);
                 }
                 if (isset($arrItems[1])) {
                     $objGC->name2 = trim($arrItems[1]);
                 }
                 if (isset($arrItems[2])) {
                     $objGC->name3 = trim($arrItems[2]);
                 }
                 if (isset($arrItems[3])) {
                     $objGC->name4 = trim($arrItems[3]);
                 }
                 if (isset($arrItems[4])) {
                     $objGC->name5 = trim($arrItems[4]);
                 }
                 if (isset($arrItems[5])) {
                     $objGC->name6 = trim($arrItems[5]);
                 }
                 if (isset($arrItems[6])) {
                     $objGC->name7 = trim($arrItems[6]);
                 }
                 if (isset($arrItems[7])) {
                     $objGC->name8 = trim($arrItems[7]);
                 }
                 if (isset($arrItems[8])) {
                     $objGC->name9 = trim($arrItems[8]);
                 }
                 $objGC->save();
             }
         }
     }
     fclose($file);
     if ($this->online == 13) {
         for ($x = 1; $x <= 9; $x++) {
             _dbx("update xlsws_category_google set `name" . $x . "`=null where `name" . $x . "`=''");
         }
         CategoryGoogle::model()->deleteAllByAttributes(array('name1' => null));
         //Import old google categories to new
         try {
             $dbC = Yii::app()->db->createCommand();
             $dbC->setFetchMode(PDO::FETCH_OBJ);
             //fetch each row as Object
             $dbC->select()->from('xlsws_category')->where('google_id IS NOT NULL')->order('id');
             foreach ($dbC->queryAll() as $row) {
                 _dbx("delete from xlsws_category_integration where module='google' AND foreign_id=" . $row->google_id . " and category_id=" . $row->id);
                 $obj = new CategoryIntegration();
                 $obj->category_id = $row->id;
                 $obj->module = "google";
                 $obj->foreign_id = $row->google_id;
                 $obj->extra = $row->google_extra;
                 $obj->save();
             }
             _dbx("alter table xlsws_category drop google_id");
             _dbx("alter table xlsws_category drop google_extra");
         } catch (Exception $e) {
         }
     }
     _dbx('SET FOREIGN_KEY_CHECKS=1');
     return array('result' => "success", 'makeline' => $this->online + 1, 'tag' => 'Installing Google categories (group ' . ($this->online - 7) . " of 6)", 'total' => 50);
 }
 /**
  * Return the Google Category record based on the complete name (path)
  * @param $strParam1
  * @return CActiveRecord
  */
 public static function LoadByName($strParam1)
 {
     // This will return a single GoogleCategories object
     return CategoryGoogle::model()->findByAttributes(array('name0' => $strParam1));
 }
Exemple #4
0
function _xls_get_googlecategory($intProductRowid)
{
    $objGoogle = Yii::app()->db->createCommand("SELECT d.name0, extra\n\t\tFROM " . ProductCategoryAssn::model()->tableName() . " AS a\n\t\tLEFT JOIN " . Category::model()->tableName() . " AS b ON a.category_id=b.id\n\t\tLEFT JOIN " . CategoryIntegration::model()->tableName() . " AS c ON a.category_id=c.category_id\n\t\tLEFT JOIN " . CategoryGoogle::model()->tableName() . " as d ON c.foreign_id=d.id\n\t\tWHERE c.module='google' AND a.product_id=" . $intProductRowid)->queryRow();
    $strLine = $objGoogle['name0'];
    $strLine = str_replace("&", "&amp;", $strLine);
    $strLine = str_replace(">", "&gt;", $strLine);
    $arrGoogle = array();
    $arrGoogle['Category'] = trim($strLine);
    if (!empty($objGoogle['extra'])) {
        $arrX = explode(",", $objGoogle['extra']);
        $arrGoogle['Gender'] = $arrX[0];
        $arrGoogle['Age'] = $arrX[1];
    }
    return $arrGoogle;
}