コード例 #1
0
        public function saveOrUpdatePrdprcCat($model, $extcatid = null, $newcatid)
    {
        $product_id = $model->product_id;
        $productprice_id = $model->id;
        $result = array();
        if(!empty($extcatid))
        {
            $condition = 'product_id=' . $product_id;
            $condition .= ' AND productprice_id = ' . $productprice_id;
            $condition .= ' AND category_id = ' . $extcatid;

            $criteria = new CDbCriteria;
            $criteria->select = array( 'id' );
            $criteria->condition = $condition;
            $result = Masterproductcategory::model()->findAll( $criteria );   
        }
        if(count($result) > 0)
        {
            $prdcat = Masterproductcategory::model()->findByPk( $result[0]->id );
        }
        else
        {
            $prdcat = new Masterproductcategory;
        }
        $prdcat->product_id = $product_id;
        $prdcat->productprice_id = $productprice_id;
        $prdcat->category_id = $newcatid;
        $rtn = $prdcat->save();
        if(!$rtn)
        {
            $this->msg = $prdcat->getErrors();
        }
        return $rtn;
    }
コード例 #2
0
  public function actionGetProductlist(){
      $postedData = $this->getPostedData();
          $condition = 'category_id='.$postedData['categoryId'];
          $criteria = new CDbCriteria;
          $criteria->select = array( 'product_id' );
          $criteria->condition = $condition;        
          $result = Masterproductcategory::model()->findAll( $criteria );    
      $chk1 =$result[0];
      $chk =$result[0]->product_id ;
      if(count($result) > 0)
      {
          $data = Product::model()->findByPk( $result[0]->product_id );
      }  
      $json = new CArJSON;            
    $relations = array();
          $attributes = array(
              'root' => array()				
          );
          $isarray = true;
            $data = $json->toJSON($data, $relations, $attributes, $isarray);
              $rtnCode = Helper::CONST_Error_None;
          $message = Helper::CONST_NotFound_Message;
 $this->returnJsonResponse($rtnCode, $data, $message);
 
  }