Пример #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;
 }
Пример #2
0
 /**
  * Save chosen third-party category
  */
 public function actionIntCatSave()
 {
     $service = Yii::app()->getRequest()->getQuery('service');
     $strSelected = Yii::app()->getRequest()->getQuery('selected');
     $arrSelected = explode("|", $strSelected);
     if (count($arrSelected) > 1) {
         $objCategory = Category::model()->findByPk($arrSelected[0]);
         if ($objCategory instanceof Category) {
             $strTable = "Category" . ucfirst($service);
             $objIntCategory = $strTable::model()->findByPk($arrSelected[1]);
             if ($objIntCategory instanceof $strTable) {
                 if (!$objIntCategory->isUsable) {
                     echo json_encode(ucfirst($service) . " does not allow you to pick this category without choosing a further subcategory.");
                     return;
                 }
                 CategoryIntegration::model()->deleteAllByAttributes(array('category_id' => $objCategory->id, 'module' => $service));
                 $objCI = new CategoryIntegration();
                 $objCI->category_id = $objCategory->id;
                 $objCI->module = $service;
                 $objCI->foreign_id = $objIntCategory->id;
                 switch (count($arrSelected)) {
                     case 4:
                         $objCI->extra = $arrSelected[2] . "," . $arrSelected[3];
                         break;
                     case 3:
                         $objCI->extra = $arrSelected[2];
                         break;
                     case 2:
                         $objCI->extra = null;
                         break;
                 }
                 if (!$objCI->save()) {
                     echo json_encode(_xls_convert_errors($objCI->getErrors()));
                 } else {
                     echo json_encode("success|" . $objIntCategory->name0);
                 }
             } else {
                 echo json_encode(ucfirst($service) . " category not found");
             }
         } else {
             echo json_encode("Web Store category not found");
         }
     } else {
         echo json_encode("Array error");
     }
 }
Пример #3
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("&", "&", $strLine);
    $strLine = str_replace(">", ">", $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;
}